summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2012-07-09 02:21:26 +0200
committerMartin Storsjö <martin@martin.st>2012-07-10 14:33:17 +0300
commit3f150ffba31e404ca48624dc6af27b85c1704862 (patch)
tree286b306d9772f2a412208906073ca764dd868d73 /libavutil
parentf80ddd5bf760e685f4d912ce6e6763e6cab45910 (diff)
x86/cpu: implement support for xgetbv through intrinsics
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/x86/cpu.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 5d77b0c2df..dfdc12394c 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -34,8 +34,19 @@
: "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx) \
: "0" (index))
+#if HAVE_INLINE_ASM
#define xgetbv(index, eax, edx) \
__asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
+#elif HAVE_XGETBV
+#include <immintrin.h>
+
+#define xgetbv(index, eax, edx) \
+ do { \
+ uint64_t res = __xgetbv(index); \
+ eax = res; \
+ edx = res >> 32; \
+ } while (0)
+#endif /* HAVE_XGETBV */
#define get_eflags(x) \
__asm__ volatile ("pushfl \n" \