ref: b10771e9d6ab408b029b0cb5b22de8fa36e2f512
parent: 65305637d762398c43175baf34348f8c7620f9a1
author: Jan Beich <[email protected]>
date: Mon Dec 17 15:25:05 EST 2018
arm: detect NEON on FreeBSD armv6 FreeBSD 11.2 added AT_HWCAP via sysctl() while 12.0 added elf_aux_info() which requires less code to use and is cached by libc. Only support the latter to avoid cruft to be removed after 11.* EOL on 2021-09-30.
--- a/meson.build
+++ b/meson.build
@@ -147,6 +147,9 @@
if cc.has_function('getauxval', prefix : '#include <sys/auxv.h>', args : test_args)
cdata.set('HAVE_GETAUXVAL', 1)
endif
+ if cc.has_function('elf_aux_info', prefix : '#include <sys/auxv.h>', args : test_args)
+ cdata.set('HAVE_ELF_AUX_INFO', 1)
+ endif
endif
# Compiler flag tests
--- a/src/arm/cpu.c
+++ b/src/arm/cpu.c
@@ -37,6 +37,11 @@
#endif
#define NEON_HWCAP HWCAP_ARM_NEON
+#elif defined(HAVE_ELF_AUX_INFO) && ARCH_ARM
+#include <sys/auxv.h>
+
+#define NEON_HWCAP HWCAP_NEON
+
#elif defined(__ANDROID__)
#include <stdio.h>
#include <string.h>
@@ -76,6 +81,10 @@
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(HAVE_ELF_AUX_INFO) && ARCH_ARM
+ unsigned long hw_cap = 0;
+ elf_aux_info(AT_HWCAP, &hw_cap, sizeof(hw_cap));
flags |= (hw_cap & NEON_HWCAP) ? DAV1D_ARM_CPU_FLAG_NEON : 0;
#elif defined(__ANDROID__)
flags |= parse_proc_cpuinfo("neon") ? DAV1D_ARM_CPU_FLAG_NEON : 0;