summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-12-08 04:46:03 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-12-08 04:46:03 +0000
commit3a075988e4abe4bc4d4f3fca5f97f7c55420433d (patch)
tree60946799559dba821d95811f3ff1aeceeff3651a /src/lib/evas
parent55854e9582ac2fdd6bf6a8a142668ee1c8cbded8 (diff)
evas cpu - just rely on eina cpu entirely to avboid feature dups
so evas cpu used to be the thing then eina cpu came and did the same and evas cpu optionalyl could lsit on top... just move it all to eina cpu so one central place does this and evas_cpu is purely a compat wrapper.
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/common/evas_cpu.c244
1 files changed, 7 insertions, 237 deletions
diff --git a/src/lib/evas/common/evas_cpu.c b/src/lib/evas/common/evas_cpu.c
index d9f5c015ee..a91ffe6930 100644
--- a/src/lib/evas/common/evas_cpu.c
+++ b/src/lib/evas/common/evas_cpu.c
@@ -1,193 +1,13 @@
1#include "evas_common_private.h" 1#include "evas_common_private.h"
2#ifdef BUILD_NEON
3# ifdef BUILD_NEON_INTRINSICS
4# include <arm_neon.h>
5# endif
6#endif
7 2
8static int cpu_feature_mask = 0; 3static int cpu_feature_mask = 0;
9 4
10#ifdef BUILD_ALTIVEC
11# ifdef __POWERPC__
12# ifdef __VEC__
13# define NEED_FEATURE_TEST
14# endif
15# endif
16#endif
17
18#ifdef __SPARC__
19# define NEED_FEATURE_TEST
20#endif
21
22#if defined(__ARM_ARCH__)
23# ifdef BUILD_NEON
24# define NEED_FEATURE_TEST
25# endif
26#endif
27
28#if defined(__aarch64__)
29# ifdef BUILD_NEON
30# define NEED_FEATURE_TEST
31# endif
32#endif
33
34#ifdef NEED_FEATURE_TEST
35# ifdef HAVE_SIGLONGJMP
36# include <signal.h>
37# include <setjmp.h>
38# include <errno.h>
39
40static sigjmp_buf detect_buf;
41static void evas_common_cpu_catch_ill(int sig);
42static void evas_common_cpu_catch_segv(int sig);
43
44static void
45evas_common_cpu_catch_ill(int sig EINA_UNUSED)
46{
47 siglongjmp(detect_buf, 1);
48}
49
50static void
51evas_common_cpu_catch_segv(int sig EINA_UNUSED)
52{
53 siglongjmp(detect_buf, 1);
54}
55# endif
56
57# ifdef BUILD_ALTIVEC
58void
59evas_common_cpu_altivec_test(void)
60{
61# ifdef __POWERPC__
62# ifdef __VEC__
63 vector unsigned int zero;
64
65 zero = vec_splat_u32(0);
66# endif /* __VEC__ */
67# endif /* __POWERPC__ */
68}
69# endif /* BUILD_ALTIVEC */
70
71void
72evas_common_cpu_neon_test(void)
73{
74//#if defined(__ARM_ARCH__) && (__ARM_ARCH__ >= 70)
75# ifdef BUILD_NEON
76# ifdef BUILD_NEON_INTRINSICS
77 volatile uint32x4_t temp = vdupq_n_u32(0x1);
78 vaddq_u32(temp, temp);
79# else
80 asm volatile (
81 ".fpu neon \n\t"
82 "vqadd.u8 d0, d1, d0\n"
83 : /* Out */
84 : /* In */
85 : /* Clobbered */
86 "d0", "d1"
87 );
88# endif
89# endif
90//#endif
91}
92
93void
94evas_common_cpu_vis_test(void)
95{
96# ifdef __SPARC__
97# endif /* __SPARC__ */
98}
99#endif /* NEED_FEATURE_TEST */
100
101
102#if defined(BUILD_MMX) || defined(BUILD_SSE3)
103# define NEED_CPU_CHECK
104#endif
105
106#ifdef NEED_FEATURE_TEST
107# ifndef HAVE_SIGLONGJMP
108# undef NEED_CPU_CHECK
109# define NEED_CPU_CHECK
110# endif
111#endif
112
113#ifdef NEED_CPU_CHECK
114static Eina_Bool 5static Eina_Bool
115_cpu_check(Eina_Cpu_Features f) 6_cpu_check(Eina_Cpu_Features f)
116{ 7{
117 Eina_Cpu_Features features; 8 Eina_Cpu_Features features = eina_cpu_features_get();
118
119 features = eina_cpu_features_get();
120 return (features & f) == f; 9 return (features & f) == f;
121} 10}
122#endif
123
124#if defined(__aarch64__)
125void
126evas_common_cpu_sve_test(void)
127{
128 volatile int result = 123;
129 asm("movz %w[res], #10" : [res] "=r" (result));
130}
131#endif
132
133#ifdef NEED_FEATURE_TEST
134int
135evas_common_cpu_feature_test(void (*feature)(void))
136{
137# ifdef HAVE_SIGLONGJMP
138 int enabled = 1;
139 struct sigaction act, oact, oact2;
140
141 act.sa_handler = evas_common_cpu_catch_ill;
142 act.sa_flags = SA_RESTART;
143 sigemptyset(&act.sa_mask);
144 sigaction(SIGILL, &act, &oact);
145
146 act.sa_handler = evas_common_cpu_catch_segv;
147 act.sa_flags = SA_RESTART;
148 sigemptyset(&act.sa_mask);
149 sigaction(SIGSEGV, &act, &oact2);
150
151 if (sigsetjmp(detect_buf, 1))
152 {
153 sigaction(SIGILL, &oact, NULL);
154 sigaction(SIGSEGV, &oact2, NULL);
155 return 0;
156 }
157
158 feature();
159
160 sigaction(SIGILL, &oact, NULL);
161 sigaction(SIGSEGV, &oact2, NULL);
162 return enabled;
163# else
164# ifdef BUILD_MMX
165 if (feature == evas_common_cpu_mmx_test)
166 return _cpu_check(EINA_CPU_MMX);
167 /* no mmx2 support in eina */
168 if (feature == evas_common_cpu_sse_test)
169 return _cpu_check(EINA_CPU_SSE);
170# endif
171# ifdef BUILD_SSE3
172 if (feature == evas_common_cpu_sse3_test)
173 return _cpu_check(EINA_CPU_SSE3);
174# endif
175# ifdef BUILD_ALTIVEC
176 if (feature == evas_common_cpu_altivec_test)
177 return _cpu_check(CPU_FEATURE_ALTIVEC);
178# endif
179# ifdef BUILD_NEON
180 if (feature == evas_common_cpu_neon_test)
181 return _cpu_check(EINA_CPU_NEON);
182# endif
183# if defined(__aarch64__)
184 if (feature == evas_common_cpu_sve_test)
185 return _cpu_check(EINA_CPU_SVE);
186# endif
187 return 0;
188# endif
189}
190#endif
191 11
192EAPI void 12EAPI void
193evas_common_cpu_init(void) 13evas_common_cpu_init(void)
@@ -218,71 +38,32 @@ evas_common_cpu_init(void)
218#endif /* BUILD_MMX */ 38#endif /* BUILD_MMX */
219 39
220#ifdef BUILD_ALTIVEC 40#ifdef BUILD_ALTIVEC
221# ifdef __POWERPC__
222# ifdef __VEC__
223 if (getenv("EVAS_CPU_NO_ALTIVEC")) 41 if (getenv("EVAS_CPU_NO_ALTIVEC"))
224 cpu_feature_mask &= ~CPU_FEATURE_ALTIVEC; 42 cpu_feature_mask &= ~CPU_FEATURE_ALTIVEC;
225 else 43 else
226 { 44 cpu_feature_mask |= _cpu_check(CPU_FEATURE_ALTIVEC) * CPU_FEATURE_ALTIVEC;
227 cpu_feature_mask |= CPU_FEATURE_ALTIVEC *
228 evas_common_cpu_feature_test(evas_common_cpu_altivec_test);
229 evas_common_cpu_end_opt();
230 }
231# endif /* __VEC__ */
232# endif /* __POWERPC__ */
233#endif /* BUILD_ALTIVEC */ 45#endif /* BUILD_ALTIVEC */
234 46
235#ifdef __SPARC__
236 if (getenv("EVAS_CPU_NO_VIS"))
237 cpu_feature_mask &= ~CPU_FEATURE_VIS;
238 else
239 {
240 cpu_feature_mask |= CPU_FEATURE_VIS *
241 evas_common_cpu_feature_test(evas_common_cpu_vis_test);
242 evas_common_cpu_end_opt();
243 }
244#endif /* __SPARC__ */
245
246#if defined(__ARM_ARCH__) 47#if defined(__ARM_ARCH__)
247# ifdef BUILD_NEON 48# ifdef BUILD_NEON
248 if (getenv("EVAS_CPU_NO_NEON")) 49 if (getenv("EVAS_CPU_NO_NEON"))
249 cpu_feature_mask &= ~CPU_FEATURE_NEON; 50 cpu_feature_mask &= ~CPU_FEATURE_NEON;
250 else 51 else
251 { 52 cpu_feature_mask |= _cpu_check(EINA_CPU_NEON) * CPU_FEATURE_NEON;
252 /* On linux eina_cpu sets this up with getauxval() */
253# if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
254 cpu_feature_mask |= CPU_FEATURE_NEON *
255 !!(eina_cpu_features_get() & EINA_CPU_NEON);
256# else
257 cpu_feature_mask |= CPU_FEATURE_NEON *
258 evas_common_cpu_feature_test(evas_common_cpu_neon_test);
259 evas_common_cpu_end_opt();
260# endif
261 }
262# endif 53# endif
263#endif 54#endif
264 55
265#if defined(__aarch64__) 56#if defined(__aarch64__)
57# ifdef BUILD_NEON
266 if (getenv("EVAS_CPU_NO_NEON")) 58 if (getenv("EVAS_CPU_NO_NEON"))
267 cpu_feature_mask &= ~CPU_FEATURE_NEON; 59 cpu_feature_mask &= ~CPU_FEATURE_NEON;
268 else 60 else
269 cpu_feature_mask |= CPU_FEATURE_NEON; 61 cpu_feature_mask |= CPU_FEATURE_NEON;
270#endif 62# endif
271
272#if defined(__aarch64__)
273 if (getenv("EVAS_CPU_NO_SVE")) 63 if (getenv("EVAS_CPU_NO_SVE"))
274 cpu_feature_mask &= ~CPU_FEATURE_SVE; 64 cpu_feature_mask &= ~CPU_FEATURE_SVE;
275 else 65 else
276 { 66 cpu_feature_mask |= _cpu_check(EINA_CPU_SVE) * CPU_FEATURE_SVE;
277# if defined(HAVE_SYS_AUXV_H) && defined(HAVE_ASM_HWCAP_H) && defined(__arm__) && defined(__linux__)
278 cpu_feature_mask |= CPU_FEATURE_SVE *
279 !!(eina_cpu_features_get() & EINA_CPU_SVE);
280# else
281 cpu_feature_mask |= CPU_FEATURE_SVE *
282 evas_common_cpu_feature_test(evas_common_cpu_sve_test);
283 evas_common_cpu_end_opt();
284# endif
285 }
286#endif 67#endif
287} 68}
288 69
@@ -296,17 +77,6 @@ int
296evas_common_cpu_have_cpuid(void) 77evas_common_cpu_have_cpuid(void)
297{ 78{
298 return 0; 79 return 0;
299/*
300#ifdef BUILD_MMX
301 unsigned int have_cpu_id;
302
303 have_cpu_id = 0;
304 have_cpuid(have_cpu_id);
305 return have_cpu_id;
306#else
307 return 0;
308#endif
309 */
310} 80}
311 81
312EAPI void 82EAPI void
@@ -333,7 +103,7 @@ evas_common_cpu_end_opt(void)
333{ 103{
334 if (cpu_feature_mask & (CPU_FEATURE_MMX | CPU_FEATURE_MMX2)) 104 if (cpu_feature_mask & (CPU_FEATURE_MMX | CPU_FEATURE_MMX2))
335 { 105 {
336 emms(); 106 emms();
337 } 107 }
338} 108}
339#else 109#else