ref: d4fcb70ddfa69808518b38c8de10ec61b145d47a
parent: 287ba91b2b84376f0ae7f823c11e2b4a017630f4
author: Martin Storsjö <martin@martin.st>
date: Fri Nov 2 06:21:18 EDT 2018
arm: Improve use of getauxval in quirky environments Manually define the necessary HWCAP if sys/auxv.h didn't define it. (It isn't defined in the Android NDK, one has to include asm/hwcap.h to get definitions of them. Additionally, the aarch64 cross libc headers in Ubuntu 16.04 lacked HWCAP definitions from sys/auxv.h, also present in asm/hwcap.h. Ubuntu 16.04's armhf cross libc headers did however define HWCAP values in sys/auxv.h.) Don't use any detection at all for NEON on aarch64, since it is a mandatory feature there. On WSL on Windows 10 1803 arm64, getauxval(AT_HWCAP) returns 0.
--- a/src/arm/cpu.c
+++ b/src/arm/cpu.c
@@ -29,14 +29,13 @@
#include "src/arm/cpu.h"
-#if defined(HAVE_GETAUXVAL)
+#if defined(HAVE_GETAUXVAL) && ARCH_ARM
#include <sys/auxv.h>
-#if ARCH_AARCH64
-#define NEON_HWCAP HWCAP_ASIMD
-#elif ARCH_ARM
-#define NEON_HWCAP HWCAP_ARM_NEON
+#ifndef HWCAP_ARM_NEON
+#define HWCAP_ARM_NEON (1 << 12)
#endif
+#define NEON_HWCAP HWCAP_ARM_NEON
#elif defined(__ANDROID__)
#include <stdio.h>
@@ -71,7 +70,9 @@
unsigned dav1d_get_cpu_flags_arm(void) {
unsigned flags = 0;
-#if defined(HAVE_GETAUXVAL)
+#if ARCH_AARCH64
+ flags |= DAV1D_ARM_CPU_FLAG_NEON;
+#elif defined(HAVE_GETAUXVAL) && ARCH_ARM
unsigned long hw_cap = getauxval(AT_HWCAP);
flags |= (hw_cap & NEON_HWCAP) ? DAV1D_ARM_CPU_FLAG_NEON : 0;
#elif defined(__ANDROID__)