[vlc-commits] [Git][videolan/vlc][master] 5 commits: cpu: remove gratuitious swap
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Mon Feb 28 19:42:46 UTC 2022
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
c0901dbc by Rémi Denis-Courmont at 2022-02-28T17:49:28+00:00
cpu: remove gratuitious swap
This gets the EBX value directly from, well, EBX. The compiler knows
that EBX will be clobbered given it is an output operand, so it will
save and restore it if/as needed.
- - - - -
4ea8f779 by Rémi Denis-Courmont at 2022-02-28T17:49:28+00:00
cpu: remove volatile qualifier
We do not care about any side effects here, only the output operands.
- - - - -
a0356a20 by Rémi Denis-Courmont at 2022-02-28T17:49:28+00:00
cpu: remove volatile qualifier
- - - - -
675aeb02 by Rémi Denis-Courmont at 2022-02-28T17:49:28+00:00
cpu: output old flags straight
Output the current CPU flags directly into the selected register.
Thus EBX is left alone, and need not be saved/restored.
- - - - -
c12fc2ad by Rémi Denis-Courmont at 2022-02-28T17:49:28+00:00
cpu: do not hard-code EAX
Let the compiler pick whichever register it sees fit.
- - - - -
1 changed file:
- src/misc/cpu.c
Changes:
=====================================
src/misc/cpu.c
=====================================
@@ -118,43 +118,32 @@ VLC_WEAK unsigned vlc_CPU_raw(void)
unsigned int i_eax, i_ebx, i_ecx, i_edx;
/* Needed for x86 CPU capabilities detection */
-# 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
+# define cpuid(reg) \
+ asm ("cpuid" \
+ : "=a" (i_eax), "=b" (i_ebx), "=c" (i_ecx), "=d" (i_edx) \
+ : "a" (reg) \
+ : "cc");
+
/* Check if the OS really supports the requested instructions */
# if defined (__i386__) && !defined (__i586__) \
&& !defined (__i686__) && !defined (__pentium4__) \
&& !defined (__k6__) && !defined (__athlon__) && !defined (__k8__)
# if !defined (__i486__)
- /* check if cpuid instruction is supported */
- asm volatile ("push %%ebx\n\t"
- "pushf\n\t"
- "pop %%eax\n\t"
- "movl %%eax, %%ebx\n\t"
- "xorl $0x200000, %%eax\n\t"
- "push %%eax\n\t"
- "popf\n\t"
- "pushf\n\t"
- "pop %%eax\n\t"
- "movl %%ebx,%1\n\t"
- "pop %%ebx\n\t"
- : "=a" (i_eax), "=r" (i_ebx)
- :
- : "cc" );
-
- if( i_eax == i_ebx )
+ /* Check if CPUID is supported by setting ID flag bit 21. */
+ unsigned int after, before;
+ asm ("pushf\n\t"
+ "pop %0\n\t"
+ "movl %0, %1\n\t"
+ "xorl $0x200000, %0\n\t"
+ "push %0\n\t"
+ "popf\n\t"
+ "pushf\n\t"
+ "pop %0\n\t"
+ : "=&r" (after), "=&r" (before)
+ :
+ : "cc");
+
+ if( after == before )
goto out;
# endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fe1083cdf555bf768e2228fd2a76dc6cb0b0c434...c12fc2ad616262db6c8c39c062d60acf93247f76
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fe1083cdf555bf768e2228fd2a76dc6cb0b0c434...c12fc2ad616262db6c8c39c062d60acf93247f76
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list