Ok, now we actually check if we can use cpuid before using it. With evil AT&T inlined ASM from ui.asm [Nach]

This commit is contained in:
grinvader
2005-10-27 16:18:51 +00:00
parent ead3840ccd
commit 69cb866762

View File

@@ -306,6 +306,26 @@ if test x$enable_cpucheck != xno; then
} }
} }
int have_cpuid()
{
int have = 0x200000;
asm volatile
(
"pushfl \n\t"
"pop %%eax \n\t"
"movl %%eax,%%edx \n\t"
"xorl %%ecx,%%eax \n\t"
"push %%eax \n\t"
"popfl \n\t"
"pushfl \n\t"
"pop %%eax \n\t"
"xorl %%edx,%%eax \n\t"
: "=a" (have)
: "c" (have)
);
return(have);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char model_name[216], flags[216], cpu_family[216]; char model_name[216], flags[216], cpu_family[216];
@@ -342,7 +362,7 @@ if test x$enable_cpucheck != xno; then
} }
fclose(fp); fclose(fp);
} }
else else if (have_cpuid())
{ {
unsigned int maxei, eax, ebx, ecx, edx, unused, i; unsigned int maxei, eax, ebx, ecx, edx, unused, i;
@@ -395,6 +415,8 @@ if test x$enable_cpucheck != xno; then
} }
} }
if (*cpu_family && *vendor_id)
{
if (!strcmp(vendor_id, "AuthenticAMD") || strstr(model_name, "AMD")) if (!strcmp(vendor_id, "AuthenticAMD") || strstr(model_name, "AMD"))
{ {
if (strstr(flags, " mmx ")) if (strstr(flags, " mmx "))
@@ -528,6 +550,7 @@ if test x$enable_cpucheck != xno; then
fclose(fp); fclose(fp);
return(0); return(0);
} }
}
return(1); return(1);
} }