Crates.io | raw-cpuid |
lib.rs | raw-cpuid |
version | |
source | src |
created_at | 2015-03-24 19:38:22.01072+00 |
updated_at | 2025-03-04 19:48:51.996701+00 |
description | A library to parse the x86 CPUID instruction, written in rust with no external dependencies. The implementation closely resembles the Intel CPUID manual description. The library does only depend on libcore. |
homepage | https://github.com/gz/rust-cpuid |
repository | https://github.com/gz/rust-cpuid |
max_upload_size | |
id | 1713 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A library to parse the x86 CPUID instruction, written in rust with no external
dependencies. The implementation closely resembles the Intel CPUID manual
description. The library works in no_std
environments. Some additional cargo
features require std
(e.g., pretty printing, serialization).
use raw_cpuid::CpuId;
let cpuid = CpuId::new();
if let Some(vf) = cpuid.get_vendor_info() {
assert!(vf.as_str() == "GenuineIntel" || vf.as_str() == "AuthenticAMD");
}
let has_sse = cpuid.get_feature_info().map_or(false, |finfo| finfo.has_sse());
if has_sse {
println!("CPU supports SSE!");
}
if let Some(cparams) = cpuid.get_cache_parameters() {
for cache in cparams {
let size = cache.associativity() * cache.physical_line_partitions() * cache.coherency_line_size() * cache.sets();
println!("L{}-Cache size is {}", cache.level(), size);
}
} else {
println!("No cache parameter information available")
}
cpuid
binaryraw-cpuid
ships with a cpuid
binary that can be installed to inspect the
output of the CPUID instruction on a host system.
To install, use:
cargo install raw-cpuid --features cli
The cli
feature is currently required to build the binary version due to
cargo limitations.