use super::*;
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[must_use]
pub struct Addr(pub usize);
impl IsEnabled for Addr {}
impl fmt::Debug for Addr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:012x?}", self.0)
}
}
impl Addr {
pub const NULL: Addr = Addr(0);
#[inline(always)]
pub fn val<'a>(&self) -> &'a AtomicU64 {
unsafe { &*(self.0 as *const _) }
}
#[inline(always)]
pub fn def<'a>(&self) -> &'a Def {
unsafe { &*(self.0 as *const _) }
}
const HALF_MASK: usize = 0b1000;
#[inline(always)]
pub(super) fn left_half(&self) -> Self {
Addr(self.0 & !Addr::HALF_MASK)
}
#[inline(always)]
pub fn other_half(&self) -> Self {
Addr(self.0 ^ Addr::HALF_MASK)
}
}