Skip to content

Commit 1beff5f

Browse files
committed
Avoid unused _have_feature and rename to _have_arm_feature
1 parent 47b8dcc commit 1beff5f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/common/cpu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ static CPUFeatures _cpu_features;
6363
#define AEGIS_AARCH64_HWCAP_SHA3 (1L << 17)
6464
#define AEGIS_AARCH64_HWCAP2_SVEAES (1L << 2)
6565

66-
#if defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
66+
#if !(__ARM_FEATURE_CRYPTO || __ARM_FEATURE_AES)
67+
# if defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
6768
// sysctlbyname() parameter documentation for instruction set characteristics:
6869
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
6970
static inline int
70-
_have_feature(const char *feature)
71+
_have_arm_feature(const char *feature)
7172
{
7273
int64_t feature_present = 0;
7374
size_t size = sizeof(feature_present);
@@ -76,6 +77,7 @@ _have_feature(const char *feature)
7677
}
7778
return feature_present;
7879
}
80+
# endif
7981

8082
#elif (defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
8183
static inline int
@@ -121,7 +123,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
121123
// Assuming all CPUs supported by Arm Windows have the crypto extensions.
122124
cpu_features->has_neon_aes = 1;
123125
#elif defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
124-
cpu_features->has_neon_aes = _have_feature("hw.optional.arm.FEAT_AES");
126+
cpu_features->has_neon_aes = _have_arm_feature("hw.optional.arm.FEAT_AES");
125127
#elif defined(HAVE_ANDROID_GETCPUFEATURES) && defined(ANDROID_CPU_ARM_FEATURE_AES)
126128
cpu_features->has_neon_aes = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_AES) != 0x0;
127129
#elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
@@ -143,7 +145,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
143145
#elif defined(_M_ARM64) && defined(PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE)
144146
cpu_features->has_neon_sha3 = IsProcessorFeaturePresent(PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE);
145147
#elif defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
146-
cpu_features->has_neon_sha3 = _have_feature("hw.optional.arm.FEAT_SHA3");
148+
cpu_features->has_neon_sha3 = _have_arm_feature("hw.optional.arm.FEAT_SHA3");
147149
#elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
148150
cpu_features->has_neon_sha3 = _have_hwcap(AT_HWCAP, AEGIS_AARCH64_HWCAP_SHA3);
149151
#endif

0 commit comments

Comments
 (0)