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
12 sys/mman.h — memory management declarations
13
15 #include <sys/mman.h>
16
18 The <sys/mman.h> header shall define the following symbolic constants
19 for use as protection options:
20
21 PROT_EXEC Page can be executed.
22
23 PROT_NONE Page cannot be accessed.
24
25 PROT_READ Page can be read.
26
27 PROT_WRITE Page can be written.
28
29 The <sys/mman.h> header shall define the following symbolic constants
30 for use as flag options:
31
32 MAP_FIXED Interpret addr exactly.
33
34 MAP_PRIVATE Changes are private.
35
36 MAP_SHARED Share changes.
37
38 The <sys/mman.h> header shall define the following symbolic constants
39 for the msync() function:
40
41 MS_ASYNC Perform asynchronous writes.
42
43 MS_INVALIDATE Invalidate mappings.
44
45 MS_SYNC Perform synchronous writes.
46
47 The <sys/mman.h> header shall define the following symbolic constants
48 for the mlockall() function:
49
50 MCL_CURRENT Lock currently mapped pages.
51
52 MCL_FUTURE Lock pages that become mapped.
53
54 The <sys/mman.h> header shall define the symbolic constant MAP_FAILED
55 which shall have type void * and shall be used to indicate a failure
56 from the mmap() function .
57
58 If the Advisory Information option is supported, the <sys/mman.h>
59 header shall define symbolic constants for the advice argument to the
60 posix_madvise() function as follows:
61
62 POSIX_MADV_DONTNEED
63 The application expects that it will not access the specified
64 range in the near future.
65
66 POSIX_MADV_NORMAL
67 The application has no advice to give on its behavior with
68 respect to the specified range. It is the default characteristic
69 if no advice is given for a range of memory.
70
71 POSIX_MADV_RANDOM
72 The application expects to access the specified range in a random
73 order.
74
75 POSIX_MADV_SEQUENTIAL
76 The application expects to access the specified range sequen‐
77 tially from lower addresses to higher addresses.
78
79 POSIX_MADV_WILLNEED
80 The application expects to access the specified range in the near
81 future.
82
83 The <sys/mman.h> header shall define the following symbolic constants
84 for use as flags for the posix_typed_mem_open() function:
85
86 POSIX_TYPED_MEM_ALLOCATE
87 Allocate on mmap().
88
89 POSIX_TYPED_MEM_ALLOCATE_CONTIG
90 Allocate contiguously on mmap().
91
92 POSIX_TYPED_MEM_MAP_ALLOCATABLE
93 Map on mmap(), without affecting allocatability.
94
95 The <sys/mman.h> header shall define the mode_t, off_t, and size_t
96 types as described in <sys_types.h>.
97
98 The <sys/mman.h> header shall define the posix_typed_mem_info struc‐
99 ture, which shall include at least the following member:
100
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
109 int mlock(const void *, size_t);
110 int mlockall(int);
111 void *mmap(void *, size_t, int, int, int, off_t);
112 int mprotect(void *, size_t, int);
113 int msync(void *, size_t, int);
114 int munlock(const void *, size_t);
115 int munlockall(void);
116 int munmap(void *, size_t);
117 int posix_madvise(void *, size_t, int);
118 int posix_mem_offset(const void *restrict, size_t, off_t *restrict,
119 size_t *restrict, int *restrict);
120 int posix_typed_mem_get_info(int, struct posix_typed_mem_info *);
121 int posix_typed_mem_open(const char *, int, int);
122 int shm_open(const char *, int, mode_t);
123 int shm_unlink(const char *);
124
125 The following sections are informative.
126
128 None.
129
131 None.
132
134 None.
135
137 <sys_types.h>
138
139 The System Interfaces volume of POSIX.1‐2017, mlock(), mlockall(),
140 mmap(), mprotect(), msync(), munmap(), posix_madvise(), posix_mem_off‐
141 set(), posix_typed_mem_get_info(), posix_typed_mem_open(), shm_open(),
142 shm_unlink()
143
145 Portions of this text are reprinted and reproduced in electronic form
146 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
147 table Operating System Interface (POSIX), The Open Group Base Specifi‐
148 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
149 Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/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 2017 sys_mman.h(0P)