From e95ae22fdde03b79f6765bea1c2fc1db29061d93 Mon Sep 17 00:00:00 2001 From: Martin Nilsson <nilsson@fastmail.com> Date: Mon, 11 Jul 2016 20:12:11 +0200 Subject: [PATCH] cpuid has been supported since 486SL. Let's assume cpuid is supported. --- src/pike_cpulib.c | 73 +++++++++-------------------------------------- 1 file changed, 13 insertions(+), 60 deletions(-) diff --git a/src/pike_cpulib.c b/src/pike_cpulib.c index cac1332e06..d219c671d4 100644 --- a/src/pike_cpulib.c +++ b/src/pike_cpulib.c @@ -20,64 +20,20 @@ PMOD_EXPORT void x86_get_cpuid(int oper, INT32 *cpuid_ptr) * edx -> cpuid_ptr[2] * ecx -> cpuid_ptr[3] */ { -#ifdef HAVE_X86_64_ASM -#define cpuid_supported 1 -#else /* HAVE_IA32_ASM */ - static int cpuid_supported = 0; - if (!cpuid_supported) { - int fbits=0; #ifdef CL_X86_ASM_STYLE - __asm { - pushf - pop eax - mov ecx, eax - xor eax, 00200000h - push eax - popf - pushf - pop eax - xor ecx, eax - mov fbits, ecx - }; -#else /* GCC_X86_ASM_STYLE */ - /* Note: gcc swaps the argument order... */ - __asm__("pushf\n\t" - "pop %%eax\n\t" - "movl %%eax, %%ecx\n\t" - "xorl $0x00200000, %%eax\n\t" - "push %%eax\n\t" - "popf\n\t" - "pushf\n\t" - "pop %%eax\n\t" - "xorl %%eax, %%ecx\n\t" - "movl %%ecx, %0" - : "=m" (fbits) - : - : "cc", "eax", "ecx"); -#endif - if (fbits & 0x00200000) { - cpuid_supported = 1; - } else { - cpuid_supported = -1; - } - } -#endif /* HAVE_IA32_ASM */ - - if (cpuid_supported > 0) { -#ifdef CL_X86_ASM_STYLE - __asm { - mov eax, oper; - mov edi, cpuid_ptr; - cpuid; - mov [edi], eax; - mov [edi+4], ebx; - mov [edi+8], edx; - mov [edi+12], ecx; - }; + __asm { + mov eax, oper; + mov edi, cpuid_ptr; + cpuid; + mov [edi], eax; + mov [edi+4], ebx; + mov [edi+8], edx; + mov [edi+12], ecx; + }; #else /* GCC_X86_ASM_STYLE */ #if SIZEOF_CHAR_P == 4 - __asm__ __volatile__("pushl %%ebx \n\t" /* save %ebx */ + __asm__ __volatile__("pushl %%ebx \n\t" /* save %ebx */ "cpuid \n\t" "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */ "popl %%ebx \n\t" /* restore the old %ebx */ @@ -88,7 +44,7 @@ PMOD_EXPORT void x86_get_cpuid(int oper, INT32 *cpuid_ptr) : "0"(oper) : "cc"); #else - __asm__ __volatile__("push %%rbx \n\t" /* save %rbx */ + __asm__ __volatile__("push %%rbx \n\t" /* save %rbx */ "cpuid \n\t" "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */ "pop %%rbx \n\t" /* restore the old %rbx */ @@ -98,11 +54,8 @@ PMOD_EXPORT void x86_get_cpuid(int oper, INT32 *cpuid_ptr) "=c"(cpuid_ptr[3]) : "0"(oper) : "cc"); -#endif -#endif - } else { - cpuid_ptr[0] = cpuid_ptr[1] = cpuid_ptr[2] = cpuid_ptr[3] = 0; - } +#endif /* SIZEOF_CHAR_P == 4 */ +#endif /* CL_X86_ASM_STYLE */ } #endif /* HAVE_IA32_ASM */ -- GitLab