WindowsMMap.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef PROFILE_INSTRPROFILING_WINDOWS_MMAP_H
  9. #define PROFILE_INSTRPROFILING_WINDOWS_MMAP_H
  10. #if defined(_WIN32)
  11. #include <basetsd.h>
  12. #include <io.h>
  13. #include <sys/types.h>
  14. /*
  15. * mmap() flags
  16. */
  17. #define PROT_READ 0x1
  18. #define PROT_WRITE 0x2
  19. #define PROT_EXEC 0x0
  20. #define MAP_FILE 0x00
  21. #define MAP_SHARED 0x01
  22. #define MAP_PRIVATE 0x02
  23. #define MAP_ANONYMOUS 0x20
  24. #define MAP_ANON MAP_ANONYMOUS
  25. #define MAP_FAILED ((void *) -1)
  26. /*
  27. * msync() flags
  28. */
  29. #define MS_ASYNC 0x0001 /* return immediately */
  30. #define MS_INVALIDATE 0x0002 /* invalidate all cached data */
  31. #define MS_SYNC 0x0010 /* msync synchronously */
  32. /*
  33. * madvise() flags
  34. */
  35. #define MADV_NORMAL 0 /* no special treatment */
  36. #define MADV_WILLNEED 3 /* expect access in the near future */
  37. #define MADV_DONTNEED 4 /* do not expect access in the near future */
  38. /*
  39. * flock() operations
  40. */
  41. #define LOCK_SH 1 /* shared lock */
  42. #define LOCK_EX 2 /* exclusive lock */
  43. #define LOCK_NB 4 /* don't block when locking */
  44. #define LOCK_UN 8 /* unlock */
  45. #ifdef __USE_FILE_OFFSET64
  46. # define DWORD_HI(x) (x >> 32)
  47. # define DWORD_LO(x) ((x) & 0xffffffff)
  48. #else
  49. # define DWORD_HI(x) (0)
  50. # define DWORD_LO(x) (x)
  51. #endif
  52. void *mmap(void *start, size_t length, int prot, int flags, int fd,
  53. off_t offset);
  54. void munmap(void *addr, size_t length);
  55. int msync(void *addr, size_t length, int flags);
  56. int madvise(void *addr, size_t length, int advice);
  57. int flock(int fd, int operation);
  58. #endif /* _WIN32 */
  59. #endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */