Uses old Rust 2015
|0.1.5||Apr 17, 2019|
|0.1.4||Feb 18, 2019|
|0.1.3||Jan 30, 2019|
#492 in Hardware support
std::detect - Rust's standard library run-time CPU feature detection
std::detect module implements run-time feature detection in Rust's
standard library. This allows detecting whether the CPU the binary runs on
supports certain features, like SIMD instructions.
std::detect APIs are available as part of
libstd. Prefer using it via the
standard library than through this crate. Unstable features of
available on nightly Rust behind the
If you need run-time feature detection in
#[no_std] environments, Rust
library cannot help you. By design, Rust
core is platform independent, but
performing run-time feature detection requires a certain level of cooperation
from the platform.
You can then manually include
std_detect as a dependency to get similar
run-time feature detection support than the one offered by Rust's standard
library. We intend to make
std_detect more flexible and configurable in this
regard to better serve the needs of
std_detect_dlsym_getauxval(enabled by default, requires
libc): Enable to use
libc::dlsymto query whether
getauxvalis linked into the binary. When this is not the case, this feature allows other fallback methods to perform run-time feature detection. When this feature is disabled,
getauxvalis linked to the binary. If that is not the case the behavior is undefined.
std_detect_file_io(enabled by default, requires
std): Enable to perform run-time feature detection using file APIs (e.g.
/proc/cpuinfo, etc.) if other more performant methods fail. This feature requires
libstdas a dependency, preventing the crate from working on applications in which
stdis not available.
x86_64targets are supported on all platforms by querying the
cpuidinstruction directly for the features supported by the hardware and the operating system.
std_detectassumes that the binary is an user-space application. If you need raw support for querying
cpuid, consider using the
std_detectsupports these on Linux by querying ELF auxiliary vectors (using
getauxvalwhen available), and if that fails, by querying
arm64: partial support for doing run-time feature detection by directly querying
mrsis implemented for Linux >= 4.11, but not enabled by default.
arm64: run-time feature detection is implemented by directly querying
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in
std_detect by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.