1 use crate::backend::c;
2 use bitflags::bitflags;
3 
4 bitflags! {
5     /// `FD_*` constants for use with [`fcntl_getfd`] and [`fcntl_setfd`].
6     ///
7     /// [`fcntl_getfd`]: crate::io::fcntl_getfd
8     /// [`fcntl_setfd`]: crate::io::fcntl_setfd
9     #[repr(transparent)]
10     #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
11     pub struct FdFlags: u32 {
12         /// `FD_CLOEXEC`
13         const CLOEXEC = bitcast!(c::FD_CLOEXEC);
14 
15         /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
16         const _ = !0;
17     }
18 }
19 
20 #[cfg(feature = "linux-raw-sys")]
21 bitflags! {
22     /// `RWF_*` constants for use with [`preadv2`] and [`pwritev2`].
23     ///
24     /// [`preadv2`]: crate::io::preadv2
25     /// [`pwritev2`]: crate::io::pwritev
26     #[repr(transparent)]
27     #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
28     pub struct ReadWriteFlags: u32 {
29         /// `RWF_DSYNC` (since Linux 4.7)
30         const DSYNC = linux_raw_sys::general::RWF_DSYNC;
31         /// `RWF_HIPRI` (since Linux 4.6)
32         const HIPRI = linux_raw_sys::general::RWF_HIPRI;
33         /// `RWF_SYNC` (since Linux 4.7)
34         const SYNC = linux_raw_sys::general::RWF_SYNC;
35         /// `RWF_NOWAIT` (since Linux 4.14)
36         const NOWAIT = linux_raw_sys::general::RWF_NOWAIT;
37         /// `RWF_APPEND` (since Linux 4.16)
38         const APPEND = linux_raw_sys::general::RWF_APPEND;
39 
40         /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
41         const _ = !0;
42     }
43 }
44 
45 #[cfg(not(target_os = "wasi"))]
46 bitflags! {
47     /// `O_*` constants for use with [`dup2`].
48     ///
49     /// [`dup2`]: crate::io::dup2
50     #[repr(transparent)]
51     #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
52     pub struct DupFlags: u32 {
53         /// `O_CLOEXEC`
54         #[cfg(not(any(
55             apple,
56             target_os = "aix",
57             target_os = "android",
58             target_os = "redox",
59         )))] // Android 5.0 has dup3, but libc doesn't have bindings
60         const CLOEXEC = bitcast!(c::O_CLOEXEC);
61 
62         /// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
63         const _ = !0;
64     }
65 }
66