state_flags.rs 758 B

12345678910111213141516171819
  1. #[derive(Copy, Clone, PartialEq, Eq)]
  2. pub struct CachedStateFlags(u32);
  3. impl CachedStateFlags {
  4. const MASK_IS_32: u32 = 1 << 0;
  5. const MASK_SS32: u32 = 1 << 1;
  6. const MASK_CPL3: u32 = 1 << 2;
  7. const MASK_FLAT_SEGS: u32 = 1 << 3;
  8. pub const EMPTY: CachedStateFlags = CachedStateFlags(0);
  9. pub fn of_u32(f: u32) -> CachedStateFlags { CachedStateFlags(f) }
  10. pub fn to_u32(&self) -> u32 { self.0 }
  11. pub fn cpl3(&self) -> bool { self.0 & CachedStateFlags::MASK_CPL3 != 0 }
  12. pub fn has_flat_segmentation(&self) -> bool { self.0 & CachedStateFlags::MASK_FLAT_SEGS != 0 }
  13. pub fn is_32(&self) -> bool { self.0 & CachedStateFlags::MASK_IS_32 != 0 }
  14. pub fn ssize_32(&self) -> bool { self.0 & CachedStateFlags::MASK_SS32 != 0 }
  15. }