include!("common.rs");
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
mod ffi {
sys_type!({
pub(crate) type [Win32::System::Threading] PROCESSOR_FEATURE_ID = u32;
pub(crate) type [core] BOOL = i32;
});
sys_const!({
pub(crate) const [Win32::Foundation] FALSE: BOOL = 0;
pub(crate) const [Win32::System::Threading]
PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE: PROCESSOR_FEATURE_ID = 34;
#[cfg(test)]
pub(crate) const [Win32::System::Threading]
PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE: PROCESSOR_FEATURE_ID = 45;
});
pub(crate) const PF_ARM_LSE2_AVAILABLE: PROCESSOR_FEATURE_ID = 62;
sys_fn!({
extern "system" {
pub(crate) fn [Win32::System::Threading] IsProcessorFeaturePresent(
ProcessorFeature: PROCESSOR_FEATURE_ID,
) -> BOOL;
}
});
}
#[cold]
#[must_use]
fn _detect(mut info: CpuInfo) -> CpuInfo {
macro_rules! check {
($flag:ident, $bit:ident) => {
if unsafe { ffi::IsProcessorFeaturePresent(ffi::$bit) != ffi::FALSE } {
info.set(CpuInfoFlag::$flag);
}
};
}
check!(lse, PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE);
check!(lse2, PF_ARM_LSE2_AVAILABLE);
#[cfg(test)]
check!(rcpc, PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE);
info
}