Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacDynamo authored and gz committed Mar 19, 2022
1 parent 9933021 commit f927c94
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,20 @@ extern crate serde;
#[macro_use]
extern crate bitflags;

#[cfg(all(feature = "serialize", not(any(all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), all(target_arch = "x86_64", not(target_env = "sgx"))))))]
#[cfg(all(
feature = "serialize",
not(any(
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
all(target_arch = "x86_64", not(target_env = "sgx"))
))
))]
core::compile_error!("Feature `serialize` is not supported on targets that do not have native cpuid. x86 and x86_64 targets with SGX and x86 targets without SSE are consider to not have native cpuid.");

/// Uses Rust's `cpuid` function from the `arch` module.
#[cfg(any(all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), all(target_arch = "x86_64", not(target_env = "sgx"))))]
#[cfg(any(
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
all(target_arch = "x86_64", not(target_env = "sgx"))
))]
pub mod native_cpuid {
use crate::CpuIdResult;

Expand Down Expand Up @@ -109,7 +118,10 @@ mod std {
///
/// First parameter is cpuid leaf (EAX register value),
/// second optional parameter is the subleaf (ECX register value).
#[cfg(any(all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), all(target_arch = "x86_64", not(target_env = "sgx"))))]
#[cfg(any(
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
all(target_arch = "x86_64", not(target_env = "sgx"))
))]
#[macro_export]
macro_rules! cpuid {
($eax:expr) => {
Expand Down Expand Up @@ -180,7 +192,10 @@ impl CpuIdReader {
}
}

#[cfg(any(all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), all(target_arch = "x86_64", not(target_env = "sgx"))))]
#[cfg(any(
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
all(target_arch = "x86_64", not(target_env = "sgx"))
))]
impl Default for CpuIdReader {
fn default() -> Self {
Self {
Expand Down Expand Up @@ -229,7 +244,10 @@ pub struct CpuId {
supported_extended_leafs: u32,
}

#[cfg(any(all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), all(target_arch = "x86_64", not(target_env = "sgx"))))]
#[cfg(any(
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
all(target_arch = "x86_64", not(target_env = "sgx"))
))]
impl Default for CpuId {
fn default() -> CpuId {
CpuId::with_cpuid_fn(native_cpuid::cpuid_count)
Expand Down Expand Up @@ -311,7 +329,10 @@ const EAX_SVM_FEATURES: u32 = 0x8000_000A;

impl CpuId {
/// Return new CpuId struct.
#[cfg(any(all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"), all(target_arch = "x86_64", not(target_env = "sgx"))))]
#[cfg(any(
all(target_arch = "x86", not(target_env = "sgx"), target_feature = "sse"),
all(target_arch = "x86_64", not(target_env = "sgx"))
))]
pub fn new() -> Self {
Self::default()
}
Expand Down

0 comments on commit f927c94

Please sign in to comment.