//! x86/x86-64 CPU feature detection support. //! //! Portable, `no_std`-friendly implementation that relies on the x86 `CPUID` //! instruction for feature detection.
/// Evaluate the given `$body` expression any of the supplied target features /// are not enabled. Otherwise returns true. /// /// The `$body` expression is not evaluated on SGX targets, and returns false /// on these targets unless *all* supplied target features are enabled. #[macro_export] #[doc(hidden)]
macro_rules! __unless_target_features {
($($tf:tt),+ => $body:expr ) => {{ #[cfg(not(all($(target_feature=$tf,)*)))]
{ #[cfg(not(any(target_env = "sgx", target_os = "", target_os = "uefi")))]
$body
// CPUID is not available on SGX. Freestanding and UEFI targets // do not support SIMD features with default compilation flags. #[cfg(any(target_env = "sgx", target_os = "", target_os = "uefi"))] false
}
#[cfg(all($(target_feature=$tf,)*))] true
}};
}
/// Use CPUID to detect the presence of all supplied target features. #[macro_export] #[doc(hidden)]
macro_rules! __detect_target_features {
($($tf:tt),+) => {{ #[cfg(target_arch = "x86")] use core::arch::x86::{__cpuid, __cpuid_count, CpuidResult}; #[cfg(target_arch = "x86_64")] use core::arch::x86_64::{__cpuid, __cpuid_count, CpuidResult};
// These wrappers are workarounds around // https://github.com/rust-lang/rust/issues/101346 // // DO NOT remove it until MSRV is bumped to a version // with the issue fix (at least 1.64). #[inline(never)] unsafefn cpuid(leaf: u32) -> CpuidResult {
__cpuid(leaf)
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.