Avoid reading /proc/cpuinfo for non-Linux Arm platforms

While we will return kCpuHasNEON if the file fails to open, this does
unnecessarily introduce filesystem operations which are not needed e.g.
on embedded non-Linux platforms. When not building for Linux, we can
simply rely on the compiler flags to determine whether NEON support is
present for Arm32.

Change-Id: Ifb0eab2a46969fca5f733ce624abdf54da9b32a2
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5778479
Reviewed-by: Wan-Teh Chang <wtc@google.com>
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Reviewed-by: George Steed <george.steed@arm.com>
This commit is contained in:
Alex Richardson 2024-08-09 14:13:09 -07:00 committed by Frank Barchard
parent 0d5a31eccb
commit f1b28b3510

View File

@ -467,7 +467,13 @@ static SAFEBUFFERS int GetCpuFlags(void) {
// __ARM_NEON__ generates code that requires Neon. NaCL also requires Neon.
// For Linux, /proc/cpuinfo can be tested but without that assume Neon.
// Linux arm parse text file for neon detect.
#if defined(__linux__)
cpu_info = ArmCpuCaps("/proc/cpuinfo");
#elif defined(__ARM_NEON__)
cpu_info = kCpuHasNEON;
#else
cpu_info = 0;
#endif
#endif
cpu_info |= kCpuHasARM;
#endif // __arm__