From: Ronald S. Bultje <rsbul...@gmail.com>

Signed-off-by: Diego Biurrun <di...@biurrun.de>
---
 configure           |    2 ++
 libavutil/x86/cpu.c |   11 +++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 7ef1025..488fa7e 100755
--- a/configure
+++ b/configure
@@ -1171,6 +1171,7 @@ HAVE_LIST="
     windows_h
     winsock2_h
     xform_asm
+    xgetbv
     xmm_clobbers
     yasm
 "
@@ -2745,6 +2746,7 @@ elif enabled sparc; then
 
 elif enabled x86; then
 
+    check_code ld immintrin.h "_xgetbv(0)" && enable xgetbv
     check_code ld intrin.h "__rdtsc()" && enable rdtsc
 
     check_code ld mmintrin.h "_mm_empty()" && enable mm_empty
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 5d77b0c..c6c96f0 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"           \
-- 
1.7.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to