forked from enlightenment/efl
Generic runtime cpu feature testing. This is not used much yet, and shouldn't
break anything. Please review and shout if you see problems. SVN revision: 6761
This commit is contained in:
parent
0ec43a7627
commit
b6ae92d827
|
@ -4,9 +4,101 @@
|
|||
#include "evas_mmx.h"
|
||||
#endif
|
||||
|
||||
static jmp_buf detect_buf;
|
||||
static int cpu_feature_mask = 0;
|
||||
|
||||
void
|
||||
evas_common_cpu_catch_ill(void)
|
||||
{
|
||||
longjmp(detect_buf, 1);
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
void
|
||||
evas_common_cpu_mmx_test(void)
|
||||
{
|
||||
pxor_r2r(mm4, mm4);
|
||||
evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_cpu_sse_test(void)
|
||||
{
|
||||
}
|
||||
#endif /* __i386__ */
|
||||
|
||||
#ifdef __POWERPC__
|
||||
#ifdef __VEC__
|
||||
void
|
||||
evas_common_cpu_altivec_test(void)
|
||||
{
|
||||
vector unsigned int zero;
|
||||
zero = vec_splat_u32(0);
|
||||
}
|
||||
#endif /* __VEC__ */
|
||||
#endif /* __POWERPC__ */
|
||||
|
||||
#ifdef __SPARC__
|
||||
void
|
||||
evas_common_cpu_vis_test(void)
|
||||
{
|
||||
}
|
||||
#endif /* __SPARC__ */
|
||||
|
||||
int
|
||||
evas_common_cpu_feature_test(void (*feature)(void))
|
||||
{
|
||||
int enabled = 1;
|
||||
struct sigaction act, oact;
|
||||
|
||||
sigaction(SIGILL, &act, &oact);
|
||||
if (setjmp(detect_buf))
|
||||
enabled = 0;
|
||||
else
|
||||
feature();
|
||||
sigaction(SIGILL, &oact, NULL);
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void
|
||||
evas_common_cpu_init(void)
|
||||
{
|
||||
int enabled;
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
if (evas_common_cpu_feature_test(evas_common_cpu_mmx_test))
|
||||
cpu_feature_mask |= CPU_FEATURE_MMX;
|
||||
|
||||
if (evas_common_cpu_feature_test(evas_common_cpu_sse_test))
|
||||
cpu_feature_mask |= CPU_FEATURE_SSE;
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
#ifdef __POWERPC__
|
||||
#ifdef __VEC__
|
||||
|
||||
if (evas_common_cpu_feature_test(evas_common_cpu_altivec_test))
|
||||
cpu_feature_mask |= CPU_FEATURE_ALTIVEC;
|
||||
|
||||
#endif /* __VEC__ */
|
||||
#endif /* __POWERPC__ */
|
||||
|
||||
#ifdef __SPARC__
|
||||
|
||||
if (evas_common_cpu_feature_test(evas_common_cpu_vis_test))
|
||||
cpu_feature_mask |= CPU_FEATURE_VIS;
|
||||
|
||||
#endif /* __SPARC__ */
|
||||
|
||||
printf("Cpu mask set to %08x\n", cpu_feature_mask);
|
||||
}
|
||||
|
||||
inline int
|
||||
evas_common_cpu_has_feature(unsigned int feature)
|
||||
{
|
||||
return (cpu_feature_mask & feature);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -110,6 +110,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#include <windows.h>
|
||||
|
@ -193,6 +195,16 @@ typedef enum _Convert_Pal_Mode
|
|||
PAL_MODE_LAST
|
||||
} Convert_Pal_Mode;
|
||||
|
||||
typedef enum _CPU_Features
|
||||
{
|
||||
CPU_FEATURE_C = 0,
|
||||
CPU_FEATURE_MMX = (1 << 0),
|
||||
CPU_FEATURE_SSE = (1 << 1),
|
||||
CPU_FEATURE_ALTIVEC = (1 << 2),
|
||||
CPU_FEATURE_VIS = (1 << 3),
|
||||
CPU_FEATURE_VIS2 = (1 << 4)
|
||||
} CPU_Features;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct _Evas_Object_List
|
||||
|
|
Loading…
Reference in New Issue