• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef	_SYS_MMAN_H
2 #define	_SYS_MMAN_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #include <features.h>
8 
9 #define __NEED_mode_t
10 #define __NEED_size_t
11 #define __NEED_off_t
12 
13 #if defined(_GNU_SOURCE)
14 #define __NEED_ssize_t
15 #endif
16 
17 #include <bits/alltypes.h>
18 
19 #define MAP_FAILED ((void *) -1)
20 
21 #define MAP_SHARED     0x01
22 #define MAP_PRIVATE    0x02
23 #define MAP_SHARED_VALIDATE 0x03
24 #define MAP_TYPE       0x0f
25 #define MAP_FIXED      0x10
26 #define MAP_ANON       0x20
27 #define MAP_ANONYMOUS  MAP_ANON
28 #define MAP_NORESERVE  0x4000
29 #define MAP_GROWSDOWN  0x0100
30 #define MAP_DENYWRITE  0x0800
31 #define MAP_EXECUTABLE 0x1000
32 #define MAP_LOCKED     0x2000
33 #define MAP_POPULATE   0x8000
34 #define MAP_NONBLOCK   0x10000
35 #define MAP_STACK      0x20000
36 #define MAP_HUGETLB    0x40000
37 #define MAP_SYNC       0x80000
38 #define MAP_FIXED_NOREPLACE 0x100000
39 #define MAP_FILE       0
40 
41 #define MAP_HUGE_SHIFT 26
42 #define MAP_HUGE_MASK  0x3f
43 #define MAP_HUGE_64KB  (16 << 26)
44 #define MAP_HUGE_512KB (19 << 26)
45 #define MAP_HUGE_1MB   (20 << 26)
46 #define MAP_HUGE_2MB   (21 << 26)
47 #define MAP_HUGE_8MB   (23 << 26)
48 #define MAP_HUGE_16MB  (24 << 26)
49 #define MAP_HUGE_32MB  (25 << 26)
50 #define MAP_HUGE_256MB (28 << 26)
51 #define MAP_HUGE_512MB (29 << 26)
52 #define MAP_HUGE_1GB   (30 << 26)
53 #define MAP_HUGE_2GB   (31 << 26)
54 #define MAP_HUGE_16GB  (34U << 26)
55 
56 #define PROT_NONE      0
57 #define PROT_READ      1
58 #define PROT_WRITE     2
59 #define PROT_EXEC      4
60 #define PROT_GROWSDOWN 0x01000000
61 #define PROT_GROWSUP   0x02000000
62 
63 #define MS_ASYNC       1
64 #define MS_INVALIDATE  2
65 #define MS_SYNC        4
66 
67 #define MCL_CURRENT    1
68 #define MCL_FUTURE     2
69 #define MCL_ONFAULT    4
70 
71 #define POSIX_MADV_NORMAL     0
72 #define POSIX_MADV_RANDOM     1
73 #define POSIX_MADV_SEQUENTIAL 2
74 #define POSIX_MADV_WILLNEED   3
75 #define POSIX_MADV_DONTNEED   4
76 
77 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
78 #define MADV_NORMAL      0
79 #define MADV_RANDOM      1
80 #define MADV_SEQUENTIAL  2
81 #define MADV_WILLNEED    3
82 #define MADV_DONTNEED    4
83 #define MADV_FREE        8
84 #define MADV_REMOVE      9
85 #define MADV_DONTFORK    10
86 #define MADV_DOFORK      11
87 #define MADV_MERGEABLE   12
88 #define MADV_UNMERGEABLE 13
89 #define MADV_HUGEPAGE    14
90 #define MADV_NOHUGEPAGE  15
91 #define MADV_DONTDUMP    16
92 #define MADV_DODUMP      17
93 #define MADV_WIPEONFORK  18
94 #define MADV_KEEPONFORK  19
95 #define MADV_COLD        20
96 #define MADV_PAGEOUT     21
97 #define MADV_HWPOISON    100
98 #define MADV_SOFT_OFFLINE 101
99 #endif
100 
101 #ifdef _GNU_SOURCE
102 #define MREMAP_MAYMOVE 1
103 #define MREMAP_FIXED 2
104 
105 #define MLOCK_ONFAULT 0x01
106 
107 #define MFD_CLOEXEC 0x0001U
108 #define MFD_ALLOW_SEALING 0x0002U
109 #define MFD_HUGETLB 0x0004U
110 #endif
111 
112 #include <bits/mman.h>
113 
114 void *mmap (void *, size_t, int, int, int, off_t);
115 int munmap (void *, size_t);
116 
117 int mprotect (void *, size_t, int);
118 int msync (void *, size_t, int);
119 
120 int posix_madvise (void *, size_t, int);
121 
122 int mlock (const void *, size_t);
123 int munlock (const void *, size_t);
124 int mlockall (int);
125 int munlockall (void);
126 
127 #ifdef _GNU_SOURCE
128 void *mremap (void *, size_t, size_t, int, ...);
129 int remap_file_pages (void *, size_t, int, size_t, int);
130 int memfd_create (const char *, unsigned);
131 int mlock2 (const void *, size_t, unsigned);
132 #endif
133 
134 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
135 int madvise (void *, size_t, int);
136 int mincore (void *, size_t, unsigned char *);
137 #endif
138 
139 int shm_open (const char *, int, mode_t);
140 int shm_unlink (const char *);
141 
142 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
143 #define mmap64 mmap
144 #define off64_t off_t
145 #endif
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 #endif
151