From eec4218ebbc98d66ed021f32b7da9f1bef53db63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:36:05 +0200 Subject: [PATCH] (RJPEG) Use features_cpu --- libretro-common/formats/jpeg/rjpeg.c | 49 +++++----------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4d43a66c76..7e384ad7fa 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -11,6 +11,7 @@ #include #include #include +#include enum { @@ -88,51 +89,19 @@ typedef struct #include #ifdef _MSC_VER - -#if _MSC_VER >= 1400 /* not VC6 */ -#include /* __cpuid */ -static int rjpeg__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; -} -#else -static int rjpeg__cpuid3(void) -{ - int res; - __asm { - mov eax,1 - cpuid - mov res,edx - } - return res; -} -#endif - #define RJPEG_SIMD_ALIGN(type, name) __declspec(align(16)) type name - -static int rjpeg__sse2_available(void) -{ - int info3 = rjpeg__cpuid3(); - return ((info3 >> 26) & 1) != 0; -} -#else /* assume GCC-style if not VC++ */ -#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - -static int rjpeg__sse2_available(void) -{ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */ - /* GCC 4.8+ has a nice way to do this */ - return __builtin_cpu_supports("sse2"); #else - /* portable way to do this, preferably without using GCC inline ASM? - * just bail for now. */ +#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +static int rjpeg__sse2_available(void) +{ + uint64_t mask = cpu_features_get(); + if (mask & RETRO_SIMD_SSE2) + return 1; return 0; -#endif } #endif -#endif /* ARM NEON */ #if defined(RJPEG_NO_SIMD) && defined(RJPEG_NEON)