aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/x86/cpu.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-05 16:52:13 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-05 16:52:13 +0200
commit2a77d4f70b8b653ba405e6c01591bc402ab25a52 (patch)
treeac8c7eca3430b000bf861516f2fca09e8ea50d95 /libavutil/x86/cpu.c
parentf74f8bc864b26cdbab606edcd6a401b4d1ca2700 (diff)
parent65d12900432ac880d764edbbd36818431484a76e (diff)
downloadffmpeg-2a77d4f70b8b653ba405e6c01591bc402ab25a52.tar.gz
Merge commit '65d12900432ac880d764edbbd36818431484a76e'
* commit '65d12900432ac880d764edbbd36818431484a76e': configure: add --enable-lto option x86: cpu: Break out test for cpuid capabilities into separate function x86: ff_get_cpu_flags_x86(): Avoid a pointless variable indirection build: Factor out mpegaudio dependencies to CONFIG_MPEGAUDIO segment: Add comments about calls that only are relevant for some muxers segment: Add an option for omitting the first header and final trailer Conflicts: configure libavcodec/Makefile libavformat/segment.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/x86/cpu.c')
-rw-r--r--libavutil/x86/cpu.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 994e30dfe1..cd2f0092fa 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -86,16 +86,14 @@
#endif /* HAVE_INLINE_ASM */
-/* Function to test if multimedia instructions are supported... */
-int ff_get_cpu_flags_x86(void)
-{
- int rval = 0;
- int eax, ebx, ecx, edx;
- int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;
- int family = 0, model = 0;
- union { int i[3]; char c[12]; } vendor;
+#if ARCH_X86_64
+
+#define cpuid_test() 1
-#if ARCH_X86_32
+#elif HAVE_INLINE_ASM || HAVE_RWEFLAGS
+
+static int cpuid_test(void)
+{
x86_reg a, c;
/* Check if CPUID is supported by attempting to toggle the ID bit in
@@ -104,14 +102,23 @@ int ff_get_cpu_flags_x86(void)
set_eflags(a ^ 0x200000);
get_eflags(c);
- if (a == c)
- return 0; /* CPUID not supported */
+ return a != c;
+}
#endif
- cpuid(0, max_std_level, ebx, ecx, edx);
- vendor.i[0] = ebx;
- vendor.i[1] = edx;
- vendor.i[2] = ecx;
+/* Function to test if multimedia instructions are supported... */
+int ff_get_cpu_flags_x86(void)
+{
+ int rval = 0;
+ int eax, ebx, ecx, edx;
+ int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;
+ int family = 0, model = 0;
+ union { int i[3]; char c[12]; } vendor;
+
+ if (!cpuid_test())
+ return 0; /* CPUID not supported */
+
+ cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]);
if (max_std_level >= 1) {
cpuid(1, eax, ebx, ecx, std_caps);