Path: blob/main/multimedia/aom/files/patch-aom__ports_arm__cpudetect.c
16125 views
- Assume NEON is enabled on aarch641- Implement NEON runtime detection on FreeBSD23--- aom_ports/arm_cpudetect.c.orig 2018-11-16 20:24:20 UTC4+++ aom_ports/arm_cpudetect.c5@@ -38,7 +38,7 @@ static int arm_cpu_env_mask(void) {6return env && *env ? (int)strtol(env, NULL, 0) : ~0;7}89-#if !CONFIG_RUNTIME_CPU_DETECT10+#if !CONFIG_RUNTIME_CPU_DETECT || defined(__ARM_NEON)1112int aom_arm_cpu_caps(void) {13/* This function should actually be a no-op. There is no way to adjust any of14@@ -143,7 +143,57 @@ int aom_arm_cpu_caps(void) {15}16return flags & mask;17}18-#else /* end __linux__ */19+#elif defined(__FreeBSD__)20+21+#if __FreeBSD__ < 1222+#include <sys/param.h>23+#include <sys/sysctl.h>24+#include <elf.h>25+#include <errno.h>26+#include <unistd.h>27+28+static unsigned long getauxval(unsigned long type) {29+ Elf_Auxinfo auxv[AT_COUNT];30+ size_t len = sizeof(auxv);31+ int mib[] = {32+ CTL_KERN,33+ KERN_PROC,34+ KERN_PROC_AUXV,35+ getpid(),36+ };37+38+ if (sysctl(mib, nitems(mib), auxv, &len, NULL, 0) != -1) {39+ for (size_t i = 0; i < nitems(auxv); i++)40+ if ((unsigned long)auxv[i].a_type == type)41+ return auxv[i].a_un.a_val;42+43+ errno = ENOENT;44+ }45+ return 0;46+}47+#else48+#include <sys/auxv.h>49+#endif50+51+int aom_arm_cpu_caps(void) {52+ int flags;53+ int mask;54+ u_long hwcap = 0;55+ if (!arm_cpu_env_flags(&flags)) {56+ return flags;57+ }58+ mask = arm_cpu_env_mask();59+#if __FreeBSD__ < 1260+ hwcap = getauxval(AT_HWCAP);61+#else62+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));63+#endif64+#if HAVE_NEON65+ if (hwcap & HWCAP_NEON) flags |= HAS_NEON;66+#endif67+ return flags & mask;68+}69+#else /* end __FreeBSD__ */70#error \71"--enable-runtime-cpu-detect selected, but no CPU detection method " \72"available for your platform. Reconfigure with --disable-runtime-cpu-detect."737475