summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--volk/gen/make_cpuid_c.py7
-rw-r--r--volk/lib/gcc_x86_cpuid.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py
index 4bd1ce5b1..c6bb5059e 100644
--- a/volk/gen/make_cpuid_c.py
+++ b/volk/gen/make_cpuid_c.py
@@ -73,6 +73,13 @@ static inline unsigned int cpuid_edx(unsigned int op) {
cpuid_x86 (op, regs);
return regs[3];
}
+
+static inline unsigned int xgetbv(void) {
+ //check to make sure that xgetbv is enabled in OS
+ int xgetbv_enabled = cpuid_ecx(1) >> 27 & 0x01;
+ if(xgetbv_enabled == 0) return 0;
+ return __xgetbv();
+}
#endif
"""
diff --git a/volk/lib/gcc_x86_cpuid.h b/volk/lib/gcc_x86_cpuid.h
index 95a6722f2..2345ed213 100644
--- a/volk/lib/gcc_x86_cpuid.h
+++ b/volk/lib/gcc_x86_cpuid.h
@@ -182,7 +182,7 @@ __get_cpuid (unsigned int __level,
* check for AVX capability before executing.
*/
static __inline unsigned int
-xgetbv(void)
+__xgetbv(void)
{
unsigned int index, __eax, __edx;
__asm__ ("xgetbv" : "=a"(__eax), "=d"(__edx) : "c" (index));