mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-09 14:14:39 +02:00
x86: cpu: clean up check for cpuid instruction support
This adds macros for accessing the EFLAGS register and uses these instead of coding the entire check in inline asm. Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
62634158b7
commit
889c1ec4cc
@ -37,6 +37,16 @@
|
|||||||
#define xgetbv(index, eax, edx) \
|
#define xgetbv(index, eax, edx) \
|
||||||
__asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
|
__asm__ (".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c" (index))
|
||||||
|
|
||||||
|
#define get_eflags(x) \
|
||||||
|
__asm__ volatile ("pushfl \n" \
|
||||||
|
"pop %0 \n" \
|
||||||
|
: "=r"(x))
|
||||||
|
|
||||||
|
#define set_eflags(x) \
|
||||||
|
__asm__ volatile ("push %0 \n" \
|
||||||
|
"popfl \n" \
|
||||||
|
:: "r"(x))
|
||||||
|
|
||||||
/* Function to test if multimedia instructions are supported... */
|
/* Function to test if multimedia instructions are supported... */
|
||||||
int ff_get_cpu_flags_x86(void)
|
int ff_get_cpu_flags_x86(void)
|
||||||
{
|
{
|
||||||
@ -48,26 +58,12 @@ int ff_get_cpu_flags_x86(void)
|
|||||||
|
|
||||||
#if ARCH_X86_32
|
#if ARCH_X86_32
|
||||||
x86_reg a, c;
|
x86_reg a, c;
|
||||||
__asm__ volatile (
|
|
||||||
/* See if CPUID instruction is supported ... */
|
|
||||||
/* ... Get copies of EFLAGS into eax and ecx */
|
|
||||||
"pushfl\n\t"
|
|
||||||
"pop %0\n\t"
|
|
||||||
"mov %0, %1\n\t"
|
|
||||||
|
|
||||||
/* ... Toggle the ID bit in one copy and store */
|
/* Check if CPUID is supported by attempting to toggle the ID bit in
|
||||||
/* to the EFLAGS reg */
|
* the EFLAGS register. */
|
||||||
"xor $0x200000, %0\n\t"
|
get_eflags(a);
|
||||||
"push %0\n\t"
|
set_eflags(a ^ 0x200000);
|
||||||
"popfl\n\t"
|
get_eflags(c);
|
||||||
|
|
||||||
/* ... Get the (hopefully modified) EFLAGS */
|
|
||||||
"pushfl\n\t"
|
|
||||||
"pop %0\n\t"
|
|
||||||
: "=a" (a), "=c" (c)
|
|
||||||
:
|
|
||||||
: "cc"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (a == c)
|
if (a == c)
|
||||||
return 0; /* CPUID not supported */
|
return 0; /* CPUID not supported */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user