1 #pragma once 2 /* 3 * sys/mman.h 4 * mman-win32 5 * 6 * Based on https://github.com/witwall/mman-win32 7 */ 8 #ifndef _SYS_MMAN_H_ 9 #define _SYS_MMAN_H_ 10 11 #include "basedefs.h" 12 13 #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 14 #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 15 #endif 16 17 /* All the headers include this file. */ 18 #ifndef _MSC_VER 19 #include <_mingw.h> 20 #endif 21 22 #if defined(MMAN_LIBRARY) 23 #define MMANSHARED_EXPORT __declspec(dllexport) 24 #else 25 #define MMANSHARED_EXPORT __declspec(dllimport) 26 #endif 27 28 /* Determine offset type */ 29 #include <stdint.h> 30 #if defined(_WIN64) 31 typedef int64_t OffsetType; 32 #else 33 typedef uint32_t OffsetType; 34 #endif 35 36 #include <sys/types.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define PROT_NONE 0 43 #define PROT_READ 1 44 #define PROT_WRITE 2 45 #define PROT_EXEC 4 46 47 #define MAP_FILE 0 48 #define MAP_SHARED 1 49 #define MAP_PRIVATE 2 50 #define MAP_TYPE 0xf 51 #define MAP_FIXED 0x10 52 #define MAP_ANONYMOUS 0x20 53 #define MAP_ANON MAP_ANONYMOUS 54 55 #define MAP_FAILED ((void *)-1) 56 57 /* Flags for msync. */ 58 #define MS_ASYNC 1 59 #define MS_SYNC 2 60 #define MS_INVALIDATE 4 61 62 void *mmap(void *addr, size_t len, int prot, int flags, HANDLE fh, OffsetType off); 63 int munmap(void *addr, size_t len); 64 int msync(void *addr, size_t len, int flags); 65 int mlock(const void *addr, size_t len); 66 int munlock(const void *addr, size_t len); 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif /* _SYS_MMAN_H_ */ 73