1
0

mman.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #ifndef _SYS_MMAN_H
  2. #define _SYS_MMAN_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #define __NEED_mode_t
  8. #define __NEED_size_t
  9. #define __NEED_off_t
  10. #if defined(_GNU_SOURCE)
  11. #define __NEED_ssize_t
  12. #endif
  13. #include <bits/alltypes.h>
  14. #define MAP_FAILED ((void *) -1)
  15. #define MAP_SHARED 0x01
  16. #define MAP_PRIVATE 0x02
  17. #define MAP_SHARED_VALIDATE 0x03
  18. #define MAP_TYPE 0x0f
  19. #define MAP_FIXED 0x10
  20. #define MAP_ANON 0x20
  21. #define MAP_ANONYMOUS MAP_ANON
  22. #define MAP_NORESERVE 0x4000
  23. #define MAP_GROWSDOWN 0x0100
  24. #define MAP_DENYWRITE 0x0800
  25. #define MAP_EXECUTABLE 0x1000
  26. #define MAP_LOCKED 0x2000
  27. #define MAP_POPULATE 0x8000
  28. #define MAP_NONBLOCK 0x10000
  29. #define MAP_STACK 0x20000
  30. #define MAP_HUGETLB 0x40000
  31. #define MAP_SYNC 0x80000
  32. #define MAP_FIXED_NOREPLACE 0x100000
  33. #define MAP_FILE 0
  34. #define MAP_HUGE_SHIFT 26
  35. #define MAP_HUGE_MASK 0x3f
  36. #define MAP_HUGE_16KB (14 << 26)
  37. #define MAP_HUGE_64KB (16 << 26)
  38. #define MAP_HUGE_512KB (19 << 26)
  39. #define MAP_HUGE_1MB (20 << 26)
  40. #define MAP_HUGE_2MB (21 << 26)
  41. #define MAP_HUGE_8MB (23 << 26)
  42. #define MAP_HUGE_16MB (24 << 26)
  43. #define MAP_HUGE_32MB (25 << 26)
  44. #define MAP_HUGE_256MB (28 << 26)
  45. #define MAP_HUGE_512MB (29 << 26)
  46. #define MAP_HUGE_1GB (30 << 26)
  47. #define MAP_HUGE_2GB (31 << 26)
  48. #define MAP_HUGE_16GB (34U << 26)
  49. #define PROT_NONE 0
  50. #define PROT_READ 1
  51. #define PROT_WRITE 2
  52. #define PROT_EXEC 4
  53. #define PROT_GROWSDOWN 0x01000000
  54. #define PROT_GROWSUP 0x02000000
  55. #define MS_ASYNC 1
  56. #define MS_INVALIDATE 2
  57. #define MS_SYNC 4
  58. #define MCL_CURRENT 1
  59. #define MCL_FUTURE 2
  60. #define MCL_ONFAULT 4
  61. #define POSIX_MADV_NORMAL 0
  62. #define POSIX_MADV_RANDOM 1
  63. #define POSIX_MADV_SEQUENTIAL 2
  64. #define POSIX_MADV_WILLNEED 3
  65. #define POSIX_MADV_DONTNEED 4
  66. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  67. #define MADV_NORMAL 0
  68. #define MADV_RANDOM 1
  69. #define MADV_SEQUENTIAL 2
  70. #define MADV_WILLNEED 3
  71. #define MADV_DONTNEED 4
  72. #define MADV_FREE 8
  73. #define MADV_REMOVE 9
  74. #define MADV_DONTFORK 10
  75. #define MADV_DOFORK 11
  76. #define MADV_MERGEABLE 12
  77. #define MADV_UNMERGEABLE 13
  78. #define MADV_HUGEPAGE 14
  79. #define MADV_NOHUGEPAGE 15
  80. #define MADV_DONTDUMP 16
  81. #define MADV_DODUMP 17
  82. #define MADV_WIPEONFORK 18
  83. #define MADV_KEEPONFORK 19
  84. #define MADV_COLD 20
  85. #define MADV_PAGEOUT 21
  86. #define MADV_HWPOISON 100
  87. #define MADV_SOFT_OFFLINE 101
  88. #endif
  89. #ifdef _GNU_SOURCE
  90. #define MREMAP_MAYMOVE 1
  91. #define MREMAP_FIXED 2
  92. #define MREMAP_DONTUNMAP 4
  93. #define MLOCK_ONFAULT 0x01
  94. #define MFD_CLOEXEC 0x0001U
  95. #define MFD_ALLOW_SEALING 0x0002U
  96. #define MFD_HUGETLB 0x0004U
  97. #endif
  98. #include <bits/mman.h>
  99. void *mmap (void *, size_t, int, int, int, off_t);
  100. int munmap (void *, size_t);
  101. int mprotect (void *, size_t, int);
  102. int msync (void *, size_t, int);
  103. int posix_madvise (void *, size_t, int);
  104. int mlock (const void *, size_t);
  105. int munlock (const void *, size_t);
  106. int mlockall (int);
  107. int munlockall (void);
  108. #ifdef _GNU_SOURCE
  109. void *mremap (void *, size_t, size_t, int, ...);
  110. int remap_file_pages (void *, size_t, int, size_t, int);
  111. int memfd_create (const char *, unsigned);
  112. int mlock2 (const void *, size_t, unsigned);
  113. #endif
  114. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  115. int madvise (void *, size_t, int);
  116. int mincore (void *, size_t, unsigned char *);
  117. #endif
  118. int shm_open (const char *, int, mode_t);
  119. int shm_unlink (const char *);
  120. #if defined(_LARGEFILE64_SOURCE)
  121. #define mmap64 mmap
  122. #define off64_t off_t
  123. #endif
  124. #ifdef __cplusplus
  125. }
  126. #endif
  127. #endif