Line 0
Link Here
|
|
|
1 |
--- vpx_ports/ppc_cpudetect.c.orig 2018-01-24 22:25:44 UTC |
2 |
+++ vpx_ports/ppc_cpudetect.c |
3 |
@@ -8,12 +8,6 @@ |
4 |
* be found in the AUTHORS file in the root of the source tree. |
5 |
*/ |
6 |
|
7 |
-#include <fcntl.h> |
8 |
-#include <unistd.h> |
9 |
-#include <stdint.h> |
10 |
-#include <asm/cputable.h> |
11 |
-#include <linux/auxvec.h> |
12 |
- |
13 |
#include "./vpx_config.h" |
14 |
#include "vpx_ports/ppc.h" |
15 |
|
16 |
@@ -35,6 +29,13 @@ static int cpu_env_mask(void) { |
17 |
return env && *env ? (int)strtol(env, NULL, 0) : ~0; |
18 |
} |
19 |
|
20 |
+#if defined(__linux__) |
21 |
+#include <fcntl.h> |
22 |
+#include <unistd.h> |
23 |
+#include <stdint.h> |
24 |
+#include <asm/cputable.h> |
25 |
+#include <linux/auxvec.h> |
26 |
+ |
27 |
int ppc_simd_caps(void) { |
28 |
int flags; |
29 |
int mask; |
30 |
@@ -73,6 +74,36 @@ out_close: |
31 |
close(fd); |
32 |
return flags & mask; |
33 |
} |
34 |
+#elif defined(__FreeBSD__) |
35 |
+#include <sys/types.h> |
36 |
+#include <sys/sysctl.h> |
37 |
+#include <machine/cpu.h> |
38 |
+ |
39 |
+int ppc_simd_caps(void) { |
40 |
+ int flags; |
41 |
+ int mask; |
42 |
+ u_long cpu_features = 0; |
43 |
+ size_t sz = sizeof(cpu_features); |
44 |
+ |
45 |
+ // If VPX_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 |
+ sysctlbyname("hw.cpu_features", &cpu_features, &sz, NULL, 0); |
53 |
+#if HAVE_VSX |
54 |
+ if (cpu_features & 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 __linux__ */ |
64 |
#else |
65 |
// If there is no RTCD the function pointers are not used and can not be |
66 |
// changed. |