cpuid is not going to change more than ebx, even on x86_64

This commit is contained in:
Frank Denis 2014-05-02 21:16:32 -07:00
parent f601e6e471
commit f8c49ac54f

View File

@ -46,12 +46,19 @@ _cpuid(unsigned int cpu_info[4U], const unsigned int cpu_info_type)
#ifdef _MSC_VER #ifdef _MSC_VER
__cpuidex((int *) cpu_info, cpu_info_type, 0); __cpuidex((int *) cpu_info, cpu_info_type, 0);
#elif defined(HAVE_CPUID) #elif defined(HAVE_CPUID)
# ifdef __x86_64__ cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
__asm__ __volatile__ ("xchgq %%rbx, %q1; cpuid; xchgq %%rbx, %q1" : # if defined(__i386__) && !defined(__x86_64__)
"=a" (cpu_info[0]), "=&r" (cpu_info[1]), __asm__ __volatile__ ("pushfl; pushfl; "
"=c" (cpu_info[2]), "=d" (cpu_info[3]) : "popl %0; "
"a" (cpu_info_type), "c" (0U)); "movl %0, %1; xorl %2, %0; "
# elif defined(__i386__) "pushl %0; "
"popfl; pushfl; popl %0; popfl" :
"=&r" (cpu_info[0]), "=&r" (cpu_info[1]) :
"i" (0x200000));
if (((cpu_info[0] ^ cpu_info[1]) & 0x200000) == 0x0) {
return;
}
# endif
__asm__ __volatile__ ("xchgl %%ebx, %k1; cpuid; xchgl %%ebx, %k1" : __asm__ __volatile__ ("xchgl %%ebx, %k1; cpuid; xchgl %%ebx, %k1" :
"=a" (cpu_info[0]), "=&r" (cpu_info[1]), "=a" (cpu_info[0]), "=&r" (cpu_info[1]),
"=c" (cpu_info[2]), "=d" (cpu_info[3]) : "=c" (cpu_info[2]), "=d" (cpu_info[3]) :
@ -59,9 +66,6 @@ _cpuid(unsigned int cpu_info[4U], const unsigned int cpu_info_type)
#else #else
cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0; cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
#endif #endif
#else
cpu_info[0] = cpu_info[1] = cpu_info[2] = cpu_info[3] = 0;
#endif
} }
static int static int