From 9e330d5615fc648cc604db819b2aed95c2e7df47 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Thu, 11 Nov 2004 07:25:45 +0000 Subject: [PATCH] fix cpuid test on x86_64 and newer binutils --- .../src/kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp index 2dd4fd3f..34d07242 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp @@ -64,8 +64,13 @@ static unsigned int x86_cpuid(void) CPUID(0). Preserve %ebx and %ecx; cpuid insn clobbers these, we don't need their CPUID values here, and %ebx may be the PIC register. */ +#ifdef __x86_64__ + __asm__ ("pushq %%rcx; pushq %%rbx; cpuid; popq %%rbx; popq %%rcx" + : "=a" (fl1) : "0" (0) : "rdx", "cc"); +#else __asm__ ("push %%ecx ; push %%ebx ; cpuid ; pop %%ebx ; pop %%ecx" : "=a" (fl1) : "0" (0) : "edx", "cc"); +#endif if (fl1 == 0) return (0); @@ -86,6 +91,18 @@ powerpc_dyngen::powerpc_dyngen(dyngen_cpu_base cpu, int cache_size) { #if defined(__i386__) || defined(__x86_64__) cpu_features = x86_cpuid(); +#ifdef SHEEPSHAVER + if (cpu_features & (HWCAP_I386_MMX | HWCAP_I386_SSE | HWCAP_I386_SSE2)) { + printf("Detected CPU features:"); + if (cpu_features & HWCAP_I386_MMX) + printf(" MMX"); + if (cpu_features & HWCAP_I386_SSE) + printf(" SSE"); + if (cpu_features & HWCAP_I386_SSE2) + printf(" SSE2"); + printf("\n"); + } +#endif #endif }