Skip to content

Commit 3e85354

Browse files
committed
lib/arm/cpu_features: simplify ifdefs for runtime detection
Eliminate a redundant preprocessor symbol, as was done in lib/x86/.
1 parent 9e79696 commit 3e85354

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

lib/arm/cpu_features.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
#include "../cpu_features_common.h" /* must be included first */
4040
#include "cpu_features.h"
4141

42-
#if HAVE_DYNAMIC_ARM_CPU_FEATURES
42+
#ifdef ARM_CPU_FEATURES_KNOWN
43+
/* Runtime ARM CPU feature detection is supported. */
4344

4445
#ifdef __linux__
4546
/*
@@ -220,4 +221,4 @@ void libdeflate_init_arm_cpu_features(void)
220221
libdeflate_arm_cpu_features = features | ARM_CPU_FEATURES_KNOWN;
221222
}
222223

223-
#endif /* HAVE_DYNAMIC_ARM_CPU_FEATURES */
224+
#endif /* ARM_CPU_FEATURES_KNOWN */

lib/arm/cpu_features.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,8 @@
3030

3131
#include "../lib_common.h"
3232

33-
#define HAVE_DYNAMIC_ARM_CPU_FEATURES 0
34-
3533
#if defined(ARCH_ARM32) || defined(ARCH_ARM64)
3634

37-
#if !defined(FREESTANDING) && \
38-
(defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)) && \
39-
(defined(__linux__) || \
40-
(defined(__APPLE__) && defined(ARCH_ARM64)) || \
41-
(defined(_WIN32) && defined(ARCH_ARM64)))
42-
# undef HAVE_DYNAMIC_ARM_CPU_FEATURES
43-
# define HAVE_DYNAMIC_ARM_CPU_FEATURES 1
44-
#endif
45-
4635
#define ARM_CPU_FEATURE_NEON (1 << 0)
4736
#define ARM_CPU_FEATURE_PMULL (1 << 1)
4837
/*
@@ -55,8 +44,13 @@
5544
#define ARM_CPU_FEATURE_SHA3 (1 << 4)
5645
#define ARM_CPU_FEATURE_DOTPROD (1 << 5)
5746

58-
#if HAVE_DYNAMIC_ARM_CPU_FEATURES
59-
#define ARM_CPU_FEATURES_KNOWN (1U << 31)
47+
#if !defined(FREESTANDING) && \
48+
(defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)) && \
49+
(defined(__linux__) || \
50+
(defined(__APPLE__) && defined(ARCH_ARM64)) || \
51+
(defined(_WIN32) && defined(ARCH_ARM64)))
52+
/* Runtime ARM CPU feature detection is supported. */
53+
# define ARM_CPU_FEATURES_KNOWN (1U << 31)
6054
extern volatile u32 libdeflate_arm_cpu_features;
6155

6256
void libdeflate_init_arm_cpu_features(void);
@@ -67,9 +61,9 @@ static inline u32 get_arm_cpu_features(void)
6761
libdeflate_init_arm_cpu_features();
6862
return libdeflate_arm_cpu_features;
6963
}
70-
#else /* HAVE_DYNAMIC_ARM_CPU_FEATURES */
64+
#else
7165
static inline u32 get_arm_cpu_features(void) { return 0; }
72-
#endif /* !HAVE_DYNAMIC_ARM_CPU_FEATURES */
66+
#endif
7367

7468
/* NEON */
7569
#if defined(__ARM_NEON) || (defined(_MSC_VER) && defined(ARCH_ARM64))

0 commit comments

Comments
 (0)