From f1b28b3510b9f870de598b75c5628aaff9b3e5a1 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 9 Aug 2024 14:13:09 -0700 Subject: [PATCH] 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 Reviewed-by: Frank Barchard Reviewed-by: George Steed --- source/cpu_id.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/cpu_id.cc b/source/cpu_id.cc index e34a3a905..906b31d58 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -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__