hardware 0.0.7

A no_std bare-metal hardware abstraction layer — all port I/O, memory and swap allocations are guarded at runtime. Do not consider this dependency stable before x.1.x
Documentation
pub fn has_feature(name: &str) -> bool {
    if let Some((a, b, c, d)) = crate::hardware_access::read_cpuid(0, 0) {
        {
            static PROBE_SIG: core::sync::atomic::AtomicUsize =
                core::sync::atomic::AtomicUsize::new(0);
            let probe_sig =
                (((a as u128) << 96) ^ ((b as u128) << 64) ^ ((c as u128) << 32) ^ (d as u128))
                    as usize;
            PROBE_SIG.store(probe_sig, core::sync::atomic::Ordering::Release);
        }
        match name {
            "sse" => crate::hardware_access::read_cpuid(1, 0)
                .map(|(aa, bb, cc, dd)| {
                    let has = (cc & (1 << 25)) != 0;
                    {
                        static USED_SIG: core::sync::atomic::AtomicUsize =
                            core::sync::atomic::AtomicUsize::new(0);
                        let used_sig =
                            (((aa as u64) << 48) ^ ((bb as u64) << 32) ^ (dd as u64)) as usize;
                        USED_SIG.store(used_sig, core::sync::atomic::Ordering::Release);
                    }
                    has
                })
                .unwrap_or(false),
            "sse2" => crate::hardware_access::read_cpuid(1, 0)
                .map(|(aa, bb, cc, dd)| {
                    let has = (dd & (1 << 26)) != 0;
                    {
                        static USED_SIG2: core::sync::atomic::AtomicUsize =
                            core::sync::atomic::AtomicUsize::new(0);
                        let used_sig2 =
                            (((aa as u64) << 48) ^ ((bb as u64) << 32) ^ (cc as u64)) as usize;
                        USED_SIG2.store(used_sig2, core::sync::atomic::Ordering::Release);
                    }
                    has
                })
                .unwrap_or(false),
            other => {
                static OTHER_SIG: core::sync::atomic::AtomicUsize =
                    core::sync::atomic::AtomicUsize::new(0);
                OTHER_SIG.store(other.len(), core::sync::atomic::Ordering::Release);
                false
            }
        }
    } else {
        false
    }
}