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