[FFmpeg-cvslog] x86/cpu: implement support for cpuid through intrinsics

Ronald S. Bultje git at videolan.org
Tue Jul 10 21:35:44 CEST 2012


ffmpeg | branch: master | Ronald S. Bultje <rsbultje at gmail.com> | Mon Jul  9 02:21:27 2012 +0200| [c0ee695bd7b278f83252c9f93803b107d7aa1e9a] | committer: Martin Storsjö

x86/cpu: implement support for cpuid through intrinsics

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0ee695bd7b278f83252c9f93803b107d7aa1e9a
---

 configure           |    2 ++
 libavutil/x86/cpu.c |   14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/configure b/configure
index 76ad4c7..0f51523 100755
--- a/configure
+++ b/configure
@@ -1061,6 +1061,7 @@ HAVE_LIST="
     cbrtf
     closesocket
     cmov
+    cpuid
     dcbzl
     dev_bktr_ioctl_bt848_h
     dev_bktr_ioctl_meteor_h
@@ -2744,6 +2745,7 @@ elif enabled sparc; then
 elif enabled x86; then
 
     check_code ld immintrin.h "__xgetbv(0)" && enable xgetbv
+    check_code ld intrin.h "int info[4]; __cpuid(info, 0)" && enable cpuid
     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 dfdc123..7d65c60 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -25,6 +25,7 @@
 #include "libavutil/x86_cpu.h"
 #include "libavutil/cpu.h"
 
+#if HAVE_INLINE_ASM
 /* ebx saving is necessary for PIC. gcc seems unable to see it alone */
 #define cpuid(index, eax, ebx, ecx, edx)                        \
     __asm__ volatile (                                          \
@@ -33,6 +34,19 @@
         "xchg   %%"REG_b", %%"REG_S                             \
         : "=a" (eax), "=S" (ebx), "=c" (ecx), "=d" (edx)        \
         : "0" (index))
+#elif HAVE_CPUID
+#include <intrin.h>
+
+#define cpuid(index, eax, ebx, ecx, edx)        \
+    do {                                        \
+        int info[4];                            \
+        __cpuid(info, index);                   \
+        eax = info[0];                          \
+        ebx = info[1];                          \
+        ecx = info[2];                          \
+        edx = info[3];                          \
+    } while (0)
+#endif /* HAVE_CPUID */
 
 #if HAVE_INLINE_ASM
 #define xgetbv(index, eax, edx)                                 \



More information about the ffmpeg-cvslog mailing list