]> git.sesse.net Git - vlc/commitdiff
Improve x86 cpuid
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 25 Oct 2011 16:49:47 +0000 (19:49 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 25 Oct 2011 16:55:48 +0000 (19:55 +0300)
There is no need for hoops around EBX for non-PIC code.

src/misc/cpu.c

index 39ac2e92337457911043908b5e1fae8605c9d900..69b471b2ca9444ca4dbae65c2679107b128d03db 100644 (file)
@@ -105,28 +105,21 @@ void vlc_CPU_init (void)
      bool b_amd;
 
     /* Needed for x86 CPU capabilities detection */
-#   if defined( __x86_64__ )
-#       define cpuid( reg )                    \
-            asm volatile ( "cpuid\n\t"         \
-                         : "=a" ( i_eax ),     \
-                           "=b" ( i_ebx ),     \
-                           "=c" ( i_ecx ),     \
-                           "=d" ( i_edx )      \
-                         : "a"  ( reg )        \
-                         : "cc" );
-#   else
-#       define cpuid( reg )                    \
-            asm volatile ( "push %%ebx\n\t"    \
-                           "cpuid\n\t"         \
-                           "movl %%ebx,%1\n\t" \
-                           "pop %%ebx\n\t"     \
-                         : "=a" ( i_eax ),     \
-                           "=r" ( i_ebx ),     \
-                           "=c" ( i_ecx ),     \
-                           "=d" ( i_edx )      \
-                         : "a"  ( reg )        \
-                         : "cc" );
-#   endif
+# if defined (__i386__) && defined (__PIC__)
+#  define cpuid(reg) \
+     asm volatile ("xchgl %%ebx,%1\n\t" \
+                   "cpuid\n\t" \
+                   "xchgl %%ebx,%1\n\t" \
+                   : "=a" (i_eax), "=r" (i_ebx), "=c" (i_ecx), "=d" (i_edx) \
+                   : "a" (reg) \
+                   : "cc");
+# else
+#  define cpuid(reg) \
+     asm volatile ("cpuid\n\t" \
+                   : "=a" (i_eax), "=b" (i_ebx), "=c" (i_ecx), "=d" (i_edx) \
+                   : "a" (reg) \
+                   : "cc");
+# endif
      /* Check if the OS really supports the requested instructions */
 # if defined (__i386__) && !defined (__i486__) && !defined (__i586__) \
   && !defined (__i686__) && !defined (__pentium4__) \