| 1 | #ifndef _MEMMAP_H |
| 2 | #define _MEMMAP_H |
| 3 | |
| 4 | #ifdef HAVE_MMAP |
| 5 | |
| 6 | #ifdef _WIN32 |
| 7 | |
| 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. |
| 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. |
| 10 | #endif |
| 11 | |
| 12 | /* All the headers include this file. */ |
| 13 | #ifndef _MSC_VER |
| 14 | #include <_mingw.h> |
| 15 | #endif |
| 16 | |
| 17 | #include <sys/types.h> |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | #define PROT_NONE 0 |
| 24 | #define PROT_READ 1 |
| 25 | #define PROT_WRITE 2 |
| 26 | #define PROT_EXEC 4 |
| 27 | |
| 28 | #define MAP_FILE 0 |
| 29 | #define MAP_SHARED 1 |
| 30 | #define MAP_PRIVATE 2 |
| 31 | #define MAP_TYPE 0xf |
| 32 | #define MAP_FIXED 0x10 |
| 33 | #define MAP_ANONYMOUS 0x20 |
| 34 | #define MAP_ANON MAP_ANONYMOUS |
| 35 | |
| 36 | #define MAP_FAILED ((void *)-1) |
| 37 | |
| 38 | /* Flags for msync. */ |
| 39 | #define MS_ASYNC 1 |
| 40 | #define MS_SYNC 2 |
| 41 | #define MS_INVALIDATE 4 |
| 42 | |
| 43 | void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off); |
| 44 | int munmap(void *addr, size_t len); |
| 45 | int mprotect(void *addr, size_t len, int prot); |
| 46 | int msync(void *addr, size_t len, int flags); |
| 47 | int mlock(const void *addr, size_t len); |
| 48 | int munlock(const void *addr, size_t len); |
| 49 | |
| 50 | #ifdef __cplusplus |
| 51 | }; |
| 52 | #endif |
| 53 | |
| 54 | #else |
| 55 | #include <sys/mman.h> |
| 56 | #endif |
| 57 | |
| 58 | #endif |
| 59 | |
| 60 | #endif |