Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/multimedia/aom/files/patch-aom__ports_ppc__cpudetect.c
16461 views
1
- Implement VSX detection on FreeBSD
2
3
--- aom_ports/ppc_cpudetect.c.orig 2021-07-20 22:23:15 UTC
4
+++ aom_ports/ppc_cpudetect.c
5
@@ -9,12 +9,6 @@
6
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
7
*/
8
9
-#include <fcntl.h>
10
-#include <unistd.h>
11
-#include <stdint.h>
12
-#include <asm/cputable.h>
13
-#include <linux/auxvec.h>
14
-
15
#include "config/aom_config.h"
16
17
#include "aom_ports/ppc.h"
18
@@ -37,6 +31,13 @@ static int cpu_env_mask(void) {
19
return env && *env ? (int)strtol(env, NULL, 0) : ~0;
20
}
21
22
+#if defined(__linux__)
23
+#include <fcntl.h>
24
+#include <unistd.h>
25
+#include <stdint.h>
26
+#include <asm/cputable.h>
27
+#include <linux/auxvec.h>
28
+
29
int ppc_simd_caps(void) {
30
int flags;
31
int mask;
32
@@ -75,6 +76,34 @@ out_close:
33
close(fd);
34
return flags & mask;
35
}
36
+#elif defined(__FreeBSD__)
37
+#include <sys/auxv.h>
38
+#include <machine/cpu.h>
39
+
40
+int ppc_simd_caps(void) {
41
+ int flags;
42
+ int mask;
43
+ u_long hwcap = 0;
44
+
45
+ // If AOM_SIMD_CAPS is set then allow only those capabilities.
46
+ if (!cpu_env_flags(&flags)) {
47
+ return flags;
48
+ }
49
+
50
+ mask = cpu_env_mask();
51
+
52
+ elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
53
+#if HAVE_VSX
54
+ if (hwcap & PPC_FEATURE_HAS_VSX) flags |= HAS_VSX;
55
+#endif
56
+
57
+ return flags & mask;
58
+}
59
+#else
60
+#error \
61
+ "--enable-runtime-cpu-detect selected, but no CPU detection method " \
62
+"available for your platform. Reconfigure with --disable-runtime-cpu-detect."
63
+#endif /* end __FreeBSD__ */
64
#else
65
// If there is no RTCD the function pointers are not used and can not be
66
// changed.
67
68