From 06e640532aa093902e81f09aa18de1b084fcc5ce Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sat, 27 Aug 2011 20:42:11 +0200 Subject: Various changes which improve FreeBSD support. Patches by martymac, all credits go to him ;) --- Source/Core/Common/Src/CPUDetect.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Source/Core/Common/Src/CPUDetect.cpp') diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp index 810c5d2a59..7c231b0a69 100644 --- a/Source/Core/Common/Src/CPUDetect.cpp +++ b/Source/Core/Common/Src/CPUDetect.cpp @@ -32,6 +32,10 @@ //#include #include +#if defined __FreeBSD__ +#include +#include +#else static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { @@ -65,15 +69,20 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, ); #endif } +#endif /* defined __FreeBSD__ */ static void __cpuid(int info[4], int x) { +#if defined __FreeBSD__ + do_cpuid((unsigned int)x, (unsigned int*)info); +#else unsigned int eax = x, ebx = 0, ecx = 0, edx = 0; do_cpuid(&eax, &ebx, &ecx, &edx); info[0] = eax; info[1] = ebx; info[2] = ecx; info[3] = edx; +#endif } #endif -- cgit v1.2.3 From 7423c74deb5d1b092fc9386c11305d8983327288 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 12 Dec 2011 00:43:23 +0100 Subject: Force the "ebx" argument to be mapped to a register (not necessarily EBX). Fixes crash on x86 under OS X. Thanks to kiesel for the fix and to shuffle2 for remembering the problem. --- Source/Core/Common/Src/CPUDetect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/Common/Src/CPUDetect.cpp') diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp index 7c231b0a69..33efef7c01 100644 --- a/Source/Core/Common/Src/CPUDetect.cpp +++ b/Source/Core/Common/Src/CPUDetect.cpp @@ -48,7 +48,7 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, "movl %%ebx,%1;" "mov %%rdi,%%rbx;" : "=a" (*eax), - "=g" (*ebx), + "=r" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (*eax) @@ -61,7 +61,7 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, "movl %%ebx,%1;" "movl %%edi,%%ebx;" : "=a" (*eax), - "=g" (*ebx), + "=r" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (*eax) -- cgit v1.2.3 From ee5a29e6f2010eea7d9953a875f5ff7dc8149fda Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Mon, 12 Dec 2011 02:14:56 +0100 Subject: For CPUID, save EBX on the stack instead of in a register. This fixes GCC running out of registers when compiling for x86 in release mode. Thanks to kiesel. --- Source/Core/Common/Src/CPUDetect.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'Source/Core/Common/Src/CPUDetect.cpp') diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp index 33efef7c01..99e43f5c46 100644 --- a/Source/Core/Common/Src/CPUDetect.cpp +++ b/Source/Core/Common/Src/CPUDetect.cpp @@ -43,29 +43,27 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, // Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to // restored at the end of the asm block. __asm__ ( - "mov %%rbx,%%rdi;" + "pushq %%rbx;" "cpuid;" "movl %%ebx,%1;" - "mov %%rdi,%%rbx;" + "popq %%rbx;" : "=a" (*eax), - "=r" (*ebx), + "=S" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (*eax) - : "rdi", "rbx" ); #else - __asm__( - "movl %%ebx,%%edi;" + __asm__ ( + "pushl %%ebx;" "cpuid;" - "movl %%ebx,%1;" - "movl %%edi,%%ebx;" + "movl %%ebx,%1;" + "popl %%ebx;" : "=a" (*eax), - "=r" (*ebx), + "=S" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (*eax) - : "edi", "ebx" ); #endif } -- cgit v1.2.3 From 59e93bff78f54a0cff3f2c6558ed1a69b47a9534 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 1 Jan 2012 20:45:15 +0100 Subject: Fix a crash at startup with Dolphin on Linux compiled in debug mode Use the clobber list instead of the stack to save rbx when executing the cpuid instruction with inline assembly. This avoids breaking GCC assumptions about the stack pointer location. --- Source/Core/Common/Src/CPUDetect.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Source/Core/Common/Src/CPUDetect.cpp') diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp index 99e43f5c46..93e9d25087 100644 --- a/Source/Core/Common/Src/CPUDetect.cpp +++ b/Source/Core/Common/Src/CPUDetect.cpp @@ -43,27 +43,25 @@ static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, // Note: EBX is reserved on Mac OS X and in PIC on Linux, so it has to // restored at the end of the asm block. __asm__ ( - "pushq %%rbx;" "cpuid;" "movl %%ebx,%1;" - "popq %%rbx;" : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (*eax) + : "rbx" ); #else __asm__ ( - "pushl %%ebx;" "cpuid;" "movl %%ebx,%1;" - "popl %%ebx;" : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (*eax) + : "ebx" ); #endif } -- cgit v1.2.3