From b5863da915b5dd62d8ae38cb7bef858d8c3c879e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 30 Nov 2010 02:56:44 +0000 Subject: [PATCH] Possible fix for the rdtsc call in JitIL.cpp on macosx (issue 3531). This also fixes issue 3595 (although that issue was invalid -- we don't suport scons on linux anymore). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6498 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp index e45048df49..2bba5878f0 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64IL/JitIL.cpp @@ -165,16 +165,22 @@ ps_adds1 #include static inline uint64_t __rdtsc() { -#ifdef __linux__ uint32_t lo, hi; +#ifdef _LP64 __asm__ __volatile__ ("xorl %%eax,%%eax \n cpuid" ::: "%rax", "%rbx", "%rcx", "%rdx"); __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return (uint64_t)hi << 32 | lo; #else - // TODO: Figure out what is wrong with clobbering the rbx register on OSX - return 0; + __asm__ __volatile__ ( + "xor %%eax,%%eax;" + "push %%ebx;" + "cpuid;" + "pop %%ebx;" + ::: "%eax", "%ecx", "%edx"); + __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); #endif + return (uint64_t)hi << 32 | lo; } #endif