xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/lib/profile/WindowsMMap.h (revision ef84fd3bd8895f4e6be1e38baf19e6dc3255bc64)
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 /* This flag is only available in WinXP+ */
25 #ifdef FILE_MAP_EXECUTE
26 #define PROT_EXEC     0x4
27 #else
28 #define PROT_EXEC        0x0
29 #define FILE_MAP_EXECUTE 0
30 #endif
31 
32 #define MAP_FILE      0x00
33 #define MAP_SHARED    0x01
34 #define MAP_PRIVATE   0x02
35 #define MAP_ANONYMOUS 0x20
36 #define MAP_ANON      MAP_ANONYMOUS
37 #define MAP_FAILED    ((void *) -1)
38 
39 /*
40  * msync() flags
41  */
42 #define MS_ASYNC        0x0001  /* return immediately */
43 #define MS_INVALIDATE   0x0002  /* invalidate all cached data */
44 #define MS_SYNC         0x0010  /* msync synchronously */
45 
46 /*
47  * flock() operations
48  */
49 #define   LOCK_SH   1    /* shared lock */
50 #define   LOCK_EX   2    /* exclusive lock */
51 #define   LOCK_NB   4    /* don't block when locking */
52 #define   LOCK_UN   8    /* unlock */
53 
54 void *mmap(void *start, size_t length, int prot, int flags, int fd,
55            off_t offset);
56 
57 void munmap(void *addr, size_t length);
58 
59 int msync(void *addr, size_t length, int flags);
60 
61 int flock(int fd, int operation);
62 
63 #endif /* _WIN32 */
64 
65 #endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */
66