[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / compiler-rt / lib / profile / WindowsMMap.h
blob1df1a0be0b02bd8341e98487c55c1660d06f0867
1 /*===- WindowsMMap.h - Support library for PGO instrumentation ------------===*\
2 |*
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 |* See https://llvm.org/LICENSE.txt for license information.
5 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 |*
7 \*===----------------------------------------------------------------------===*/
9 #ifndef PROFILE_INSTRPROFILING_WINDOWS_MMAP_H
10 #define PROFILE_INSTRPROFILING_WINDOWS_MMAP_H
12 #if defined(_WIN32)
14 #include <basetsd.h>
15 #include <io.h>
16 #include <sys/types.h>
19 * mmap() flags
21 #define PROT_READ 0x1
22 #define PROT_WRITE 0x2
23 #define PROT_EXEC 0x0
25 #define MAP_FILE 0x00
26 #define MAP_SHARED 0x01
27 #define MAP_PRIVATE 0x02
28 #define MAP_ANONYMOUS 0x20
29 #define MAP_ANON MAP_ANONYMOUS
30 #define MAP_FAILED ((void *) -1)
33 * msync() flags
35 #define MS_ASYNC 0x0001 /* return immediately */
36 #define MS_INVALIDATE 0x0002 /* invalidate all cached data */
37 #define MS_SYNC 0x0010 /* msync synchronously */
40 * madvise() flags
43 #define MADV_NORMAL 0 /* no special treatment */
44 #define MADV_WILLNEED 3 /* expect access in the near future */
45 #define MADV_DONTNEED 4 /* do not expect access in the near future */
48 * flock() operations
50 #define LOCK_SH 1 /* shared lock */
51 #define LOCK_EX 2 /* exclusive lock */
52 #define LOCK_NB 4 /* don't block when locking */
53 #define LOCK_UN 8 /* unlock */
55 #ifdef __USE_FILE_OFFSET64
56 # define DWORD_HI(x) (x >> 32)
57 # define DWORD_LO(x) ((x) & 0xffffffff)
58 #else
59 # define DWORD_HI(x) (0)
60 # define DWORD_LO(x) (x)
61 #endif
63 #define mmap __llvm_profile_mmap
64 #define munmap __llvm_profile_munmap
65 #define msync __llvm_profile_msync
66 #define madvise __llvm_profile_madvise
67 #define flock __llvm_profile_flock
69 void *mmap(void *start, size_t length, int prot, int flags, int fd,
70 off_t offset);
72 void munmap(void *addr, size_t length);
74 int msync(void *addr, size_t length, int flags);
76 int madvise(void *addr, size_t length, int advice);
78 int flock(int fd, int operation);
80 #endif /* _WIN32 */
82 #endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */