summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/CPUDetect.cpp
diff options
context:
space:
mode:
authorMaarten ter Huurne <maarten@treewalker.org>2008-08-24 20:13:49 +0000
committerMaarten ter Huurne <maarten@treewalker.org>2008-08-24 20:13:49 +0000
commit1b1f0ecae965e58babaa8092d056f74c4344c610 (patch)
treecf08ee356fd0a5683e88fe4592667aa8d5558138 /Source/Core/Common/Src/CPUDetect.cpp
parent7151ec6f4faa08f02eae0791fc022aa2be2ffa64 (diff)
The simple form of "cpuid" should work on 64-bit platforms; on 32-bit platforms it is safer to use the version that does not modify EBX.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@297 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/CPUDetect.cpp')
-rw-r--r--Source/Core/Common/Src/CPUDetect.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp
index bbcee7c9eb..f15b1adba7 100644
--- a/Source/Core/Common/Src/CPUDetect.cpp
+++ b/Source/Core/Common/Src/CPUDetect.cpp
@@ -23,24 +23,23 @@
//#include <config/i386/cpuid.h>
#include <xmmintrin.h>
-// 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)
{
- #ifdef __linux__
+ #ifdef _LP64
__asm__("cpuid"
: "=a" (*eax),
"=b" (*ebx),
"=c" (*ecx),
"=d" (*edx));
- #else
- // Note: EBX is reserved on Mac OS X, so it has to be restored at the end
- // of the asm block.
+ #else
+ // Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to be
+ // restored at the end of the asm block.
__asm__(
- "pushl %%ebx;"
- "cpuid;"
- "movl %%ebx,%1;"
- "popl %%ebx;"
+ "pushl %%ebx;"
+ "cpuid;"
+ "movl %%ebx,%1;"
+ "popl %%ebx;"
: "=a" (*eax),
"=r" (*ebx),
"=c" (*ecx),