#[cfg(feature = "small-gen")]
use core::sync::atomic::AtomicU32;
#[cfg(feature = "small-gen")]
pub type AtomicType = AtomicU32;
#[cfg(feature = "small-gen")]
pub type NumericType = u32;
#[cfg(not(feature = "small-gen"))]
use core::sync::atomic::AtomicU64;
#[cfg(not(feature = "small-gen"))]
pub type AtomicType = AtomicU64;
#[cfg(not(feature = "small-gen"))]
pub type NumericType = u64;
pub const MSB: NumericType = NumericType::MAX - (NumericType::MAX >> 1);
#[inline]
pub fn gen_dist_msb_masked(a: NumericType, b: NumericType) -> NumericType {
a.wrapping_sub(b) & !MSB
}
#[inline]
pub fn gen_gte_msb_masked(a: NumericType, b: NumericType) -> bool {
a.wrapping_sub(b) & !MSB <= (NumericType::MAX / 4)
}
#[inline]
pub fn gen_add_msb_masked(a: NumericType, b: NumericType) -> NumericType {
a.wrapping_add(b) & !MSB
}
#[inline]
pub fn gen_lte_msb_masked(a: NumericType, b: NumericType) -> bool {
gen_gte_msb_masked(b, a)
}
#[inline]
pub fn gen_gt_msb_masked(a: NumericType, b: NumericType) -> bool {
a != b && gen_gte_msb_masked(a, b)
}
#[inline]
pub fn gen_lt_msb_masked(a: NumericType, b: NumericType) -> bool {
gen_gt_msb_masked(b, a)
}