1use core::ops::{BitAnd, BitOr};
2
3#[repr(C)]
5pub struct RawMemMapConfig {
6 pub addr_hint: *const (),
8 pub page_count: usize,
10 pub guard_pages_count: usize,
12 pub resource_to_map: usize,
14 pub resource_off: isize,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
20#[repr(transparent)]
21pub struct MemMapFlags(u8);
22
23impl MemMapFlags {
24 pub const FIXED: Self = Self(1 << 0);
26 pub const WRITE: Self = Self(1 << 1);
28 pub const DISABLE_EXEC: Self = Self(1 << 2);
30 pub const MAP_RESOURCE: Self = Self(1 << 3);
32}
33
34impl MemMapFlags {
35 pub fn from_bits_retaining(bits: u8) -> Self {
36 Self(bits)
37 }
38
39 pub fn contains(self, other: MemMapFlags) -> bool {
40 (self & other) == other
41 }
42}
43
44impl BitOr for MemMapFlags {
45 type Output = Self;
46 fn bitor(self, rhs: Self) -> Self::Output {
47 Self(self.0 | rhs.0)
48 }
49}
50
51impl BitAnd for MemMapFlags {
52 type Output = Self;
53 fn bitand(self, rhs: Self) -> Self::Output {
54 Self(self.0 & rhs.0)
55 }
56}
57
58#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
60#[repr(transparent)]
61pub struct ShmFlags(u32);
62
63impl ShmFlags {
64 pub const LOCAL: Self = Self(1 << 0);
66}
67
68impl ShmFlags {
69 pub const fn from_bits_retaining(bits: u32) -> Self {
70 Self(bits)
71 }
72
73 pub const fn contains(self, other: Self) -> bool {
74 (self.0 & other.0) == other.0
75 }
76}
77
78impl BitOr for ShmFlags {
79 type Output = Self;
80 fn bitor(self, rhs: Self) -> Self::Output {
81 Self(self.0 | rhs.0)
82 }
83}
84
85impl BitAnd for ShmFlags {
86 type Output = Self;
87 fn bitand(self, rhs: Self) -> Self::Output {
88 Self(self.0 & rhs.0)
89 }
90}