1sys_mman.h(0P) POSIX Programmer's Manual sys_mman.h(0P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 sys/mman.h — memory management declarations
14
16 #include <sys/mman.h>
17
19 The <sys/mman.h> header shall define the following symbolic constants
20 for use as protection options:
21
22 PROT_EXEC Page can be executed.
23
24 PROT_NONE Page cannot be accessed.
25
26 PROT_READ Page can be read.
27
28 PROT_WRITE Page can be written.
29
30 The <sys/mman.h> header shall define the following symbolic constants
31 for use as flag options:
32
33 MAP_FIXED Interpret addr exactly.
34
35 MAP_PRIVATE Changes are private.
36
37 MAP_SHARED Share changes.
38
39 The <sys/mman.h> header shall define the following symbolic constants
40 for the msync() function:
41
42 MS_ASYNC Perform asynchronous writes.
43
44 MS_INVALIDATE Invalidate mappings.
45
46 MS_SYNC Perform synchronous writes.
47
48 The <sys/mman.h> header shall define the following symbolic constants
49 for the mlockall() function:
50
51 MCL_CURRENT Lock currently mapped pages.
52
53 MCL_FUTURE Lock pages that become mapped.
54
55 The <sys/mman.h> header shall define the symbolic constant MAP_FAILED
56 which shall have type void * and shall be used to indicate a failure
57 from the mmap() function .
58
59 If the Advisory Information option is supported, the <sys/mman.h>
60 header shall define symbolic constants for the advice argument to the
61 posix_madvise() function as follows:
62
63 POSIX_MADV_DONTNEED
64 The application expects that it will not access the specified
65 range in the near future.
66
67 POSIX_MADV_NORMAL
68 The application has no advice to give on its behavior with
69 respect to the specified range. It is the default characteristic
70 if no advice is given for a range of memory.
71
72 POSIX_MADV_RANDOM
73 The application expects to access the specified range in a random
74 order.
75
76 POSIX_MADV_SEQUENTIAL
77 The application expects to access the specified range sequen‐
78 tially from lower addresses to higher addresses.
79
80 POSIX_MADV_WILLNEED
81 The application expects to access the specified range in the near
82 future.
83
84 The <sys/mman.h> header shall define the following symbolic constants
85 for use as flags for the posix_typed_mem_open() function:
86
87 POSIX_TYPED_MEM_ALLOCATE
88 Allocate on mmap().
89
90 POSIX_TYPED_MEM_ALLOCATE_CONTIG
91 Allocate contiguously on mmap().
92
93 POSIX_TYPED_MEM_MAP_ALLOCATABLE
94 Map on mmap(), without affecting allocatability.
95
96 The <sys/mman.h> header shall define the mode_t, off_t, and size_t
97 types as described in <sys_types.h>.
98
99 The <sys/mman.h> header shall define the posix_typed_mem_info struc‐
100 ture, which shall include at least the following member:
101
102 size_t posix_tmi_length Maximum length which may be allocated
103 from a typed memory object.
104
105 The following shall be declared as functions and may also be defined as
106 macros. Function prototypes shall be provided.
107
108 int mlock(const void *, size_t);
109 int mlockall(int);
110 void *mmap(void *, size_t, int, int, int, off_t);
111 int mprotect(void *, size_t, int);
112 int msync(void *, size_t, int);
113 int munlock(const void *, size_t);
114 int munlockall(void);
115 int munmap(void *, size_t);
116 int posix_madvise(void *, size_t, int);
117 int posix_mem_offset(const void *restrict, size_t, off_t *restrict,
118 size_t *restrict, int *restrict);
119 int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
120 int posix_typed_mem_open(const char *, int, int);
121 int shm_open(const char *, int, mode_t);
122 int shm_unlink(const char *);
123
124 The following sections are informative.
125
127 None.
128
130 None.
131
133 None.
134
136 <sys_types.h>
137
138 The System Interfaces volume of POSIX.1‐2008, mlock(), mlockall(),
139 mmap(), mprotect(), msync(), munmap(), posix_madvise(), posix_mem_off‐
140 set(), posix_typed_mem_get_info(), posix_typed_mem_open(), shm_open(),
141 shm_unlink()
142
144 Portions of this text are reprinted and reproduced in electronic form
145 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
146 -- Portable Operating System Interface (POSIX), The Open Group Base
147 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
148 cal and Electronics Engineers, Inc and The Open Group. (This is
149 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
150 event of any discrepancy between this version and the original IEEE and
151 The Open Group Standard, the original IEEE and The Open Group Standard
152 is the referee document. The original Standard can be obtained online
153 at http://www.unix.org/online.html .
154
155 Any typographical or formatting errors that appear in this page are
156 most likely to have been introduced during the conversion of the source
157 files to man page format. To report such errors, see https://www.ker‐
158 nel.org/doc/man-pages/reporting_bugs.html .
159
160
161
162IEEE/The Open Group 2013 sys_mman.h(0P)