diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/evas/src/lib/engines/common/evas_cpu.c | 274 |
1 files changed, 0 insertions, 274 deletions
diff --git a/libraries/evas/src/lib/engines/common/evas_cpu.c b/libraries/evas/src/lib/engines/common/evas_cpu.c deleted file mode 100644 index fe90c5b..0000000 --- a/libraries/evas/src/lib/engines/common/evas_cpu.c +++ /dev/null | |||
@@ -1,274 +0,0 @@ | |||
1 | #include "evas_common.h" | ||
2 | #if defined BUILD_MMX || defined BUILD_SSE | ||
3 | #include "evas_mmx.h" | ||
4 | #endif | ||
5 | |||
6 | #if defined BUILD_SSE3 | ||
7 | #include <immintrin.h> | ||
8 | #endif | ||
9 | |||
10 | #if defined (HAVE_STRUCT_SIGACTION) && defined (HAVE_SIGLONGJMP) | ||
11 | #include <signal.h> | ||
12 | #include <setjmp.h> | ||
13 | #include <errno.h> | ||
14 | |||
15 | static sigjmp_buf detect_buf; | ||
16 | #endif | ||
17 | |||
18 | static int cpu_feature_mask = 0; | ||
19 | |||
20 | #if defined (HAVE_STRUCT_SIGACTION) && defined (HAVE_SIGLONGJMP) | ||
21 | static void evas_common_cpu_catch_ill(int sig); | ||
22 | static void evas_common_cpu_catch_segv(int sig); | ||
23 | |||
24 | static void | ||
25 | evas_common_cpu_catch_ill(int sig __UNUSED__) | ||
26 | { | ||
27 | siglongjmp(detect_buf, 1); | ||
28 | } | ||
29 | |||
30 | static void | ||
31 | evas_common_cpu_catch_segv(int sig __UNUSED__) | ||
32 | { | ||
33 | siglongjmp(detect_buf, 1); | ||
34 | } | ||
35 | #endif | ||
36 | |||
37 | void | ||
38 | evas_common_cpu_mmx_test(void) | ||
39 | { | ||
40 | #ifdef BUILD_MMX | ||
41 | pxor_r2r(mm4, mm4); | ||
42 | #endif | ||
43 | } | ||
44 | |||
45 | void | ||
46 | evas_common_cpu_mmx2_test(void) | ||
47 | { | ||
48 | #ifdef BUILD_MMX | ||
49 | char data[16]; | ||
50 | |||
51 | data[0] = 0; | ||
52 | mmx_r2m(movntq, mm0, data); | ||
53 | data[0] = 0; | ||
54 | #endif | ||
55 | } | ||
56 | |||
57 | void | ||
58 | evas_common_cpu_sse_test(void) | ||
59 | { | ||
60 | #ifdef BUILD_SSE | ||
61 | int blah[16]; | ||
62 | |||
63 | movntq_r2m(mm0, blah); | ||
64 | #endif | ||
65 | } | ||
66 | |||
67 | void evas_common_op_sse3_test(void); | ||
68 | |||
69 | void | ||
70 | evas_common_cpu_sse3_test(void) | ||
71 | { | ||
72 | #ifdef BUILD_SSE3 | ||
73 | evas_common_op_sse3_test(); | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | #ifdef BUILD_ALTIVEC | ||
78 | void | ||
79 | evas_common_cpu_altivec_test(void) | ||
80 | { | ||
81 | #ifdef __POWERPC__ | ||
82 | #ifdef __VEC__ | ||
83 | vector unsigned int zero; | ||
84 | |||
85 | zero = vec_splat_u32(0); | ||
86 | #endif /* __VEC__ */ | ||
87 | #endif /* __POWERPC__ */ | ||
88 | } | ||
89 | #endif /* BUILD_ALTIVEC */ | ||
90 | |||
91 | void | ||
92 | evas_common_cpu_neon_test(void) | ||
93 | { | ||
94 | //#if defined(__ARM_ARCH__) && (__ARM_ARCH__ >= 70) | ||
95 | #ifdef BUILD_NEON | ||
96 | asm volatile ( | ||
97 | ".fpu neon \n\t" | ||
98 | "vqadd.u8 d0, d1, d0\n" | ||
99 | : /* Out */ | ||
100 | : /* In */ | ||
101 | : /* Clobbered */ | ||
102 | "d0", "d1" | ||
103 | ); | ||
104 | #endif | ||
105 | //#endif | ||
106 | } | ||
107 | |||
108 | void | ||
109 | evas_common_cpu_vis_test(void) | ||
110 | { | ||
111 | #ifdef __SPARC__ | ||
112 | #endif /* __SPARC__ */ | ||
113 | } | ||
114 | |||
115 | int | ||
116 | evas_common_cpu_feature_test(void (*feature)(void)) | ||
117 | { | ||
118 | #if defined (HAVE_STRUCT_SIGACTION) && defined (HAVE_SIGLONGJMP) | ||
119 | int enabled = 1; | ||
120 | struct sigaction act, oact, oact2; | ||
121 | |||
122 | act.sa_handler = evas_common_cpu_catch_ill; | ||
123 | act.sa_flags = SA_RESTART; | ||
124 | sigemptyset(&act.sa_mask); | ||
125 | sigaction(SIGILL, &act, &oact); | ||
126 | |||
127 | act.sa_handler = evas_common_cpu_catch_segv; | ||
128 | act.sa_flags = SA_RESTART; | ||
129 | sigemptyset(&act.sa_mask); | ||
130 | sigaction(SIGSEGV, &act, &oact2); | ||
131 | |||
132 | if (sigsetjmp(detect_buf, 1)) | ||
133 | { | ||
134 | sigaction(SIGILL, &oact, NULL); | ||
135 | sigaction(SIGSEGV, &oact2, NULL); | ||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | feature(); | ||
140 | |||
141 | sigaction(SIGILL, &oact, NULL); | ||
142 | sigaction(SIGSEGV, &oact2, NULL); | ||
143 | return enabled; | ||
144 | #else | ||
145 | return 0; | ||
146 | #endif | ||
147 | } | ||
148 | |||
149 | EAPI void | ||
150 | evas_common_cpu_init(void) | ||
151 | { | ||
152 | static int called = 0; | ||
153 | |||
154 | if (called) return; | ||
155 | called = 1; | ||
156 | #ifdef BUILD_MMX | ||
157 | cpu_feature_mask |= CPU_FEATURE_MMX * | ||
158 | evas_common_cpu_feature_test(evas_common_cpu_mmx_test); | ||
159 | evas_common_cpu_end_opt(); | ||
160 | if (getenv("EVAS_CPU_NO_MMX")) | ||
161 | cpu_feature_mask &= ~CPU_FEATURE_MMX; | ||
162 | cpu_feature_mask |= CPU_FEATURE_MMX2 * | ||
163 | evas_common_cpu_feature_test(evas_common_cpu_mmx2_test); | ||
164 | evas_common_cpu_end_opt(); | ||
165 | if (getenv("EVAS_CPU_NO_MMX2")) | ||
166 | cpu_feature_mask &= ~CPU_FEATURE_MMX2; | ||
167 | #ifdef BUILD_SSE | ||
168 | cpu_feature_mask |= CPU_FEATURE_SSE * | ||
169 | evas_common_cpu_feature_test(evas_common_cpu_sse_test); | ||
170 | evas_common_cpu_end_opt(); | ||
171 | if (getenv("EVAS_CPU_NO_SSE")) | ||
172 | cpu_feature_mask &= ~CPU_FEATURE_SSE; | ||
173 | #ifdef BUILD_SSE3 | ||
174 | cpu_feature_mask |= CPU_FEATURE_SSE3 * | ||
175 | evas_common_cpu_feature_test(evas_common_cpu_sse3_test); | ||
176 | evas_common_cpu_end_opt(); | ||
177 | if (getenv("EVAS_CPU_NO_SSE3")) | ||
178 | cpu_feature_mask &= ~CPU_FEATURE_SSE3; | ||
179 | #endif /* BUILD_SSE3 */ | ||
180 | #endif /* BUILD_SSE */ | ||
181 | #endif /* BUILD_MMX */ | ||
182 | #ifdef BUILD_ALTIVEC | ||
183 | #ifdef __POWERPC__ | ||
184 | #ifdef __VEC__ | ||
185 | cpu_feature_mask |= CPU_FEATURE_ALTIVEC * | ||
186 | evas_common_cpu_feature_test(evas_common_cpu_altivec_test); | ||
187 | evas_common_cpu_end_opt(); | ||
188 | if (getenv("EVAS_CPU_NO_ALTIVEC")) | ||
189 | cpu_feature_mask &= ~CPU_FEATURE_ALTIVEC; | ||
190 | #endif /* __VEC__ */ | ||
191 | #endif /* __POWERPC__ */ | ||
192 | #endif /* BUILD_ALTIVEC */ | ||
193 | #ifdef __SPARC__ | ||
194 | cpu_feature_mask |= CPU_FEATURE_VIS * | ||
195 | evas_common_cpu_feature_test(evas_common_cpu_vis_test); | ||
196 | evas_common_cpu_end_opt(); | ||
197 | if (getenv("EVAS_CPU_NO_VIS")) | ||
198 | cpu_feature_mask &= ~CPU_FEATURE_VIS; | ||
199 | #endif /* __SPARC__ */ | ||
200 | #if defined(__ARM_ARCH__) | ||
201 | #ifdef BUILD_NEON | ||
202 | cpu_feature_mask |= CPU_FEATURE_NEON * | ||
203 | evas_common_cpu_feature_test(evas_common_cpu_neon_test); | ||
204 | evas_common_cpu_end_opt(); | ||
205 | if (getenv("EVAS_CPU_NO_NEON")) | ||
206 | cpu_feature_mask &= ~CPU_FEATURE_NEON; | ||
207 | #endif | ||
208 | #endif | ||
209 | } | ||
210 | |||
211 | int | ||
212 | evas_common_cpu_has_feature(unsigned int feature) | ||
213 | { | ||
214 | return (cpu_feature_mask & feature); | ||
215 | } | ||
216 | |||
217 | int | ||
218 | evas_common_cpu_have_cpuid(void) | ||
219 | { | ||
220 | return 0; | ||
221 | /* | ||
222 | #ifdef BUILD_MMX | ||
223 | unsigned int have_cpu_id; | ||
224 | |||
225 | have_cpu_id = 0; | ||
226 | have_cpuid(have_cpu_id); | ||
227 | return have_cpu_id; | ||
228 | #else | ||
229 | return 0; | ||
230 | #endif | ||
231 | */ | ||
232 | } | ||
233 | |||
234 | EAPI void | ||
235 | evas_common_cpu_can_do(int *mmx, int *sse, int *sse2) | ||
236 | { | ||
237 | static int do_mmx = 0, do_sse = 0, do_sse2 = 0, done = 0; | ||
238 | |||
239 | if (!done) | ||
240 | { | ||
241 | # ifdef HARD_CODED_P3 | ||
242 | cpu_feature_mask |= CPU_FEATURE_MMX; | ||
243 | cpu_feature_mask |= CPU_FEATURE_SSE; | ||
244 | #endif | ||
245 | #ifdef HARD_CODED_P2 | ||
246 | cpu_feature_mask |= CPU_FEATURE_MMX; | ||
247 | #endif | ||
248 | if (cpu_feature_mask & CPU_FEATURE_MMX) do_mmx = 1; | ||
249 | if (cpu_feature_mask & CPU_FEATURE_MMX2) do_sse = 1; | ||
250 | if (cpu_feature_mask & CPU_FEATURE_SSE) do_sse = 1; | ||
251 | } | ||
252 | // INF("%i %i %i", do_mmx, do_sse, do_sse2); | ||
253 | *mmx = do_mmx; | ||
254 | *sse = do_sse; | ||
255 | *sse2 = do_sse2; | ||
256 | done = 1; | ||
257 | } | ||
258 | |||
259 | #ifdef BUILD_MMX | ||
260 | EAPI void | ||
261 | evas_common_cpu_end_opt(void) | ||
262 | { | ||
263 | if (cpu_feature_mask & | ||
264 | (CPU_FEATURE_MMX | CPU_FEATURE_MMX2)) | ||
265 | { | ||
266 | emms(); | ||
267 | } | ||
268 | } | ||
269 | #else | ||
270 | EAPI void | ||
271 | evas_common_cpu_end_opt(void) | ||
272 | { | ||
273 | } | ||
274 | #endif | ||