diff options
author | Nick Foster <nick@ettus.com> | 2012-04-15 17:21:44 -0700 |
---|---|---|
committer | Johnathan Corgan <jcorgan@corganenterprises.com> | 2012-04-16 08:33:01 -0700 |
commit | 92db96430685e843443a00936328b3539354c83e (patch) | |
tree | f05285ca6e4d0d77a205ede742f1c76cb346fd3c /volk | |
parent | c3f2c30a54c75575f464afdd7cd11a017fb07695 (diff) |
Volk: also check to make sure OSXSAVE is enabled so you don't check XGETBV when OS has it disabled.
Diffstat (limited to 'volk')
-rw-r--r-- | volk/gen/make_cpuid_c.py | 7 | ||||
-rw-r--r-- | volk/lib/gcc_x86_cpuid.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/volk/gen/make_cpuid_c.py b/volk/gen/make_cpuid_c.py index 4bd1ce5b1b..c6bb5059eb 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 95a6722f29..2345ed2133 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)); |