aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2012-10-04 14:01:26 +0200
committerDiego Biurrun <diego@biurrun.de>2012-10-04 18:09:21 +0200
commit54b243141e9ded3437f055d173272caa399a216e (patch)
treeec0ed60999072c8eb5abc0d27d536e67f8fe768d
parentcc5e9e5ff052fe31aa757de79f2d11fb21df3fba (diff)
downloadffmpeg-54b243141e9ded3437f055d173272caa399a216e.tar.gz
x86: cpu: Break out test for cpuid capabilities into separate function
-rw-r--r--libavutil/x86/cpu.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 9cf68e4c98..5de60147c6 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,10 +102,22 @@ 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
+/* 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) {