Path: blob/main/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c
16461 views
- Implement VSX detection on FreeBSD12--- aom_ports/ppc_cpudetect.c.orig 2021-07-20 22:23:15 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,34 @@ out_close:32close(fd);33return flags & mask;34}35+#elif defined(__FreeBSD__)36+#include <sys/auxv.h>37+#include <machine/cpu.h>38+39+int ppc_simd_caps(void) {40+ int flags;41+ int mask;42+ u_long hwcap = 0;43+44+ // If AOM_SIMD_CAPS is set then allow only those capabilities.45+ if (!cpu_env_flags(&flags)) {46+ return flags;47+ }48+49+ mask = cpu_env_mask();50+51+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));52+#if HAVE_VSX53+ if (hwcap & PPC_FEATURE_HAS_VSX) flags |= HAS_VSX;54+#endif55+56+ return flags & mask;57+}58+#else59+#error \60+ "--enable-runtime-cpu-detect selected, but no CPU detection method " \61+"available for your platform. Reconfigure with --disable-runtime-cpu-detect."62+#endif /* end __FreeBSD__ */63#else64// If there is no RTCD the function pointers are not used and can not be65// changed.666768