@@ -11,6 +11,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
1111 // The following Microsoft documents isn't updated for aarch64.
1212 // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
1313 // These are defined in winnt.h of Windows SDK
14+ const PF_ARM_VFP_32_REGISTERS_AVAILABLE : u32 = 18 ;
1415 const PF_ARM_NEON_INSTRUCTIONS_AVAILABLE : u32 = 19 ;
1516 const PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE : u32 = 30 ;
1617 const PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE : u32 = 31 ;
@@ -31,10 +32,14 @@ pub(crate) fn detect_features() -> cache::Initializer {
3132 }
3233 } ;
3334
34- // Some features such Feature::fp may be supported on current CPU,
35+ // Some features may be supported on current CPU,
3536 // but no way to detect it by OS API.
3637 // Also, we require unsafe block for the extern "system" calls.
3738 unsafe {
39+ enable_feature (
40+ Feature :: fp,
41+ IsProcessorFeaturePresent ( PF_ARM_VFP_32_REGISTERS_AVAILABLE ) != FALSE ,
42+ ) ;
3843 enable_feature (
3944 Feature :: asimd,
4045 IsProcessorFeaturePresent ( PF_ARM_NEON_INSTRUCTIONS_AVAILABLE ) != FALSE ,
@@ -61,18 +66,11 @@ pub(crate) fn detect_features() -> cache::Initializer {
6166 ) ;
6267 // PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE means aes, sha1, sha2 and
6368 // pmull support
64- enable_feature (
65- Feature :: aes,
66- IsProcessorFeaturePresent ( PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE ) != FALSE ,
67- ) ;
68- enable_feature (
69- Feature :: pmull,
70- IsProcessorFeaturePresent ( PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE ) != FALSE ,
71- ) ;
72- enable_feature (
73- Feature :: sha2,
74- IsProcessorFeaturePresent ( PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE ) != FALSE ,
75- ) ;
69+ let crypto =
70+ IsProcessorFeaturePresent ( PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE ) != FALSE ;
71+ enable_feature ( Feature :: aes, crypto) ;
72+ enable_feature ( Feature :: pmull, crypto) ;
73+ enable_feature ( Feature :: sha2, crypto) ;
7674 }
7775 }
7876 value
0 commit comments