#[repr(usize)]
pub enum AlignmentBitMask
{
_512_bit = (1 << 6) - 1,
_256_bit = (1 << 5) - 1,
_128_bit = (1 << 4) - 1,
}
impl AlignmentBitMask
{
#[inline(always)]
pub fn is_aligned(self, pointer: usize) -> bool
{
pointer & (self as usize) == 0
}
#[inline(always)]
pub fn is_unaligned(self, pointer: usize) -> bool
{
pointer & (self as usize) != 0
}
#[inline(always)]
pub fn preferred_alignment() -> Self
{
use self::AlignmentBitMask::*;
if cfg!(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "avx512f"))
{
_512_bit
}
else if cfg!(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "avx"))
{
_256_bit
}
else
{
_128_bit
}
}
}