]>
git.proxmox.com Git - rustc.git/blob - vendor/rustix-0.36.5/src/backend/libc/mm/types.rs
2 use bitflags
::bitflags
;
5 /// `PROT_*` flags for use with [`mmap`].
7 /// For `PROT_NONE`, use `ProtFlags::empty()`.
9 /// [`mmap`]: crate::io::mmap
10 pub struct ProtFlags
: c
::c_int
{
12 const READ
= c
::PROT_READ
;
14 const WRITE
= c
::PROT_WRITE
;
16 const EXEC
= c
::PROT_EXEC
;
21 /// `PROT_*` flags for use with [`mprotect`].
23 /// For `PROT_NONE`, use `MprotectFlags::empty()`.
25 /// [`mprotect`]: crate::io::mprotect
26 pub struct MprotectFlags
: c
::c_int
{
28 const READ
= c
::PROT_READ
;
30 const WRITE
= c
::PROT_WRITE
;
32 const EXEC
= c
::PROT_EXEC
;
34 #[cfg(any(target_os = "android", target_os = "linux"))]
35 const GROWSUP
= c
::PROT_GROWSUP
;
37 #[cfg(any(target_os = "android", target_os = "linux"))]
38 const GROWSDOWN
= c
::PROT_GROWSDOWN
;
43 /// `MAP_*` flags for use with [`mmap`].
45 /// For `MAP_ANONYMOUS` (aka `MAP_ANON`), see [`mmap_anonymous`].
47 /// [`mmap`]: crate::io::mmap
48 /// [`mmap_anonymous`]: crates::io::mmap_anonymous
49 pub struct MapFlags
: c
::c_int
{
51 const SHARED
= c
::MAP_SHARED
;
52 /// `MAP_SHARED_VALIDATE`
54 target_os
= "android",
55 target_os
= "dragonfly",
56 target_os
= "emscripten",
57 target_os
= "freebsd",
58 target_os
= "fuchsia",
60 target_os
= "illumos",
64 target_os
= "openbsd",
66 target_os
= "solaris",
68 const SHARED_VALIDATE
= c
::MAP_SHARED_VALIDATE
;
70 const PRIVATE
= c
::MAP_PRIVATE
;
73 target_os
= "dragonfly",
74 target_os
= "freebsd",
76 target_os
= "illumos",
80 target_os
= "openbsd",
82 target_os
= "solaris",
84 const DENYWRITE
= c
::MAP_DENYWRITE
;
86 const FIXED
= c
::MAP_FIXED
;
87 /// `MAP_FIXED_NOREPLACE`
89 target_os
= "android",
90 target_os
= "dragonfly",
91 target_os
= "emscripten",
92 target_os
= "freebsd",
93 target_os
= "fuchsia",
95 target_os
= "illumos",
99 target_os
= "openbsd",
101 target_os
= "solaris",
103 const FIXED_NOREPLACE
= c
::MAP_FIXED_NOREPLACE
;
106 target_os
= "dragonfly",
107 target_os
= "freebsd",
109 target_os
= "illumos",
112 target_os
= "netbsd",
113 target_os
= "openbsd",
115 target_os
= "solaris",
117 const GROWSDOWN
= c
::MAP_GROWSDOWN
;
120 target_os
= "dragonfly",
121 target_os
= "freebsd",
123 target_os
= "illumos",
126 target_os
= "netbsd",
127 target_os
= "openbsd",
129 target_os
= "solaris",
131 const HUGETLB
= c
::MAP_HUGETLB
;
134 target_os
= "android",
135 target_os
= "dragonfly",
136 target_os
= "emscripten",
137 target_os
= "freebsd",
138 target_os
= "fuchsia",
140 target_os
= "illumos",
143 target_os
= "netbsd",
144 target_os
= "openbsd",
146 target_os
= "solaris",
148 const HUGE_2MB
= c
::MAP_HUGE_2MB
;
151 target_os
= "android",
152 target_os
= "dragonfly",
153 target_os
= "emscripten",
154 target_os
= "freebsd",
155 target_os
= "fuchsia",
157 target_os
= "illumos",
160 target_os
= "netbsd",
161 target_os
= "openbsd",
163 target_os
= "solaris",
165 const HUGE_1GB
= c
::MAP_HUGE_1GB
;
168 target_os
= "dragonfly",
169 target_os
= "freebsd",
171 target_os
= "illumos",
174 target_os
= "netbsd",
175 target_os
= "openbsd",
177 target_os
= "solaris",
179 const LOCKED
= c
::MAP_LOCKED
;
181 #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
182 const NOCORE
= c
::MAP_NOCORE
;
184 #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd", target_os = "redox")))]
185 const NORESERVE
= c
::MAP_NORESERVE
;
187 #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
188 const NOSYNC
= c
::MAP_NOSYNC
;
191 target_os
= "dragonfly",
192 target_os
= "freebsd",
194 target_os
= "illumos",
197 target_os
= "netbsd",
198 target_os
= "openbsd",
200 target_os
= "solaris",
202 const POPULATE
= c
::MAP_POPULATE
;
205 target_os
= "dragonfly",
207 target_os
= "illumos",
210 target_os
= "netbsd",
212 target_os
= "solaris",
214 const STACK
= c
::MAP_STACK
;
215 /// `MAP_PREFAULT_READ`
216 #[cfg(target_os = "freebsd")]
217 const PREFAULT_READ
= c
::MAP_PREFAULT_READ
;
220 target_os
= "android",
221 target_os
= "dragonfly",
222 target_os
= "emscripten",
223 target_os
= "freebsd",
224 target_os
= "fuchsia",
226 target_os
= "illumos",
229 target_os
= "netbsd",
230 target_os
= "openbsd",
232 target_os
= "solaris",
234 any(target_os
= "android", target_os
= "linux"),
235 any(target_arch
= "mips", target_arch
= "mips64"),
238 const SYNC
= c
::MAP_SYNC
;
239 /// `MAP_UNINITIALIZED`
241 const UNINITIALIZED
= c
::MAP_UNINITIALIZED
;
245 #[cfg(target_os = "linux")]
247 /// `MREMAP_*` flags for use with [`mremap`].
249 /// For `MREMAP_FIXED`, see [`mremap_fixed`].
251 /// [`mremap`]: crate::io::mremap
252 /// [`mremap_fixed`]: crate::io::mremap_fixed
253 pub struct MremapFlags
: i32 {
255 const MAYMOVE
= c
::MREMAP_MAYMOVE
;
260 /// `MS_*` flags for use with [`msync`].
262 /// [`msync`]: crate::io::msync
263 pub struct MsyncFlags
: i32 {
264 /// `MS_SYNC`—Requests an update and waits for it to complete.
265 const SYNC
= c
::MS_SYNC
;
266 /// `MS_ASYNC`—Specifies that an update be scheduled, but the call
267 /// returns immediately.
268 const ASYNC
= c
::MS_ASYNC
;
269 /// `MS_INVALIDATE`—Asks to invalidate other mappings of the same
270 /// file (so that they can be updated with the fresh values just
272 const INVALIDATE
= c
::MS_INVALIDATE
;
276 #[cfg(any(target_os = "android", target_os = "linux"))]
278 /// `MLOCK_*` flags for use with [`mlock_with`].
280 /// [`mlock_with`]: crate::io::mlock_with
281 pub struct MlockFlags
: i32 {
283 const ONFAULT
= c
::MLOCK_ONFAULT
as _
;
287 /// `POSIX_MADV_*` constants for use with [`madvise`].
289 /// [`madvise`]: crate::mm::madvise
290 #[cfg(not(target_os = "redox"))]
291 #[derive(Debug, Copy, Clone, Eq, PartialEq)]
295 /// `POSIX_MADV_NORMAL`
296 #[cfg(not(any(target_os = "android", target_os = "haiku")))]
297 Normal
= c
::POSIX_MADV_NORMAL
,
299 /// `POSIX_MADV_NORMAL`
300 #[cfg(any(target_os = "android", target_os = "haiku"))]
301 Normal
= c
::MADV_NORMAL
,
303 /// `POSIX_MADV_SEQUENTIAL`
304 #[cfg(not(any(target_os = "android", target_os = "haiku")))]
305 Sequential
= c
::POSIX_MADV_SEQUENTIAL
,
307 /// `POSIX_MADV_SEQUENTIAL`
308 #[cfg(any(target_os = "android", target_os = "haiku"))]
309 Sequential
= c
::MADV_SEQUENTIAL
,
311 /// `POSIX_MADV_RANDOM`
312 #[cfg(not(any(target_os = "android", target_os = "haiku")))]
313 Random
= c
::POSIX_MADV_RANDOM
,
315 /// `POSIX_MADV_RANDOM`
316 #[cfg(any(target_os = "android", target_os = "haiku"))]
317 Random
= c
::MADV_RANDOM
,
319 /// `POSIX_MADV_WILLNEED`
320 #[cfg(not(any(target_os = "android", target_os = "haiku")))]
321 WillNeed
= c
::POSIX_MADV_WILLNEED
,
323 /// `POSIX_MADV_WILLNEED`
324 #[cfg(any(target_os = "android", target_os = "haiku"))]
325 WillNeed
= c
::MADV_WILLNEED
,
327 /// `POSIX_MADV_DONTNEED`
328 #[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "haiku")))]
329 DontNeed
= c
::POSIX_MADV_DONTNEED
,
331 /// `POSIX_MADV_DONTNEED`
332 #[cfg(any(target_os = "android", target_os = "haiku"))]
333 DontNeed
= i32::MAX
- 1,
336 // `MADV_DONTNEED` has the same value as `POSIX_MADV_DONTNEED`. We don't
337 // have a separate `posix_madvise` from `madvise`, so we expose a special
338 // value which we special-case.
339 #[cfg(target_os = "linux")]
340 LinuxDontNeed
= i32::MAX
,
343 #[cfg(target_os = "android")]
344 LinuxDontNeed
= c
::MADV_DONTNEED
,
346 #[cfg(any(target_os = "android", target_os = "linux"))]
347 LinuxFree
= c
::MADV_FREE
,
349 #[cfg(any(target_os = "android", target_os = "linux"))]
350 LinuxRemove
= c
::MADV_REMOVE
,
352 #[cfg(any(target_os = "android", target_os = "linux"))]
353 LinuxDontFork
= c
::MADV_DONTFORK
,
355 #[cfg(any(target_os = "android", target_os = "linux"))]
356 LinuxDoFork
= c
::MADV_DOFORK
,
358 #[cfg(any(target_os = "android", target_os = "linux"))]
359 LinuxHwPoison
= c
::MADV_HWPOISON
,
360 /// `MADV_SOFT_OFFLINE`
362 any(target_os
= "android", target_os
= "linux"),
363 not(any(target_arch
= "mips", target_arch
= "mips64")),
365 LinuxSoftOffline
= c
::MADV_SOFT_OFFLINE
,
367 #[cfg(any(target_os = "android", target_os = "linux"))]
368 LinuxMergeable
= c
::MADV_MERGEABLE
,
369 /// `MADV_UNMERGEABLE`
370 #[cfg(any(target_os = "android", target_os = "linux"))]
371 LinuxUnmergeable
= c
::MADV_UNMERGEABLE
,
372 /// `MADV_HUGEPAGE` (since Linux 2.6.38)
373 #[cfg(any(target_os = "android", target_os = "linux"))]
374 LinuxHugepage
= c
::MADV_HUGEPAGE
,
375 /// `MADV_NOHUGEPAGE` (since Linux 2.6.38)
376 #[cfg(any(target_os = "android", target_os = "linux"))]
377 LinuxNoHugepage
= c
::MADV_NOHUGEPAGE
,
378 /// `MADV_DONTDUMP` (since Linux 3.4)
379 #[cfg(any(target_os = "android", target_os = "linux"))]
380 LinuxDontDump
= c
::MADV_DONTDUMP
,
381 /// `MADV_DODUMP` (since Linux 3.4)
382 #[cfg(any(target_os = "android", target_os = "linux"))]
383 LinuxDoDump
= c
::MADV_DODUMP
,
384 /// `MADV_WIPEONFORK` (since Linux 4.14)
385 #[cfg(any(target_os = "android", target_os = "linux"))]
386 #[cfg(feature = "mm")]
387 LinuxWipeOnFork
= linux_raw_sys
::general
::MADV_WIPEONFORK
as i32,
388 /// `MADV_KEEPONFORK` (since Linux 4.14)
389 #[cfg(any(target_os = "android", target_os = "linux"))]
390 #[cfg(feature = "mm")]
391 LinuxKeepOnFork
= linux_raw_sys
::general
::MADV_KEEPONFORK
as i32,
392 /// `MADV_COLD` (since Linux 5.4)
393 #[cfg(any(target_os = "android", target_os = "linux"))]
394 #[cfg(feature = "mm")]
395 LinuxCold
= linux_raw_sys
::general
::MADV_COLD
as i32,
396 /// `MADV_PAGEOUT` (since Linux 5.4)
397 #[cfg(any(target_os = "android", target_os = "linux"))]
398 #[cfg(feature = "mm")]
399 LinuxPageOut
= linux_raw_sys
::general
::MADV_PAGEOUT
as i32,
400 /// `MADV_POPULATE_READ` (since Linux 5.14)
401 #[cfg(any(target_os = "android", target_os = "linux"))]
402 #[cfg(feature = "mm")]
403 LinuxPopulateRead
= linux_raw_sys
::general
::MADV_POPULATE_READ
as i32,
404 /// `MADV_POPULATE_WRITE` (since Linux 5.14)
405 #[cfg(any(target_os = "android", target_os = "linux"))]
406 #[cfg(feature = "mm")]
407 LinuxPopulateWrite
= linux_raw_sys
::general
::MADV_POPULATE_WRITE
as i32,
410 #[cfg(target_os = "emscripten")]
412 /// `POSIX_MADV_DONTNEED`
413 #[allow(non_upper_case_globals)]
414 pub const DontNeed
: Self = Self::Normal
;
417 #[cfg(any(target_os = "android", target_os = "linux"))]
419 /// `O_*` flags for use with [`userfaultfd`].
421 /// [`userfaultfd`]: crate::io::userfaultfd
422 pub struct UserfaultfdFlags
: c
::c_int
{
424 const CLOEXEC
= c
::O_CLOEXEC
;
426 const NONBLOCK
= c
::O_NONBLOCK
;