#![allow(dead_code)]
pub use self::imp::*;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod imp {
#[inline]
fn cpuid(ain : u32, cin : u32) -> (u32, u32, u32, u32) {
let (mut a, mut b, mut c, mut d);
unsafe {
asm!("cpuid"
:"={eax}"(a), "={ebx}"(b), "={ecx}"(c), "={edx}"(d)
:"{eax}"(ain), "{ecx}"(cin)
);
}
(a, b, c, d)
}
#[inline]
pub fn is_intel() -> bool {
let (_, b, c, d) = cpuid(0, 0);
return b == 0x756E6547 && d == 0x49656e69 && c == 0x6C65746E;
}
#[inline]
pub fn has_rdrand() -> bool {
const FLAG : u32 = 1 << 30;
let (_, _, c, _) = cpuid(1, 0);
return c & FLAG == FLAG;
}
#[inline]
pub fn has_rdseed() -> bool {
const FLAG : u32 = 1 << 18;
let (_, b, _, _) = cpuid(7, 0);
return b & FLAG == FLAG;
}
}
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
mod imp {
#[inline]
pub fn is_intel() -> bool {
false
}
#[inline]
pub fn has_rdrand() -> bool {
false
}
#[inline]
pub fn has_rdseed() -> bool {
false
}
}