Branch: Tag:

2016-07-11

2016-07-11 18:12:11 by Martin Nilsson <nilsson@fastmail.com>

cpuid has been supported since 486SL. Let's assume cpuid is supported.

20:    * 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;
98:    "=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 */