| 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_16KB (14 << 26) |
| 48 |
#define MAP_HUGE_64KB (16 << 26) |
| 49 |
#define MAP_HUGE_512KB (19 << 26) |
| 50 |
#define MAP_HUGE_1MB (20 << 26) |
| 51 |
#define MAP_HUGE_2MB (21 << 26) |
| 52 |
#define MAP_HUGE_8MB (23 << 26) |
| 53 |
#define MAP_HUGE_16MB (24 << 26) |
| 54 |
#define MAP_HUGE_32MB (25 << 26) |
| 55 |
#define MAP_HUGE_256MB (28 << 26) |
| 56 |
#define MAP_HUGE_512MB (29 << 26) |
| 57 |
#define MAP_HUGE_1GB (30 << 26) |
| 58 |
#define MAP_HUGE_2GB (31 << 26) |
| 59 |
#define MAP_HUGE_16GB (34U << 26) |
| 60 |
|
| 61 |
#define PROT_NONE 0 |
| 62 |
#define PROT_READ 1 |
| 63 |
#define PROT_WRITE 2 |
| 64 |
#define PROT_EXEC 4 |
| 65 |
#define PROT_GROWSDOWN 0x01000000 |
| 66 |
#define PROT_GROWSUP 0x02000000 |
| 67 |
|
| 68 |
#define MS_ASYNC 1 |
| 69 |
#define MS_INVALIDATE 2 |
| 70 |
#define MS_SYNC 4 |
| 71 |
|
| 72 |
#define MCL_CURRENT 1 |
| 73 |
#define MCL_FUTURE 2 |
| 74 |
#define MCL_ONFAULT 4 |
| 75 |
|
| 76 |
#define POSIX_MADV_NORMAL 0 |
| 77 |
#define POSIX_MADV_RANDOM 1 |
| 78 |
#define POSIX_MADV_SEQUENTIAL 2 |
| 79 |
#define POSIX_MADV_WILLNEED 3 |
| 80 |
#define POSIX_MADV_DONTNEED 4 |
| 81 |
|
| 82 |
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 83 |
#define MADV_NORMAL 0 |
| 84 |
#define MADV_RANDOM 1 |
| 85 |
#define MADV_SEQUENTIAL 2 |
| 86 |
#define MADV_WILLNEED 3 |
| 87 |
#define MADV_DONTNEED 4 |
| 88 |
#define MADV_FREE 8 |
| 89 |
#define MADV_REMOVE 9 |
| 90 |
#define MADV_DONTFORK 10 |
| 91 |
#define MADV_DOFORK 11 |
| 92 |
#define MADV_MERGEABLE 12 |
| 93 |
#define MADV_UNMERGEABLE 13 |
| 94 |
#define MADV_HUGEPAGE 14 |
| 95 |
#define MADV_NOHUGEPAGE 15 |
| 96 |
#define MADV_DONTDUMP 16 |
| 97 |
#define MADV_DODUMP 17 |
| 98 |
#define MADV_WIPEONFORK 18 |
| 99 |
#define MADV_KEEPONFORK 19 |
| 100 |
#define MADV_COLD 20 |
| 101 |
#define MADV_PAGEOUT 21 |
| 102 |
#define MADV_HWPOISON 100 |
| 103 |
#define MADV_SOFT_OFFLINE 101 |
| 104 |
#endif |
| 105 |
|
| 106 |
#ifdef _GNU_SOURCE |
| 107 |
#define MREMAP_MAYMOVE 1 |
| 108 |
#define MREMAP_FIXED 2 |
| 109 |
#define MREMAP_DONTUNMAP 4 |
| 110 |
|
| 111 |
#define MLOCK_ONFAULT 0x01 |
| 112 |
|
| 113 |
#define MFD_CLOEXEC 0x0001U |
| 114 |
#define MFD_ALLOW_SEALING 0x0002U |
| 115 |
#define MFD_HUGETLB 0x0004U |
| 116 |
#endif |
| 117 |
|
| 118 |
#include <bits/mman.h> |
| 119 |
|
| 120 |
void *mmap (void *, size_t, int, int, int, off_t); |
| 121 |
int munmap (void *, size_t); |
| 122 |
|
| 123 |
int mprotect (void *, size_t, int); |
| 124 |
int msync (void *, size_t, int); |
| 125 |
|
| 126 |
int posix_madvise (void *, size_t, int); |
| 127 |
|
| 128 |
int mlock (const void *, size_t); |
| 129 |
int munlock (const void *, size_t); |
| 130 |
int mlockall (int); |
| 131 |
int munlockall (void); |
| 132 |
|
| 133 |
#ifdef _GNU_SOURCE |
| 134 |
void *mremap (void *, size_t, size_t, int, ...); |
| 135 |
int remap_file_pages (void *, size_t, int, size_t, int); |
| 136 |
int memfd_create (const char *, unsigned); |
| 137 |
int mlock2 (const void *, size_t, unsigned); |
| 138 |
#endif |
| 139 |
|
| 140 |
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 141 |
int madvise (void *, size_t, int); |
| 142 |
int mincore (void *, size_t, unsigned char *); |
| 143 |
#endif |
| 144 |
|
| 145 |
int shm_open (const char *, int, mode_t); |
| 146 |
int shm_unlink (const char *); |
| 147 |
|
| 148 |
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
| 149 |
#define mmap64 mmap |
| 150 |
#define off64_t off_t |
| 151 |
#endif |
| 152 |
|
| 153 |
#ifdef __cplusplus |
| 154 |
} |
| 155 |
#endif |
| 156 |
#endif |
| 157 |
#endif |