@@ -58,25 +58,28 @@ static CPUFeatures _cpu_features;
58
58
#define AEGIS_ARM_HWCAP2_AES (1L << 0)
59
59
60
60
// AArch64 hwcaps.
61
- #define AEGIS_AARCH64_HWCAP_ASIMD (1L << 1)
62
- #define AEGIS_AARCH64_HWCAP_AES (1L << 3)
63
- #define AEGIS_AARCH64_HWCAP_SHA3 (1L << 17)
61
+ #define AEGIS_AARCH64_HWCAP_ASIMD (1L << 1)
62
+ #define AEGIS_AARCH64_HWCAP_AES (1L << 3)
63
+ #define AEGIS_AARCH64_HWCAP_SHA3 (1L << 17)
64
64
#define AEGIS_AARCH64_HWCAP2_SVEAES (1L << 2)
65
65
66
66
#if defined(__APPLE__ ) && defined(CPU_TYPE_ARM64 ) && defined(CPU_SUBTYPE_ARM64E )
67
67
// sysctlbyname() parameter documentation for instruction set characteristics:
68
68
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
69
- static inline int _have_feature (const char * feature ) {
70
- int64_t feature_present = 0 ;
71
- size_t size = sizeof (feature_present );
72
- if (sysctlbyname (feature , & feature_present , & size , NULL , 0 ) != 0 ) {
73
- return 0 ;
74
- }
75
- return feature_present ;
69
+ static inline int
70
+ _have_feature (const char * feature )
71
+ {
72
+ int64_t feature_present = 0 ;
73
+ size_t size = sizeof (feature_present );
74
+ if (sysctlbyname (feature , & feature_present , & size , NULL , 0 ) != 0 ) {
75
+ return 0 ;
76
+ }
77
+ return feature_present ;
76
78
}
77
79
78
80
#elif (defined(__arm__ ) || defined(__aarch64__ ) || defined(_M_ARM64 )) && defined(AT_HWCAP )
79
- static inline int _have_hwcap (int hwcap_id , int bit )
81
+ static inline int
82
+ _have_hwcap (int hwcap_id , int bit )
80
83
{
81
84
unsigned long buf = 0 ;
82
85
# ifdef HAVE_GETAUXVAL
@@ -138,8 +141,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
138
141
#if __ARM_FEATURE_SHA3
139
142
cpu_features -> has_neon_sha3 = 1 ;
140
143
#elif defined(_M_ARM64 ) && defined(PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE )
141
- cpu_features -> has_neon_sha3 =
142
- IsProcessorFeaturePresent (PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE );
144
+ cpu_features -> has_neon_sha3 = IsProcessorFeaturePresent (PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE );
143
145
#elif defined(__APPLE__ ) && defined(CPU_TYPE_ARM64 ) && defined(CPU_SUBTYPE_ARM64E )
144
146
cpu_features -> has_neon_sha3 = _have_feature ("hw.optional.arm.FEAT_SHA3" );
145
147
#elif (defined(__aarch64__ ) || defined(_M_ARM64 )) && defined(AT_HWCAP )
@@ -157,8 +159,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
157
159
#if __ARM_FEATURE_SVE2_AES
158
160
cpu_features -> has_sve2_aes = 1 ;
159
161
#elif defined(_M_ARM64 ) && defined(PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE )
160
- cpu_features -> has_sve2_aes =
161
- IsProcessorFeaturePresent (PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE );
162
+ cpu_features -> has_sve2_aes = IsProcessorFeaturePresent (PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE );
162
163
#elif (defined(__aarch64__ ) || defined(_M_ARM64 )) && defined(AT_HWCAP )
163
164
cpu_features -> has_sve2_aes = _have_hwcap (AT_HWCAP2 , AEGIS_AARCH64_HWCAP2_SVEAES );
164
165
#endif
0 commit comments