• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @defgroup mman Mman
3  * @ingroup libc
4  */
5 
6 #ifndef	_SYS_MMAN_H
7 #define	_SYS_MMAN_H
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <features.h>
13 
14 #define __NEED_mode_t
15 #define __NEED_size_t
16 #define __NEED_off_t
17 
18 #if defined(_GNU_SOURCE)
19 #define __NEED_ssize_t
20 #endif
21 #ifdef __LITEOS__
22 #define __NEED_int64_t
23 #endif
24 
25 #include <bits/alltypes.h>
26 
27 #define MAP_FAILED ((void *) -1)
28 
29 #define MAP_SHARED     0x01
30 #define MAP_PRIVATE    0x02
31 #define MAP_SHARED_VALIDATE 0x03
32 #define MAP_TYPE       0x0f
33 #define MAP_FIXED      0x10
34 #define MAP_ANON       0x20
35 #define MAP_ANONYMOUS  MAP_ANON
36 #define MAP_NORESERVE  0x4000
37 #define MAP_GROWSDOWN  0x0100
38 #define MAP_DENYWRITE  0x0800
39 #define MAP_EXECUTABLE 0x1000
40 #define MAP_LOCKED     0x2000
41 #define MAP_POPULATE   0x8000
42 #define MAP_NONBLOCK   0x10000
43 #define MAP_STACK      0x20000
44 #define MAP_HUGETLB    0x40000
45 #define MAP_SYNC       0x80000
46 #define MAP_FIXED_NOREPLACE 0x100000
47 #define MAP_FILE       0
48 
49 #define MAP_HUGE_SHIFT 26
50 #define MAP_HUGE_MASK  0x3f
51 #define MAP_HUGE_64KB  (16 << 26)
52 #define MAP_HUGE_512KB (19 << 26)
53 #define MAP_HUGE_1MB   (20 << 26)
54 #define MAP_HUGE_2MB   (21 << 26)
55 #define MAP_HUGE_8MB   (23 << 26)
56 #define MAP_HUGE_16MB  (24 << 26)
57 #define MAP_HUGE_32MB  (25 << 26)
58 #define MAP_HUGE_256MB (28 << 26)
59 #define MAP_HUGE_512MB (29 << 26)
60 #define MAP_HUGE_1GB   (30 << 26)
61 #define MAP_HUGE_2GB   (31 << 26)
62 #define MAP_HUGE_16GB  (34U << 26)
63 
64 #define PROT_NONE      0
65 #define PROT_READ      1
66 #define PROT_WRITE     2
67 #define PROT_EXEC      4
68 #define PROT_GROWSDOWN 0x01000000
69 #define PROT_GROWSUP   0x02000000
70 
71 #define MS_ASYNC       1
72 #define MS_INVALIDATE  2
73 #define MS_SYNC        4
74 
75 #define MCL_CURRENT    1
76 #define MCL_FUTURE     2
77 #define MCL_ONFAULT    4
78 
79 #define POSIX_MADV_NORMAL     0
80 #define POSIX_MADV_RANDOM     1
81 #define POSIX_MADV_SEQUENTIAL 2
82 #define POSIX_MADV_WILLNEED   3
83 #define POSIX_MADV_DONTNEED   4
84 
85 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
86 #define MADV_NORMAL      0
87 #define MADV_RANDOM      1
88 #define MADV_SEQUENTIAL  2
89 #define MADV_WILLNEED    3
90 #define MADV_DONTNEED    4
91 #define MADV_FREE        8
92 #define MADV_REMOVE      9
93 #define MADV_DONTFORK    10
94 #define MADV_DOFORK      11
95 #define MADV_MERGEABLE   12
96 #define MADV_UNMERGEABLE 13
97 #define MADV_HUGEPAGE    14
98 #define MADV_NOHUGEPAGE  15
99 #define MADV_DONTDUMP    16
100 #define MADV_DODUMP      17
101 #define MADV_WIPEONFORK  18
102 #define MADV_KEEPONFORK  19
103 #define MADV_COLD        20
104 #define MADV_PAGEOUT     21
105 #define MADV_HWPOISON    100
106 #define MADV_SOFT_OFFLINE 101
107 #endif
108 
109 #ifdef _GNU_SOURCE
110 #define MREMAP_MAYMOVE 1
111 #define MREMAP_FIXED 2
112 
113 #define MLOCK_ONFAULT 0x01
114 
115 #define MFD_CLOEXEC 0x0001U
116 #define MFD_ALLOW_SEALING 0x0002U
117 #define MFD_HUGETLB 0x0004U
118 #endif
119 
120 #include <bits/mman.h>
121 
122 /**
123  * @ingroup  mman
124  *
125  * @par Description:
126  * This function shall establish a mapping between an address space and a memory object.
127  *
128  * @attention
129  * <ul>
130  * <li>This API just returns the pointer to the offset parameter on LiteOS.</li>
131  * <li>The macro __USE_FILE_OFFSET64 should have been defined for this api.</li>
132  * </ul>
133  *
134  * @retval  #void*  pointer to the offset parameter is returned.
135  *
136  * @par Dependency:
137  * <ul><li>mman.h</li></ul>
138  *
139  * @see  None
140  *
141  */
142 void *mmap (void *, size_t, int, int, int, off_t);
143 int munmap (void *, size_t);
144 
145 int mprotect (void *, size_t, int);
146 int msync (void *, size_t, int);
147 
148 int posix_madvise (void *, size_t, int);
149 
150 int mlock (const void *, size_t);
151 int munlock (const void *, size_t);
152 int mlockall (int);
153 int munlockall (void);
154 
155 #ifdef _GNU_SOURCE
156 void *mremap (void *, size_t, size_t, int, ...);
157 int remap_file_pages (void *, size_t, int, size_t, int);
158 int memfd_create (const char *, unsigned);
159 int mlock2 (const void *, size_t, unsigned);
160 #endif
161 
162 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
163 int madvise (void *, size_t, int);
164 int mincore (void *, size_t, unsigned char *);
165 #endif
166 
167 int shm_open (const char *, int, mode_t);
168 int shm_unlink (const char *);
169 
170 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
171 #define mmap64 mmap
172 #ifdef __LITEOS__
173 #define off64_t int64_t
174 #else
175 #define off64_t off_t
176 #endif
177 #endif
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 #endif
183