Untangle arm and aarch64 #ifdefs in GetCpuFlags()

Change-Id: I5df39c20a700aee38954bc9288fdee116138645d
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5879350
Reviewed-by: George Steed <george.steed@arm.com>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
Wan-Teh Chang 2024-09-20 15:34:42 -07:00 committed by Frank Barchard
parent f1b28b3510
commit 85e55115f0

View File

@ -451,8 +451,8 @@ static SAFEBUFFERS int GetCpuFlags(void) {
cpu_info = LoongarchCpuCaps(); cpu_info = LoongarchCpuCaps();
cpu_info |= kCpuHasLOONGARCH; cpu_info |= kCpuHasLOONGARCH;
#endif #endif
#if defined(__arm__) || defined(__aarch64__) #if defined(__aarch64__)
#if defined(__aarch64__) && defined(__linux__) #if defined(__linux__)
// getauxval is supported since Android SDK version 18, minimum at time of // getauxval is supported since Android SDK version 18, minimum at time of
// writing is 21, so should be safe to always use this. If getauxval is // writing is 21, so should be safe to always use this. If getauxval is
// somehow disabled then getauxval returns 0, which will leave Neon enabled // somehow disabled then getauxval returns 0, which will leave Neon enabled
@ -460,9 +460,12 @@ static SAFEBUFFERS int GetCpuFlags(void) {
unsigned long hwcap = getauxval(AT_HWCAP); unsigned long hwcap = getauxval(AT_HWCAP);
unsigned long hwcap2 = getauxval(AT_HWCAP2); unsigned long hwcap2 = getauxval(AT_HWCAP2);
cpu_info = AArch64CpuCaps(hwcap, hwcap2); cpu_info = AArch64CpuCaps(hwcap, hwcap2);
#elif defined(__aarch64__)
cpu_info = AArch64CpuCaps();
#else #else
cpu_info = AArch64CpuCaps();
#endif
cpu_info |= kCpuHasARM;
#endif // __aarch64__
#if defined(__arm__)
// gcc -mfpu=neon defines __ARM_NEON__ // gcc -mfpu=neon defines __ARM_NEON__
// __ARM_NEON__ generates code that requires Neon. NaCL also requires Neon. // __ARM_NEON__ generates code that requires Neon. NaCL also requires Neon.
// For Linux, /proc/cpuinfo can be tested but without that assume Neon. // For Linux, /proc/cpuinfo can be tested but without that assume Neon.
@ -473,7 +476,6 @@ static SAFEBUFFERS int GetCpuFlags(void) {
cpu_info = kCpuHasNEON; cpu_info = kCpuHasNEON;
#else #else
cpu_info = 0; cpu_info = 0;
#endif
#endif #endif
cpu_info |= kCpuHasARM; cpu_info |= kCpuHasARM;
#endif // __arm__ #endif // __arm__