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