diff --git a/CHANGELOG.md b/CHANGELOG.md index 140f922..478d519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,21 +5,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [11.0.0] - XXXX-XX-XX +## [11.0.0] - 2023-04-17 ### Breaking changes - The `CpuId` type now takes a generic reader argument `CpuId`: - the generic allows for more flexibility. This is a breaking change for users + which allows for more flexibility on how cpuid is queried and better support + for using the library on non-x86 targets. This is a breaking change for users of `with_cpuid_fn` and potentially when specifying `CpuId` as a type argument somewhere. To make existing code compile again, whenever a generic type argument for CpuId is needed, you can use the `cpuid::NativeCpuIdReader` type - which provides the default behavior of reading the CPUID registers. + which provides the default behavior of execution the `cpuid` instruction. - Although we do specify a default generic type for CpuId to be - `cpuid::NativeCpuIdReader` there might be cases where you need to specify the - generic type of CpuId: e.g., `fn take_cpuid(cpuid: CpuId)` would become: - `fn take_cpuid(cpuid: CpuId)` + For example, in your code there might be cases where the compiler now asks you + to specify the generic type of CpuId: e.g., `fn take_cpuid(cpuid: CpuId)` + would become: `fn take_cpuid(cpuid: CpuId)` + + See also [#140](https://github.com/gz/rust-cpuid/pull/140) and + [#138](https://github.com/gz/rust-cpuid/pull/138) for the original discussion. - If you're using the `serialization` feature: It go revamped by fixing some long-standing problems with it that made it difficult to use diff --git a/examples/cache.rs b/examples/cache.rs index 02fb8ff..f31333d 100644 --- a/examples/cache.rs +++ b/examples/cache.rs @@ -1,4 +1,6 @@ //! Example that displays information about the caches. +//! +//! This example only compiles on x86 platforms. extern crate raw_cpuid; use raw_cpuid::{CacheType, CpuId}; diff --git a/examples/cpu.rs b/examples/cpu.rs index 167a41c..42fc600 100644 --- a/examples/cpu.rs +++ b/examples/cpu.rs @@ -1,4 +1,6 @@ //! An example that displays the type/features/configuration of the CPU. +//! +//! This example only compiles on x86 platforms. extern crate raw_cpuid; fn main() { diff --git a/examples/topology.rs b/examples/topology.rs index 9b2874f..85b8d10 100644 --- a/examples/topology.rs +++ b/examples/topology.rs @@ -2,6 +2,8 @@ //! //! Intel Topology is a pretty complicated subject (unfortunately): //! https://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/ +//! +//! This example only compiles on x86 platforms. extern crate core_affinity; extern crate raw_cpuid; diff --git a/examples/tsc_frequency.rs b/examples/tsc_frequency.rs index 341e735..a3b4c64 100644 --- a/examples/tsc_frequency.rs +++ b/examples/tsc_frequency.rs @@ -1,4 +1,6 @@ -//! An example that determines the time stamp counter frequency (RDTSC, RDTSCP) . +//! An example that determines the time stamp counter frequency (RDTSC, RDTSCP). +//! +//! This example only compiles on x86 platforms. extern crate raw_cpuid; use std::time; diff --git a/src/bin/cpuid.rs b/src/bin/cpuid.rs index dca8140..4be48e8 100644 --- a/src/bin/cpuid.rs +++ b/src/bin/cpuid.rs @@ -1,3 +1,6 @@ +//! The cpuid binary accompanying the library. +//! +//! The cpuid binary only compiles/runs on x86 platforms. use std::str::FromStr; use clap::Parser; diff --git a/src/lib.rs b/src/lib.rs index 0e225c6..778568f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,19 +220,7 @@ impl Vendor { /// /// Other structs can be accessed by going through this type. #[derive(Clone, Copy)] -pub struct CpuId< - #[cfg(any( - all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), - all(target_arch = "x86_64", not(target_env = "sgx")) - ))] - R: CpuIdReader=CpuIdReaderNative, - - #[cfg(not(any( - all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), - all(target_arch = "x86_64", not(target_env = "sgx")) - )))] - R: CpuIdReader -> { +pub struct CpuId { /// A generic reader to abstract the cpuid interface. read: R, /// CPU vendor to differentiate cases where logic needs to differ in code . diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 4237dfe..5dfff62 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,4 +1,6 @@ +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] mod i5_3337u; + mod i7_12700k; mod ryzen_matisse; mod xeon_gold_6252;