Index: head/multimedia/aom/files/patch-aom__ports_arm__cpudetect.c =================================================================== --- head/multimedia/aom/files/patch-aom__ports_arm__cpudetect.c (revision 486563) +++ head/multimedia/aom/files/patch-aom__ports_arm__cpudetect.c (revision 486564) @@ -1,77 +1,73 @@ - Assume NEON is enabled on aarch64 - Implement NEON runtime detection on FreeBSD --- aom_ports/arm_cpudetect.c.orig 2018-11-16 20:24:20 UTC +++ aom_ports/arm_cpudetect.c @@ -38,7 +38,7 @@ static int arm_cpu_env_mask(void) { return env && *env ? (int)strtol(env, NULL, 0) : ~0; } -#if !CONFIG_RUNTIME_CPU_DETECT +#if !CONFIG_RUNTIME_CPU_DETECT || defined(__ARM_NEON) int aom_arm_cpu_caps(void) { /* This function should actually be a no-op. There is no way to adjust any of -@@ -143,7 +143,61 @@ int aom_arm_cpu_caps(void) { +@@ -143,7 +143,57 @@ int aom_arm_cpu_caps(void) { } return flags & mask; } -#else /* end __linux__ */ +#elif defined(__FreeBSD__) + -+#if 0 // __has_include() -+#include -+#else ++#if __FreeBSD__ < 12 +#include +#include +#include +#include +#include + +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 ((unsigned long)auxv[i].a_type == type) + return auxv[i].a_un.a_val; + + errno = ENOENT; + } + return 0; +} ++#else ++#include +#endif + -+#ifndef AT_HWCAP -+#define AT_HWCAP 25 /* 16 on Linux */ -+#endif -+ -+#ifndef HWCAP_NEON -+#define HWCAP_NEON (1 << 12) -+#endif -+ +int aom_arm_cpu_caps(void) { + int flags; + int mask; -+ unsigned long hwcaps; ++ u_long hwcaps = 0; + if (!arm_cpu_env_flags(&flags)) { + return flags; + } + mask = arm_cpu_env_mask(); ++#if __FreeBSD__ < 12 + hwcaps = getauxval(AT_HWCAP); ++#else ++ elf_aux_info(AT_HWCAP, &hwcaps, sizeof(hwcaps)); ++#endif +#if HAVE_NEON + if (hwcaps & HWCAP_NEON) flags |= HAS_NEON; +#endif + return flags & mask; +} -+#else /* end __FreeBSD__ */ ++#else /* end __FreeBSD__ */ #error \ "--enable-runtime-cpu-detect selected, but no CPU detection method " \ "available for your platform. Reconfigure with --disable-runtime-cpu-detect." Index: head/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c =================================================================== --- head/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c (revision 486563) +++ head/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c (revision 486564) @@ -1,68 +1,76 @@ - Implement VSX detection on FreeBSD --- aom_ports/ppc_cpudetect.c.orig 2018-06-25 14:54:59 UTC +++ aom_ports/ppc_cpudetect.c @@ -9,12 +9,6 @@ * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ -#include -#include -#include -#include -#include - #include "config/aom_config.h" #include "aom_ports/ppc.h" @@ -37,6 +31,13 @@ static int cpu_env_mask(void) { return env && *env ? (int)strtol(env, NULL, 0) : ~0; } +#if defined(__linux__) +#include +#include +#include +#include +#include + int ppc_simd_caps(void) { int flags; int mask; -@@ -75,6 +76,36 @@ out_close: +@@ -75,6 +76,44 @@ out_close: close(fd); return flags & mask; } +#elif defined(__FreeBSD__) ++#if __FreeBSD__ < 12 +#include +#include ++#else ++#include ++#endif +#include + +int ppc_simd_caps(void) { + int flags; + int mask; + u_long cpu_features = 0; -+ size_t sz = sizeof(cpu_features); + + // If AOM_SIMD_CAPS is set then allow only those capabilities. + if (!cpu_env_flags(&flags)) { + return flags; + } + + mask = cpu_env_mask(); + ++#if __FreeBSD__ < 12 ++ size_t sz = sizeof(cpu_features); + sysctlbyname("hw.cpu_features", &cpu_features, &sz, NULL, 0); ++#else ++ elf_aux_info(AT_HWCAP, &cpu_features, sizeof(cpu_features)); ++#endif +#if HAVE_VSX + if (cpu_features & PPC_FEATURE_HAS_VSX) flags |= HAS_VSX; +#endif + + return flags & mask; +} +#else +#error \ + "--enable-runtime-cpu-detect selected, but no CPU detection method " \ +"available for your platform. Reconfigure with --disable-runtime-cpu-detect." +#endif /* end __FreeBSD__ */ #else // If there is no RTCD the function pointers are not used and can not be // changed. Index: head/multimedia/libvpx/files/patch-vpx__ports_arm__cpudetect.c =================================================================== --- head/multimedia/libvpx/files/patch-vpx__ports_arm__cpudetect.c (revision 486563) +++ head/multimedia/libvpx/files/patch-vpx__ports_arm__cpudetect.c (revision 486564) @@ -1,63 +1,61 @@ --- vpx_ports/arm_cpudetect.c.orig 2017-01-12 20:27:27 UTC +++ vpx_ports/arm_cpudetect.c -@@ -147,6 +147,60 @@ int arm_cpu_caps(void) { +@@ -147,7 +147,57 @@ int arm_cpu_caps(void) { } return flags & mask; } +-#else /* end __linux__ */ +#elif defined(__FreeBSD__) + -+#if 0 // __has_include() -+#include -+#else ++#if __FreeBSD__ < 12 +#include +#include +#include +#include +#include + +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 ((unsigned long)auxv[i].a_type == type) + return auxv[i].a_un.a_val; + + errno = ENOENT; + } + return 0; +} ++#else ++#include +#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; ++ u_long hwcaps = 0; + if (!arm_cpu_env_flags(&flags)) { + return flags; + } + mask = arm_cpu_env_mask(); ++#if __FreeBSD__ < 12 + hwcaps = getauxval(AT_HWCAP); ++#else ++ elf_aux_info(AT_HWCAP, &hwcaps, sizeof(hwcaps)); ++#endif +#if HAVE_NEON || HAVE_NEON_ASM + if (hwcaps & HWCAP_NEON) flags |= HAS_NEON; +#endif + return flags & mask; +} - #else /* end __linux__ */ ++#else /* end __FreeBSD__ */ #error \ "--enable-runtime-cpu-detect selected, but no CPU detection method " \ + "available for your platform. Reconfigure with --disable-runtime-cpu-detect." Index: head/multimedia/libvpx/files/patch-vpx__ports_ppc__cpudetect.c =================================================================== --- head/multimedia/libvpx/files/patch-vpx__ports_ppc__cpudetect.c (revision 486563) +++ head/multimedia/libvpx/files/patch-vpx__ports_ppc__cpudetect.c (revision 486564) @@ -1,66 +1,74 @@ --- vpx_ports/ppc_cpudetect.c.orig 2018-01-24 22:25:44 UTC +++ vpx_ports/ppc_cpudetect.c @@ -8,12 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include -#include -#include -#include - #include "./vpx_config.h" #include "vpx_ports/ppc.h" @@ -35,6 +29,13 @@ static int cpu_env_mask(void) { return env && *env ? (int)strtol(env, NULL, 0) : ~0; } +#if defined(__linux__) +#include +#include +#include +#include +#include + int ppc_simd_caps(void) { int flags; int mask; -@@ -73,6 +74,36 @@ out_close: +@@ -73,6 +74,44 @@ out_close: close(fd); return flags & mask; } +#elif defined(__FreeBSD__) ++#if __FreeBSD__ < 12 +#include +#include ++#else ++#include ++#endif +#include + +int ppc_simd_caps(void) { + int flags; + int mask; + u_long cpu_features = 0; -+ size_t sz = sizeof(cpu_features); + + // If VPX_SIMD_CAPS is set then allow only those capabilities. + if (!cpu_env_flags(&flags)) { + return flags; + } + + mask = cpu_env_mask(); + ++#if __FreeBSD__ < 12 ++ size_t sz = sizeof(cpu_features); + sysctlbyname("hw.cpu_features", &cpu_features, &sz, NULL, 0); ++#else ++ elf_aux_info(AT_HWCAP, &cpu_features, sizeof(cpu_features)); ++#endif +#if HAVE_VSX + if (cpu_features & PPC_FEATURE_HAS_VSX) flags |= HAS_VSX; +#endif + + return flags & mask; +} +#else +#error \ + "--enable-runtime-cpu-detect selected, but no CPU detection method " \ +"available for your platform. Reconfigure with --disable-runtime-cpu-detect." -+#endif /* end __linux__ */ ++#endif /* end __FreeBSD__ */ #else // If there is no RTCD the function pointers are not used and can not be // changed.