summaryrefslogtreecommitdiff
path: root/libavutil/x86/cpu.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-05 17:02:15 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-05 17:04:15 +0200
commit0ed023275f79d6dd7b1be832da27175f788b8e4d (patch)
treee8bea39cd11b75c5dfad3b39ba96169c6499a0ec /libavutil/x86/cpu.c
parent2a77d4f70b8b653ba405e6c01591bc402ab25a52 (diff)
parentf6f7d1504134683c435e2c7d804279d982e52bb4 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: h264: don't touch H264Context->ref_count[] during MB decoding x86: get_cpu_flags: add necessary ifdefs around function body x86: Drop CPU detection intrinsics x86: Add YASM implementations of cpuid and xgetbv from x264 Conflicts: configure libavcodec/h264_cabac.c libavcodec/h264_cavlc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/x86/cpu.c')
-rw-r--r--libavutil/x86/cpu.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index cd2f0092fa..3fee152095 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -22,10 +22,21 @@
#include <stdlib.h>
#include <string.h>
+
#include "libavutil/x86/asm.h"
+#include "libavutil/x86/cpu.h"
#include "libavutil/cpu.h"
-#if HAVE_INLINE_ASM
+#if HAVE_YASM
+
+#define cpuid(index, eax, ebx, ecx, edx) \
+ ff_cpu_cpuid(index, &eax, &ebx, &ecx, &edx)
+
+#define xgetbv(index, eax, edx) \
+ ff_cpu_xgetbv(index, &eax, &edx)
+
+#elif 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 ( \
@@ -34,35 +45,9 @@
"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) \
__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 */
-
-#if HAVE_INLINE_ASM
#define get_eflags(x) \
__asm__ volatile ("pushfl \n" \
@@ -74,22 +59,16 @@
"popfl \n" \
:: "r"(x))
-#elif HAVE_RWEFLAGS
-
-#include <intrin.h>
-
-#define get_eflags(x) \
- x = __readeflags()
-
-#define set_eflags(x) \
- __writeeflags(x)
-
#endif /* HAVE_INLINE_ASM */
#if ARCH_X86_64
#define cpuid_test() 1
+#elif HAVE_YASM
+
+#define cpuid_test ff_cpu_cpuid_test
+
#elif HAVE_INLINE_ASM || HAVE_RWEFLAGS
static int cpuid_test(void)
@@ -110,6 +89,9 @@ static int cpuid_test(void)
int ff_get_cpu_flags_x86(void)
{
int rval = 0;
+
+#ifdef cpuid
+
int eax, ebx, ecx, edx;
int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;
int family = 0, model = 0;
@@ -213,5 +195,7 @@ int ff_get_cpu_flags_x86(void)
rval |= AV_CPU_FLAG_ATOM;
}
+#endif /* cpuid */
+
return rval;
}