userspace/target/operating_system/linux/syscall/mmap/
flags.rs

1#[rustfmt::skip]
2ample::enum_flag!(
3    usize;
4    "Map Flags";
5    pub enum Flag {
6        [0x01;      Shared;         SHARED;          "Shared";         "Shared"],
7        [0x02;      Private;        PRIVATE;         "Private";        "Private"],
8        [0x03;      SharedValidate; SHAREDVALIDATE;  "SharedValidate"; "SharedValidate"],
9        [0x10;      Fixed;          FIXED;           "Fixed";          "Fixed"],
10        [0x20;      Anonymous;      ANONYMOUS;       "Anonymous";      "Anonymous"],
11        [0x0100;    GrowsDown;      GROWSDOWN;       "GrowsDown";      "GrowsDown"],
12        [0x0800;    DenyWrite;      DENYWRITE;       "DenyWrite";      "DenyWrite"],
13        [0x1000;    Executable;     EXECUTABLE;      "Executable";     "Executable"],
14        [0x2000;    Locked;         LOCKED;          "Locked";         "Locked"],
15        [0x4000;    NoReserve;      NORESERVE;       "NoReserve";      "NoReserve"],
16        [0x8000;    Populate;       POPULATE;        "Populate";       "Populate"],
17        [0x10000;   NonBlock;       NONBLOCK;        "NonBlock";       "NonBlock"],
18        [0x20000;   Stack;          STACK;           "Stack";          "Stack"],
19        [0x40000;   HugeTlb;        HUGETLB;         "HugeTlb";        "HugeTlb"],
20        [0x80000;   Sync;           SYNC;            "Sync";           "Sync"],
21        [0x100000;  FixedNoReplace; FIXEDNOREPLACE;  "FixedNoReplace"; "FixedNoReplace"]
22    }
23);
24
25// #[repr(i32)]
26// #[derive(Clone, Copy)]
27// pub enum Flag {
28//     Shared = 0x01,
29//     Private = 0x02,
30//     SharedValidate = 0x03,
31//     Fixed = 0x10,
32//     Anonymous = 0x20,
33//     GrowsDown = 0x0100,
34//     DenyWrite = 0x0800,
35//     Executable = 0x1000,
36//     Locked = 0x2000,
37//     NoReserve = 0x4000,
38//     Populate = 0x8000,
39//     NonBlock = 0x10000,
40//     Stack = 0x20000,
41//     HugeTlb = 0x40000,
42//     Sync = 0x80000,
43//     FixedNoReplace = 0x100000,
44// }
45
46// impl Flag {
47//     pub fn to(self) -> i32 {
48//         self as i32
49//     }
50// }
51
52// impl core::ops::BitOr for Flag {
53//     type Output = i32;
54
55//     fn bitor(self, rhs: Self) -> Self::Output {
56//         self.to() | rhs.to()
57//     }
58// }
59
60// impl core::ops::BitOr<i32> for Flag {
61//     type Output = i32;
62
63//     fn bitor(self, rhs: i32) -> Self::Output {
64//         self.to() | rhs
65//     }
66// }
67
68// #[repr(i32)]
69// #[derive(Clone, Copy)]
70// pub enum Prot {
71//     None = 0,
72//     Read = 1,
73//     Write = 2,
74//     Exec = 4,
75// }
76
77// impl Prot {
78//     pub fn to(self) -> i32 {
79//         self as i32
80//     }
81// }
82
83// impl core::ops::BitOr for Prot {
84//     type Output = i32;
85
86//     fn bitor(self, rhs: Self) -> Self::Output {
87//         self.to() | rhs.to()
88//     }
89// }
90
91// impl core::ops::BitOr<i32> for Prot {
92//     type Output = i32;
93
94//     fn bitor(self, rhs: i32) -> Self::Output {
95//         self.to() | rhs
96//     }
97// }