@@ -40,10 +40,10 @@ pub(crate) fn detect_features() -> cache::Initializer {
4040 // leaf value for subsequent calls of `cpuinfo` in range [0,
4141 // 0x8000_0000]. - The vendor ID is stored in 12 u8 ascii chars,
4242 // returned in EBX, EDX, and ECX (in that order):
43- let ( max_basic_leaf, vendor_id) = unsafe {
43+ let ( max_basic_leaf, vendor_id) = {
4444 let CpuidResult { eax : max_basic_leaf, ebx, ecx, edx } = __cpuid ( 0 ) ;
4545 let vendor_id: [ [ u8 ; 4 ] ; 3 ] = [ ebx. to_ne_bytes ( ) , edx. to_ne_bytes ( ) , ecx. to_ne_bytes ( ) ] ;
46- let vendor_id: [ u8 ; 12 ] = mem:: transmute ( vendor_id) ;
46+ let vendor_id: [ u8 ; 12 ] = unsafe { mem:: transmute ( vendor_id) } ;
4747 ( max_basic_leaf, vendor_id)
4848 } ;
4949
@@ -54,8 +54,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
5454
5555 // EAX = 1, ECX = 0: Queries "Processor Info and Feature Bits";
5656 // Contains information about most x86 features.
57- let CpuidResult { ecx : proc_info_ecx, edx : proc_info_edx, .. } =
58- unsafe { __cpuid ( 0x0000_0001_u32 ) } ;
57+ let CpuidResult { ecx : proc_info_ecx, edx : proc_info_edx, .. } = __cpuid ( 0x0000_0001_u32 ) ;
5958
6059 // EAX = 7: Queries "Extended Features";
6160 // Contains information about bmi,bmi2, and avx2 support.
@@ -66,9 +65,9 @@ pub(crate) fn detect_features() -> cache::Initializer {
6665 extended_features_eax_leaf_1,
6766 extended_features_edx_leaf_1,
6867 ) = if max_basic_leaf >= 7 {
69- let CpuidResult { ebx, ecx, edx, .. } = unsafe { __cpuid ( 0x0000_0007_u32 ) } ;
68+ let CpuidResult { ebx, ecx, edx, .. } = __cpuid ( 0x0000_0007_u32 ) ;
7069 let CpuidResult { eax : eax_1, edx : edx_1, .. } =
71- unsafe { __cpuid_count ( 0x0000_0007_u32 , 0x0000_0001_u32 ) } ;
70+ __cpuid_count ( 0x0000_0007_u32 , 0x0000_0001_u32 ) ;
7271 ( ebx, ecx, edx, eax_1, edx_1)
7372 } else {
7473 ( 0 , 0 , 0 , 0 , 0 ) // CPUID does not support "Extended Features"
@@ -77,12 +76,12 @@ pub(crate) fn detect_features() -> cache::Initializer {
7776 // EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported
7877 // - EAX returns the max leaf value for extended information, that is,
7978 // `cpuid` calls in range [0x8000_0000; u32::MAX]:
80- let CpuidResult { eax : extended_max_basic_leaf, .. } = unsafe { __cpuid ( 0x8000_0000_u32 ) } ;
79+ let CpuidResult { eax : extended_max_basic_leaf, .. } = __cpuid ( 0x8000_0000_u32 ) ;
8180
8281 // EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature
8382 // Bits"
8483 let extended_proc_info_ecx = if extended_max_basic_leaf >= 1 {
85- let CpuidResult { ecx, .. } = unsafe { __cpuid ( 0x8000_0001_u32 ) } ;
84+ let CpuidResult { ecx, .. } = __cpuid ( 0x8000_0001_u32 ) ;
8685 ecx
8786 } else {
8887 0
@@ -132,7 +131,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
132131
133132 // Detect if CPUID.19h available
134133 if bit:: test ( extended_features_ecx as usize , 23 ) {
135- let CpuidResult { ebx, .. } = unsafe { __cpuid ( 0x19 ) } ;
134+ let CpuidResult { ebx, .. } = __cpuid ( 0x19 ) ;
136135 enable ( ebx, 0 , Feature :: kl) ;
137136 enable ( ebx, 2 , Feature :: widekl) ;
138137 }
@@ -223,7 +222,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
223222 // ECX = 1):
224223 if max_basic_leaf >= 0xd {
225224 let CpuidResult { eax : proc_extended_state1_eax, .. } =
226- unsafe { __cpuid_count ( 0xd_u32 , 1 ) } ;
225+ __cpuid_count ( 0xd_u32 , 1 ) ;
227226 enable ( proc_extended_state1_eax, 0 , Feature :: xsaveopt) ;
228227 enable ( proc_extended_state1_eax, 1 , Feature :: xsavec) ;
229228 enable ( proc_extended_state1_eax, 3 , Feature :: xsaves) ;
@@ -282,7 +281,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
282281
283282 if max_basic_leaf >= 0x1e {
284283 let CpuidResult { eax : amx_feature_flags_eax, .. } =
285- unsafe { __cpuid_count ( 0x1e_u32 , 1 ) } ;
284+ __cpuid_count ( 0x1e_u32 , 1 ) ;
286285
287286 enable ( amx_feature_flags_eax, 4 , Feature :: amx_fp8) ;
288287 enable ( amx_feature_flags_eax, 6 , Feature :: amx_tf32) ;
@@ -297,7 +296,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
297296
298297 let avx10_1 = enable ( extended_features_edx_leaf_1, 19 , Feature :: avx10_1) ;
299298 if avx10_1 {
300- let CpuidResult { ebx, .. } = unsafe { __cpuid ( 0x24 ) } ;
299+ let CpuidResult { ebx, .. } = __cpuid ( 0x24 ) ;
301300 let avx10_version = ebx & 0xff ;
302301 if avx10_version >= 2 {
303302 value. set ( Feature :: avx10_2 as u32 ) ;
0 commit comments