ushort getCPUcount(){
std::ifstream cpuinfo("/proc/cpuinfo");
std::string line;
/*
I read somewhere that the processor ID could be repeated. I don't know if
that's true or not.
*/
std::set<unsigned> IDs;
while (!cpuinfo.eof()){
std::getline(cpuinfo,line);
if (!line.size())
continue;
if (line.find("processor")!=0)
continue;
size_t start=line.find(':'),
end;
for (;line[start]<'0' || line[start]>'9';start++);
for (end=start;line[end]>='0' && line[end]<='9';end++);
line=line.substr(start,end-start);
IDs.insert(atoi(line.c_str()));
}
return IDs.size();
}
Zaita: I posted on an osx forum as well, but I figured the odds were decent at least I wasn't the only one here programming on osx so I thought it was worth a shot.