svn commit: r451561 - in head/multimedia/libvpx: . files
Jan Beich
jbeich at FreeBSD.org
Sun Oct 8 18:57:31 UTC 2017
Author: jbeich
Date: Sun Oct 8 18:57:28 2017
New Revision: 451561
URL: https://svnweb.freebsd.org/changeset/ports/451561
Log:
multimedia/libvpx: detect NEON on armv7 at runtime
- armv6 may have NEON depending on CPUTYPE
- aarch64 always has NEON but not AT_HWCAP
Added:
head/multimedia/libvpx/files/patch-vpx__ports_arm__cpudetect.c (contents, props changed)
Modified:
head/multimedia/libvpx/Makefile (contents, props changed)
Modified: head/multimedia/libvpx/Makefile
==============================================================================
--- head/multimedia/libvpx/Makefile Sun Oct 8 18:57:19 2017 (r451560)
+++ head/multimedia/libvpx/Makefile Sun Oct 8 18:57:28 2017 (r451561)
@@ -51,8 +51,6 @@ ASFLAGS+= ${ASFLAGS_armv7}
OPTIONS_DEFINE= DEBUG MULTIRES POSTPROC RTCPU SHARED SIZE_LIMIT TEST THREADS
OPTIONS_DEFAULT=MULTIRES POSTPROC RTCPU SHARED SIZE_LIMIT THREADS
OPTIONS_EXCLUDE_aarch64=RTCPU
-OPTIONS_EXCLUDE_armv6= RTCPU
-OPTIONS_EXCLUDE_armv7= RTCPU
OPTIONS_SUB= SHARED
DEBUG_CONFIGURE_ON= --enable-debug
Added: head/multimedia/libvpx/files/patch-vpx__ports_arm__cpudetect.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/multimedia/libvpx/files/patch-vpx__ports_arm__cpudetect.c Sun Oct 8 18:57:28 2017 (r451561)
@@ -0,0 +1,60 @@
+--- vpx_ports/arm_cpudetect.c.orig 2017-01-12 20:27:27 UTC
++++ vpx_ports/arm_cpudetect.c
+@@ -147,6 +147,57 @@ int arm_cpu_caps(void) {
+ }
+ return flags & mask;
+ }
++#elif defined(__FreeBSD__)
++
++#if __has_include(<sys/auxv.h>)
++#include <sys/auxv.h>
++#else
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <elf.h>
++#include <unistd.h>
++
++static unsigned long getauxval(unsigned long type) {
++ Elf_Auxinfo auxv[AT_COUNT];
++ size_t len = sizeof(auxv);
++ int mib[] = {
++ CTL_KERN,
++ KERN_PROC,
++ KERN_PROC_AUXV,
++ getpid(),
++ };
++
++ if (sysctl(mib, nitems(mib), auxv, &len, NULL, 0) != -1) {
++ for (size_t i = 0; i < nitems(auxv); i++)
++ if (auxv[i].a_type == (long)type)
++ return auxv[i].a_un.a_val;
++ }
++ return 0;
++}
++#endif
++
++#ifndef AT_HWCAP
++#define AT_HWCAP 25 /* 16 on Linux */
++#endif
++
++#ifndef HWCAP_NEON
++#define HWCAP_NEON (1 << 12)
++#endif
++
++int arm_cpu_caps(void) {
++ int flags;
++ int mask;
++ unsigned long hwcaps;
++ if (!arm_cpu_env_flags(&flags)) {
++ return flags;
++ }
++ mask = arm_cpu_env_mask();
++ hwcaps = getauxval(AT_HWCAP);
++#if HAVE_NEON || HAVE_NEON_ASM
++ if (hwcaps & HWCAP_NEON) flags |= HAS_NEON;
++#endif
++ return flags & mask;
++}
+ #else /* end __linux__ */
+ #error \
+ "--enable-runtime-cpu-detect selected, but no CPU detection method " \
More information about the svn-ports-head
mailing list