Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/compiler-rt/lib/profile/WindowsMMap.h
35233 views
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
\*===----------------------------------------------------------------------===*/
8
9
#ifndef PROFILE_INSTRPROFILING_WINDOWS_MMAP_H
10
#define PROFILE_INSTRPROFILING_WINDOWS_MMAP_H
11
12
#if defined(_WIN32)
13
14
#include <basetsd.h>
15
#include <io.h>
16
#include <sys/types.h>
17
18
/*
19
* mmap() flags
20
*/
21
#define PROT_READ 0x1
22
#define PROT_WRITE 0x2
23
#define PROT_EXEC 0x0
24
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)
31
32
/*
33
* msync() flags
34
*/
35
#define MS_ASYNC 0x0001 /* return immediately */
36
#define MS_INVALIDATE 0x0002 /* invalidate all cached data */
37
#define MS_SYNC 0x0010 /* msync synchronously */
38
39
/*
40
* madvise() flags
41
*/
42
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 */
46
47
/*
48
* flock() operations
49
*/
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 */
54
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
62
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
68
69
void *mmap(void *start, size_t length, int prot, int flags, int fd,
70
off_t offset);
71
72
void munmap(void *addr, size_t length);
73
74
int msync(void *addr, size_t length, int flags);
75
76
int madvise(void *addr, size_t length, int advice);
77
78
int flock(int fd, int operation);
79
80
#endif /* _WIN32 */
81
82
#endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */
83
84