Path: blob/main/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c
16125 views
- Implement VSX detection on FreeBSD12--- aom_ports/ppc_cpudetect.c.orig 2018-06-25 14:54:59 UTC3+++ aom_ports/ppc_cpudetect.c4@@ -9,12 +9,6 @@5* PATENTS file, you can obtain it at www.aomedia.org/license/patent.6*/78-#include <fcntl.h>9-#include <unistd.h>10-#include <stdint.h>11-#include <asm/cputable.h>12-#include <linux/auxvec.h>13-14#include "config/aom_config.h"1516#include "aom_ports/ppc.h"17@@ -37,6 +31,13 @@ static int cpu_env_mask(void) {18return env && *env ? (int)strtol(env, NULL, 0) : ~0;19}2021+#if defined(__linux__)22+#include <fcntl.h>23+#include <unistd.h>24+#include <stdint.h>25+#include <asm/cputable.h>26+#include <linux/auxvec.h>27+28int ppc_simd_caps(void) {29int flags;30int mask;31@@ -75,6 +76,44 @@ out_close:32close(fd);33return flags & mask;34}35+#elif defined(__FreeBSD__)36+#if __FreeBSD__ < 1237+#include <sys/types.h>38+#include <sys/sysctl.h>39+#else40+#include <sys/auxv.h>41+#endif42+#include <machine/cpu.h>43+44+int ppc_simd_caps(void) {45+ int flags;46+ int mask;47+ u_long hwcap = 0;48+49+ // If AOM_SIMD_CAPS is set then allow only those capabilities.50+ if (!cpu_env_flags(&flags)) {51+ return flags;52+ }53+54+ mask = cpu_env_mask();55+56+#if __FreeBSD__ < 1257+ size_t sz = sizeof(hwcap);58+ sysctlbyname("hw.cpu_features", &hwcap, &sz, NULL, 0);59+#else60+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));61+#endif62+#if HAVE_VSX63+ if (hwcap & PPC_FEATURE_HAS_VSX) flags |= HAS_VSX;64+#endif65+66+ return flags & mask;67+}68+#else69+#error \70+ "--enable-runtime-cpu-detect selected, but no CPU detection method " \71+"available for your platform. Reconfigure with --disable-runtime-cpu-detect."72+#endif /* end __FreeBSD__ */73#else74// If there is no RTCD the function pointers are not used and can not be75// changed.767778