summaryrefslogtreecommitdiff
path: root/src/cpu.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-01-03 15:09:55 +0000
committerrubidium <rubidium@openttd.org>2014-01-03 15:09:55 +0000
commit9947bdb0c424c7d77dfbaac87390f34a3ac31b0f (patch)
treee86f4f4f1e623cb5e890a5a03d35439cebea0d30 /src/cpu.cpp
parente6fc55b07b7adba8c1880f967dfd119f2a7c8faf (diff)
downloadopenttd-9947bdb0c424c7d77dfbaac87390f34a3ac31b0f.tar.xz
(svn r26220) -Fix?: another attempt at getting cpuid to finally work "everywhere"
Diffstat (limited to 'src/cpu.cpp')
-rw-r--r--src/cpu.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cpu.cpp b/src/cpu.cpp
index e6a8656c2..7776821ce 100644
--- a/src/cpu.cpp
+++ b/src/cpu.cpp
@@ -96,14 +96,22 @@ void ottd_cpuid(int info[4], int type)
#elif defined(__x86_64__) || defined(__i386)
void ottd_cpuid(int info[4], int type)
{
+#if defined(__i386) && defined(__PIC__)
/* The easy variant would be just cpuid, however... ebx gets clobbered by PIC. */
__asm__ __volatile__ (
"xchgl %%ebx, %1 \n\t"
"cpuid \n\t"
"xchgl %%ebx, %1 \n\t"
: "=a" (info[0]), "=r" (info[1]), "=c" (info[2]), "=d" (info[3])
- : "0" (type)
+ : "a" (type)
);
+#else
+ __asm__ __volatile__ (
+ "cpuid \n\t"
+ : "=a" (info[0]), "=b" (info[1]), "=c" (info[2]), "=d" (info[3])
+ : "a" (type)
+ );
+#endif /* i386 PIC */
}
#else
void ottd_cpuid(int info[4], int type)