1<sys/mman.h>(0P) POSIX Programmer's Manual <sys/mman.h>(0P)
2
3
4
6 sys/mman.h - memory management declarations
7
9 #include <sys/mman.h>
10
12 The <sys/mman.h> header shall be supported if the implementation sup‐
13 ports at least one of the following options:
14
15 * The Memory Mapped Files option
16
17 * The Shared Memory Objects option
18
19 * The Process Memory Locking option
20
21 * The Memory Protection option
22
23 * The Typed Memory Objects option
24
25 * The Synchronized Input and Output option
26
27 * The Advisory Information option
28
29 * The Typed Memory Objects option
30
31 If one or more of the Advisory Information, Memory Mapped Files, or
32 Shared Memory Objects options are supported, the following protection
33 options shall be defined:
34
35 PROT_READ
36 Page can be read.
37
38 PROT_WRITE
39 Page can be written.
40
41 PROT_EXEC
42 Page can be executed.
43
44 PROT_NONE
45 Page cannot be accessed.
46
47
48 The following flag options shall be defined:
49
50 MAP_SHARED
51 Share changes.
52
53 MAP_PRIVATE
54 Changes are private.
55
56 MAP_FIXED
57 Interpret addr exactly.
58
59
60 The following flags shall be defined for msync():
61
62 MS_ASYNC
63 Perform asynchronous writes.
64
65 MS_SYNC
66 Perform synchronous writes.
67
68 MS_INVALIDATE
69 Invalidate mappings.
70
71
72 The following symbolic constants shall be defined for the mlockall()
73 function:
74
75 MCL_CURRENT
76 Lock currently mapped pages.
77
78 MCL_FUTURE
79 Lock pages that become mapped.
80
81
82 The symbolic constant MAP_FAILED shall be defined to indicate a failure
83 from the mmap() function.
84
85 If the Advisory Information and either the Memory Mapped Files or
86 Shared Memory Objects options are supported, values for advice used by
87 posix_madvise() shall be defined as follows:
88
89 POSIX_MADV_NORMAL
90
91 The application has no advice to give on its behavior with
92 respect to the specified range. It is the default characteristic
93 if no advice is given for a range of memory.
94
95 POSIX_MADV_SEQUENTIAL
96
97 The application expects to access the specified range sequen‐
98 tially from lower addresses to higher addresses.
99
100 POSIX_MADV_RANDOM
101
102 The application expects to access the specified range in a ran‐
103 dom order.
104
105 POSIX_MADV_WILLNEED
106
107 The application expects to access the specified range in the
108 near future.
109
110 POSIX_MADV_DONTNEED
111
112 The application expects that it will not access the specified
113 range in the near future.
114
115
116 The following flags shall be defined for posix_typed_mem_open():
117
118 POSIX_TYPED_MEM_ALLOCATE
119
120 Allocate on mmap().
121
122 POSIX_TYPED_MEM_ALLOCATE_CONTIG
123
124 Allocate contiguously on mmap().
125
126 POSIX_TYPED_MEM_MAP_ALLOCATABLE
127
128 Map on mmap(), without affecting allocatability.
129
130
131 The mode_t, off_t, and size_t types shall be defined as described in
132 <sys/types.h> .
133
134 The <sys/mman.h> header shall define the structure
135 posix_typed_mem_info, which includes at least the following member:
136
137
138 size_t posix_tmi_length Maximum length which may be allocated
139 from a typed memory object.
140
141 The following shall be declared as functions and may also be defined as
142 macros. Function prototypes shall be provided.
143
144
145 int mlock(const void *, size_t);
146
147
148 int mlockall(int);
149
150
151 void *mmap(void *, size_t, int, int, int, off_t);
152
153
154 int mprotect(void *, size_t, int);
155
156
157 int msync(void *, size_t, int);
158
159
160 int munlock(const void *, size_t);
161
162
163 int munlockall(void);
164
165
166 int munmap(void *, size_t);
167
168
169 int posix_madvise(void *, size_t, int);
170
171
172 int posix_mem_offset(const void *restrict, size_t, off_t *restrict,
173 size_t *restrict, int *restrict);
174 int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
175 int posix_typed_mem_open(const char *, int, int);
176
177
178 int shm_open(const char *, int, mode_t);
179 int shm_unlink(const char *);
180
181
182 The following sections are informative.
183
185 None.
186
188 None.
189
191 None.
192
194 <sys/types.h>, the System Interfaces volume of IEEE Std 1003.1-2001,
195 mlock(), mlockall(), mmap(), mprotect(), msync(), munlock(), munlock‐
196 all(), munmap(), posix_mem_offset(), posix_typed_mem_get_info(),
197 posix_typed_mem_open(), shm_open(), shm_unlink()
198
200 Portions of this text are reprinted and reproduced in electronic form
201 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
202 -- Portable Operating System Interface (POSIX), The Open Group Base
203 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
204 Electrical and Electronics Engineers, Inc and The Open Group. In the
205 event of any discrepancy between this version and the original IEEE and
206 The Open Group Standard, the original IEEE and The Open Group Standard
207 is the referee document. The original Standard can be obtained online
208 at http://www.opengroup.org/unix/online.html .
209
210
211
212IEEE/The Open Group 2003 <sys/mman.h>(0P)