|
发表于 2003-9-2 10:44:35
|
显示全部楼层
[code:1] QFile cpuinfo("/proc/cpuinfo");
QString line;
int CPUs=0;
if(cpuinfo.open(IO_ReadOnly)) {
while(!cpuinfo.atEnd()) {
cpuinfo.readLine(line, 1024);
if(line.left(9)=="vendor_id" && line.contains("AMD")) {
isAMD=true;
} else if(line.left(9)=="vendor_id" && line.contains("CentaurHauls")) {
isBrokenVIACentaur=true;
} else if(line.left(9) == "processor") {
CPUs++;
} else if (line.left(5)=="flags") {
if(line.contains("sse"))
isP3=true;
if(line.contains("sse2"))
isP4=true;
if(line.contains("cmov")) // If it's a VIA, it's a fixed one
isBrokenVIACentaur=false;
}
}
cpuinfo.close();
}
// cout << "arch is " << arch.local8Bit() << endl;
if(arch == "i386" || arch == "i486") // Ouch! Let's hope the best...
arch="i586";
if(arch == "i786" || arch == "i886" || arch == "i986") // Ok, wild but educated guess
arch = "i686";
if(arch != "i586" && arch != "i686" && arch != "athlon") // Huh? Better safe than sorry...
arch = "i586";
if(arch == "i686" && isAMD) {
// Unfortunately, uname() doesn't know the difference between an i686
// and an athlon...
// Let's assume that anything from AMD that is i686 or higher is athlon compatible.
arch = "athlon";
}
if(arch == "i686" && isBrokenVIACentaur) {
arch = "i586";
}
if (arch == "i686" && isP3 && !isAMD) {
if (isP4) {
arch = "pentium4";
} else {
arch = "pentium3";
}
}
[/code:1] |
|