@@ -65,7 +65,10 @@ extern crate serde;
65
65
#[ macro_use]
66
66
extern crate bitflags;
67
67
68
+ #[ cfg_attr( any( all( target_arch = "x86" , not( target_env = "sgx" ) , target_feature = "sse" ) , all( target_arch = "x86_64" , not( target_env = "sgx" ) ) ) , has_native_cpuid) ]
69
+
68
70
/// Uses Rust's `cpuid` function from the `arch` module.
71
+ #[ cfg( has_native_cpuid) ]
69
72
pub mod native_cpuid {
70
73
use crate :: CpuIdResult ;
71
74
@@ -105,6 +108,7 @@ mod std {
105
108
///
106
109
/// First parameter is cpuid leaf (EAX register value),
107
110
/// second optional parameter is the subleaf (ECX register value).
111
+ #[ cfg( has_native_cpuid) ]
108
112
#[ macro_export]
109
113
macro_rules! cpuid {
110
114
( $eax: expr) => {
@@ -175,6 +179,7 @@ impl CpuIdReader {
175
179
}
176
180
}
177
181
182
+ #[ cfg( has_native_cpuid) ]
178
183
impl Default for CpuIdReader {
179
184
fn default ( ) -> Self {
180
185
Self {
@@ -223,6 +228,7 @@ pub struct CpuId {
223
228
supported_extended_leafs : u32 ,
224
229
}
225
230
231
+ #[ cfg( has_native_cpuid) ]
226
232
impl Default for CpuId {
227
233
fn default ( ) -> CpuId {
228
234
CpuId :: with_cpuid_fn ( native_cpuid:: cpuid_count)
@@ -304,6 +310,7 @@ const EAX_SVM_FEATURES: u32 = 0x8000_000A;
304
310
305
311
impl CpuId {
306
312
/// Return new CpuId struct.
313
+ #[ cfg( has_native_cpuid) ]
307
314
pub fn new ( ) -> Self {
308
315
Self :: default ( )
309
316
}
@@ -5129,9 +5136,9 @@ impl SoCVendorInfo {
5129
5136
pub fn get_vendor_brand ( & self ) -> Option < SoCVendorBrand > {
5130
5137
// Leaf 17H is valid if MaxSOCID_Index >= 3.
5131
5138
if self . eax >= 3 {
5132
- let r1 = cpuid ! ( EAX_SOC_VENDOR_INFO , 1 ) ;
5133
- let r2 = cpuid ! ( EAX_SOC_VENDOR_INFO , 2 ) ;
5134
- let r3 = cpuid ! ( EAX_SOC_VENDOR_INFO , 3 ) ;
5139
+ let r1 = self . read . cpuid2 ( EAX_SOC_VENDOR_INFO , 1 ) ;
5140
+ let r2 = self . read . cpuid2 ( EAX_SOC_VENDOR_INFO , 2 ) ;
5141
+ let r3 = self . read . cpuid2 ( EAX_SOC_VENDOR_INFO , 3 ) ;
5135
5142
Some ( SoCVendorBrand { data : [ r1, r2, r3] } )
5136
5143
} else {
5137
5144
None
0 commit comments