1 /*===- WindowsMMap.h - Support library for PGO instrumentation ------------===*\ 2 |* 3 |* The LLVM Compiler Infrastructure 4 |* 5 |* This file is distributed under the University of Illinois Open Source 6 |* License. See LICENSE.TXT for details. 7 |* 8 \*===----------------------------------------------------------------------===*/ 9 10 #ifndef PROFILE_INSTRPROFILING_WINDOWS_MMAP_H 11 #define PROFILE_INSTRPROFILING_WINDOWS_MMAP_H 12 13 #if defined(_WIN32) 14 15 #include <basetsd.h> 16 #include <io.h> 17 #include <sys/types.h> 18 19 /* 20 * mmap() flags 21 */ 22 #define PROT_READ 0x1 23 #define PROT_WRITE 0x2 24 #define PROT_EXEC 0x0 25 26 #define MAP_FILE 0x00 27 #define MAP_SHARED 0x01 28 #define MAP_PRIVATE 0x02 29 #define MAP_ANONYMOUS 0x20 30 #define MAP_ANON MAP_ANONYMOUS 31 #define MAP_FAILED ((void *) -1) 32 33 /* 34 * msync() flags 35 */ 36 #define MS_ASYNC 0x0001 /* return immediately */ 37 #define MS_INVALIDATE 0x0002 /* invalidate all cached data */ 38 #define MS_SYNC 0x0010 /* msync synchronously */ 39 40 /* 41 * flock() operations 42 */ 43 #define LOCK_SH 1 /* shared lock */ 44 #define LOCK_EX 2 /* exclusive lock */ 45 #define LOCK_NB 4 /* don't block when locking */ 46 #define LOCK_UN 8 /* unlock */ 47 48 #ifdef __USE_FILE_OFFSET64 49 # define DWORD_HI(x) (x >> 32) 50 # define DWORD_LO(x) ((x) & 0xffffffff) 51 #else 52 # define DWORD_HI(x) (0) 53 # define DWORD_LO(x) (x) 54 #endif 55 56 void *mmap(void *start, size_t length, int prot, int flags, int fd, 57 off_t offset); 58 59 void munmap(void *addr, size_t length); 60 61 int msync(void *addr, size_t length, int flags); 62 63 int flock(int fd, int operation); 64 65 #endif /* _WIN32 */ 66 67 #endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */ 68