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) 53 #define MAP_HUGE_32MB (25 << 26) 54 #define MAP_HUGE_256MB (28 << 26) 55 #define MAP_HUGE_512MB (29 << 26) 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_COLD 20 100 #define MADV_PAGEOUT 21 101 #define MADV_HWPOISON 100 102 #define MADV_SOFT_OFFLINE 101 103 #endif 104 105 #ifdef _GNU_SOURCE 106 #define MREMAP_MAYMOVE 1 107 #define MREMAP_FIXED 2 108 #define MREMAP_DONTUNMAP 4 109 110 #define MLOCK_ONFAULT 0x01 111 112 #define MFD_CLOEXEC 0x0001U 113 #define MFD_ALLOW_SEALING 0x0002U 114 #define MFD_HUGETLB 0x0004U 115 #endif 116 117 #include <bits/mman.h> 118 119 void *mmap (void *, size_t, int, int, int, off_t); 120 int munmap (void *, size_t); 121 122 int mprotect (void *, size_t, int); 123 int msync (void *, size_t, int); 124 125 int posix_madvise (void *, size_t, int); 126 127 int mlock (const void *, size_t); 128 int munlock (const void *, size_t); 129 int mlockall (int); 130 int munlockall (void); 131 132 #ifdef _GNU_SOURCE 133 void *mremap (void *, size_t, size_t, int, ...); 134 int remap_file_pages (void *, size_t, int, size_t, int); 135 int memfd_create (const char *, unsigned); 136 int mlock2 (const void *, size_t, unsigned); 137 #endif 138 139 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 140 int madvise (void *, size_t, int); 141 int mincore (void *, size_t, unsigned char *); 142 #endif 143 144 int shm_open (const char *, int, mode_t); 145 int shm_unlink (const char *); 146 147 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 148 #define mmap64 mmap 149 #define off64_t off_t 150 #endif 151 152 #ifdef __cplusplus 153 } 154 #endif 155 #endif 156 #endif 157