summaryrefslogtreecommitdiff
path: root/volk
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-04-18 11:16:59 -0700
committerJosh Blum <josh@joshknows.com>2012-04-19 18:13:23 -0700
commit283b6e911517313597756a9c3acd966c2dfe77e4 (patch)
treebf071c76c102fda53f1ee95fce95a86bce3f8181 /volk
parentc1348c8cdc8d607a00f2c427e0bdf78c80e836d1 (diff)
volk: added gcc version check to xgetbv
Reference https://code.google.com/p/pcsx2/issues/detail?id=1195
Diffstat (limited to 'volk')
-rw-r--r--volk/tmpl/volk_cpu.tmpl.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/volk/tmpl/volk_cpu.tmpl.c b/volk/tmpl/volk_cpu.tmpl.c
index e0a0e91ded..b312c44853 100644
--- a/volk/tmpl/volk_cpu.tmpl.c
+++ b/volk/tmpl/volk_cpu.tmpl.c
@@ -44,12 +44,16 @@ struct VOLK_CPU volk_cpu;
* This function will bomb on non-AVX-capable machines, so
* check for AVX capability before executing.
*/
- static inline unsigned int __xgetbv(void)
- {
- unsigned int index, __eax, __edx;
- __asm__ ("xgetbv" : "=a"(__eax), "=d"(__edx) : "c" (index));
- return __eax;
+ #if defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 4)
+ static inline unsigned long long _xgetbv(unsigned int index){
+ unsigned int eax, edx;
+ __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
+ return ((unsigned long long)edx << 32) | eax;
}
+ #define __xgetbv() _xgetbv(0)
+ #else
+ #define __xgetbv() 0
+ #endif
//implement get cpuid for MSVC compilers using __cpuid intrinsic
#elif defined(_MSC_VER) && defined(HAVE_INTRIN_H)