mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-30 04:26:56 +00:00
Save PIC register in cpuid() to fix "can't find a register in class 'BREG'" error in some versions of GCC
This was SVN commit r9023.
This commit is contained in:
@@ -79,7 +79,24 @@ static void cpuid(x86_x64_CpuidRegs* regs)
|
||||
cassert(sizeof(*regs) == 4*sizeof(int));
|
||||
__cpuidex((int*)regs, regs->eax, regs->ecx);
|
||||
#elif GCC_VERSION
|
||||
__asm__ __volatile__ ("cpuid": "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx) : "a" (regs->eax), "c" (regs->ecx));
|
||||
// Need to preserve the PIC register (ebx/rbx) in case GCC is using it
|
||||
# if ARCH_AMD64
|
||||
__asm__ __volatile__ (
|
||||
"pushq %%rbx\n"
|
||||
"cpuid\n"
|
||||
"movl %%ebx, %1\n"
|
||||
"popq %%rbx\n"
|
||||
: "=a" (regs->eax), "=m" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx)
|
||||
: "a" (regs->eax), "c" (regs->ecx));
|
||||
# else
|
||||
__asm__ __volatile__ (
|
||||
"pushl %%ebx\n"
|
||||
"cpuid\n"
|
||||
"movl %%ebx, %1\n"
|
||||
"popl %%ebx\n"
|
||||
: "=a" (regs->eax), "=m" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx)
|
||||
: "a" (regs->eax), "c" (regs->ecx));
|
||||
# endif
|
||||
#else
|
||||
# if ARCH_AMD64
|
||||
amd64_asm_cpuid(regs);
|
||||
|
||||
Reference in New Issue
Block a user