Factor out a MemFlags constructor for trusted notrap/aligned accesses.

This commit is contained in:
Dan Gohman
2018-12-11 05:44:26 -08:00
parent 68a13646f9
commit a55c933f19
5 changed files with 14 additions and 15 deletions

View File

@@ -26,6 +26,15 @@ impl MemFlags {
Self { bits: 0 }
}
/// Create a set of flags representing an access from a "trusted" address, meaning it's
/// known to be aligned and non-trapping.
pub fn trusted() -> Self {
let mut result = Self::new();
result.set_notrap();
result.set_aligned();
result
}
/// Read a flag bit.
fn read(self, bit: FlagBit) -> bool {
self.bits & (1 << bit as usize) != 0