summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/CPUDetect.cpp
diff options
context:
space:
mode:
authorMaarten ter Huurne <maarten@treewalker.org>2008-08-16 10:48:32 +0000
committerMaarten ter Huurne <maarten@treewalker.org>2008-08-16 10:48:32 +0000
commit7962ab47138c06e505258baa1561c4142bcd39f1 (patch)
treeccb0569492ad75573a98aff586fc835b7d86e314 /Source/Core/Common/Src/CPUDetect.cpp
parent2f55ee30beb804d1c1acc075ae7808a3dcfc4a8d (diff)
Fixed CPU detection on Mac OS X.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@225 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/CPUDetect.cpp')
-rw-r--r--Source/Core/Common/Src/CPUDetect.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp
index b221fc14f5..d11a9fbe18 100644
--- a/Source/Core/Common/Src/CPUDetect.cpp
+++ b/Source/Core/Common/Src/CPUDetect.cpp
@@ -26,17 +26,23 @@
// if you are on linux and this doesn't build, plz fix :)
static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
-{
- __asm__("cpuid"
- : "=a" (*eax),
- "=b" (*ebx),
- "=c" (*ecx),
- "=d" (*edx));
+{
+ // Note: EBX is reserved on Mac OS X, so it has to be restored at the end
+ // of the asm block.
+ __asm__(
+ "pushl %%ebx;"
+ "cpuid;"
+ "movl %%ebx,%1;"
+ "popl %%ebx;"
+ : "=a" (*eax),
+ "=r" (*ebx),
+ "=c" (*ecx),
+ "=d" (*edx));
}
void __cpuid(int info[4], int x)
{
- int eax = x, ebx = 0, ecx = 0, edx = 0;
+ unsigned int eax = x, ebx = 0, ecx = 0, edx = 0;
do_cpuid(&eax, &ebx, &ecx, &edx);
info[0] = eax;
info[1] = ebx;