1 //===-- Definition of macros from sys/mman.h ------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef __LLVM_LIBC_MACROS_LINUX_SYS_MMAN_MACROS_H
10 #define __LLVM_LIBC_MACROS_LINUX_SYS_MMAN_MACROS_H
12 // Memory protection flags. (mmap, munmap, mprotect)
15 #define PROT_WRITE 0x2
17 // These protection flags are only valid for mprotect.
18 #define PROT_GROWSUP 0x1000000
19 #define PROT_GROWSDOWN 0x2000000
21 // Memory mapping flags. (mmap, munmap)
22 #define MAP_FAILED ((void *)-1)
23 // These are the sharing types, and exactly one of these must be set.
24 #define MAP_FILE 0x0 // Compatibility flag. Ignored.
25 #define MAP_SHARED 0x1
26 #define MAP_PRIVATE 0x2
27 #define MAP_SHARED_VALIDATE 0x3
28 // 0x4-0xf are unused.
29 // These are the other flags, and zero or more of these can be set.
30 #define MAP_FIXED 0x10
31 #define MAP_ANONYMOUS 0x20
32 #define MAP_ANON MAP_ANONYMOUS
33 #define MAP_32BIT 0x40
35 #define MAP_GROWSDOWN 0x100
36 #define MAP_DENYWRITE 0x800
37 #define MAP_EXECUTABLE 0x1000 // Compatibility flag. Ignored.
38 #define MAP_LOCKED 0x2000
39 #define MAP_NORESERVE 0x4000
40 #define MAP_POPULATE 0x8000
41 #define MAP_NONBLOCK 0x10000
42 #define MAP_STACK 0x20000
43 #define MAP_HUGETLB 0x40000
44 #define MAP_SYNC 0x80000
45 #define MAP_FIXED_NOREPLACE 0x100000
46 // HUGETLB support macros. If ma_HUGHTLB is set, the bits under MAP_HUGE_MASK
47 // represent the base-2 logarithm of the desired page size, and MAP_HUGE_2MB/1GB
49 #define MAP_HUGE_SHIFT 26
50 #define MAP_HUGE_MASK 0x3f
51 #define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT)
52 #define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT)
54 // Memory sync flags. (msync)
56 #define MS_INVALIDATE 2
59 // Memory advice flags. (madvise)
62 #define MADV_SEQUENTIAL 2
63 #define MADV_WILLNEED 3
64 #define MADV_DONTNEED 4
67 #define MADV_DONTFORK 10
68 #define MADV_DOFORK 11
69 #define MADV_MERGEABLE 12
70 #define MADV_UNMERGEABLE 13
71 #define MADV_HUGEPAGE 14
72 #define MADV_NOHUGEPAGE 15
73 #define MADV_DONTDUMP 16
74 #define MADV_DODUMP 17
75 #define MADV_WIPEONFORK 18
76 #define MADV_KEEPONFORK 19
78 #define MADV_PAGEOUT 21
79 #define MADV_HWPOISON 100
81 // Posix memory advise flags. (posix_madvise)
82 #define POSIX_MADV_NORMAL MADV_NORMAL
83 #define POSIX_MADV_SEQUENTIAL MADV_SEQUENTIAL
84 #define POSIX_MADV_RANDOM MADV_RANDOM
85 #define POSIX_MADV_WILLNEED MADV_WILLNEED
86 #define POSIX_MADV_DONTNEED MADV_DONTNEED
88 #endif // __LLVM_LIBC_MACROS_LINUX_SYS_MMAN_MACROS_H