Skip to content

Commit 2859a32

Browse files
committed
Format
1 parent 3fd2d43 commit 2859a32

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/common/cpu.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,28 @@ static CPUFeatures _cpu_features;
5858
#define AEGIS_ARM_HWCAP2_AES (1L << 0)
5959

6060
// 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)
6464
#define AEGIS_AARCH64_HWCAP2_SVEAES (1L << 2)
6565

6666
#if defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
6767
// sysctlbyname() parameter documentation for instruction set characteristics:
6868
// 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;
7678
}
7779

7880
#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)
8083
{
8184
unsigned long buf = 0;
8285
# ifdef HAVE_GETAUXVAL
@@ -138,8 +141,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
138141
#if __ARM_FEATURE_SHA3
139142
cpu_features->has_neon_sha3 = 1;
140143
#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);
143145
#elif defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
144146
cpu_features->has_neon_sha3 = _have_feature("hw.optional.arm.FEAT_SHA3");
145147
#elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
@@ -157,8 +159,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
157159
#if __ARM_FEATURE_SVE2_AES
158160
cpu_features->has_sve2_aes = 1;
159161
#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);
162163
#elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
163164
cpu_features->has_sve2_aes = _have_hwcap(AT_HWCAP2, AEGIS_AARCH64_HWCAP2_SVEAES);
164165
#endif

0 commit comments

Comments
 (0)