mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r26208) -Fix (r26197): the cpuid assembly didn't work when PIC was enabled
This commit is contained in:
parent
ee73015e8f
commit
1f0d3cc15b
16
src/cpu.cpp
16
src/cpu.cpp
@ -96,9 +96,21 @@ void ottd_cpuid(int info[4], int type)
|
|||||||
#elif defined(__x86_64__) || defined(__i386)
|
#elif defined(__x86_64__) || defined(__i386)
|
||||||
void ottd_cpuid(int info[4], int type)
|
void ottd_cpuid(int info[4], int type)
|
||||||
{
|
{
|
||||||
|
/* The easy variant would be just cpuid, however... ebx gets clobbered by PIC. */
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cpuid"
|
#if defined(__x86_64__)
|
||||||
: "=a" (info[0]), "=b" (info[1]), "=c" (info[2]), "=d" (info[3])
|
"pushq %%rbx \n\t" // save %rbx
|
||||||
|
#else
|
||||||
|
"pushl %%ebx \n\t" // save %ebx
|
||||||
|
#endif
|
||||||
|
"cpuid \n\t"
|
||||||
|
"movl %%ebx, %1 \n\t" // write the result into output var
|
||||||
|
#if defined(__x86_64__)
|
||||||
|
"popq %%rbx \n\t" // restore %rbx
|
||||||
|
#else
|
||||||
|
"popl %%ebx \n\t" // restore %ebc
|
||||||
|
#endif
|
||||||
|
: "=a" (info[0]), "=r" (info[1]), "=c" (info[2]), "=d" (info[3])
|
||||||
: "a" (type)
|
: "a" (type)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user