1
# Description: Implement WebRtc_GetCPUFeaturesARM on non-Android arm,
2
# so that it can be built with arm_neon_optional and NEON run-time
4
# Author: Chris Coulson <chris.coulson@canonical.com>
6
diff --git a/third_party/webrtc/system_wrappers/source/cpu_features.cc b/third_party/webrtc/system_wrappers/source/cpu_features.cc
7
--- a/third_party/webrtc/system_wrappers/source/cpu_features.cc
8
+++ b/third_party/webrtc/system_wrappers/source/cpu_features.cc
9
@@ -65,8 +65,76 @@ static int GetCPUInfo(CPUFeature feature
10
static int GetCPUInfo(CPUFeature feature) {
16
WebRtc_CPUInfo WebRtc_GetCPUInfo = GetCPUInfo;
17
WebRtc_CPUInfo WebRtc_GetCPUInfoNoASM = GetCPUInfoNoASM;
19
+#if defined(WEBRTC_ARCH_ARM64)
21
+uint64_t WebRtc_GetCPUFeaturesARM(void) {
22
+ return kCPUFeatureNEON;
25
+#elif defined(WEBRTC_ARCH_ARM)
27
+#include <asm/hwcap.h>
28
+#include <sys/auxv.h>
31
+#if defined(WEBRTC_ARCH_ARM_V7)
32
+#define HAVE_ARM_V7 kCPUFeatureARMv7
34
+#define HAVE_ARM_V7 0
36
+#if defined(WEBRTC_ARCH_ARM_NEON)
37
+#define HAVE_ARM_NEON kCPUFeatureNEON
39
+#define HAVE_ARM_NEON 0
42
+#define CORE_FLAGS (HAVE_ARM_V7 | HAVE_ARM_NEON)
44
+uint64_t WebRtc_GetCPUFeaturesARM(void) {
45
+ static bool detected = false;
46
+ static uint64_t flags = CORE_FLAGS;
54
+ struct { uint32_t a_type; uint32_t a_val; } auxv;
55
+ FILE *f = fopen("/proc/self/auxv", "r");
57
+ bool found_hwcap = false;
61
+ while (fread(&auxv, sizeof(auxv), 1, f) > 0) {
62
+ if (auxv.a_type == AT_HWCAP) {
75
+ if (hwcap & HWCAP_VFPv3) {
76
+ flags |= kCPUFeatureVFPv3;
78
+ if (hwcap & HWCAP_NEON) {
79
+ flags |= kCPUFeatureNEON;