From f942343d3a8b13578c882c4d4c6a1e74adb19384 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 25 Oct 2011 19:49:47 +0300 Subject: [PATCH] Improve x86 cpuid There is no need for hoops around EBX for non-PIC code. --- src/misc/cpu.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/misc/cpu.c b/src/misc/cpu.c index 39ac2e9233..69b471b2ca 100644 --- a/src/misc/cpu.c +++ b/src/misc/cpu.c @@ -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__) \ -- 2.39.2