evas_cpu: Refactor checks that use eina_cpu_features_get

Summary: Minor code simplification.

Reviewers: devilhorns, zmike

Reviewed By: zmike

Subscribers: cedric, #committers, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6313
This commit is contained in:
Derek Foreman 2018-06-18 15:12:36 -05:00
parent 4a60c60528
commit 1d8a93aa78
1 changed files with 12 additions and 6 deletions

View File

@ -120,6 +120,15 @@ evas_common_cpu_vis_test(void)
#endif /* __SPARC__ */
}
static Eina_Bool
_cpu_check(Eina_Cpu_Features f)
{
Eina_Cpu_Features features;
features = eina_cpu_features_get();
return (features & f) == f;
}
int
evas_common_cpu_feature_test(void (*feature)(void))
{
@ -150,16 +159,13 @@ evas_common_cpu_feature_test(void (*feature)(void))
sigaction(SIGSEGV, &oact2, NULL);
return enabled;
#else
Eina_Cpu_Features f;
f = eina_cpu_features_get();
if (feature == evas_common_cpu_mmx_test)
return (f & EINA_CPU_MMX) == EINA_CPU_MMX;
return _cpu_check(EINA_CPU_MMX);
/* no mmx2 support in eina */
if (feature == evas_common_cpu_sse_test)
return (f & EINA_CPU_SSE) == EINA_CPU_SSE;
return _cpu_check(EINA_CPU_SSE);
if (feature == evas_common_cpu_sse3_test)
return (f & EINA_CPU_SSE3) == EINA_CPU_SSE3;
return _cpu_check(EINA_CPU_SSE3);
return 0;
#endif
}