[PATCH 2/3] kwsys: sum up all caches found in /proc/cpuinfo
Rolf Eike Beer
eike at sf-mail.de
Sat Sep 8 11:25:03 EDT 2012
Non-x86 architectures (namely PA-RISC) may not have the "cache size" li=
ne, but
others. Search for all and sum up their results.
---
Source/kwsys/SystemInformation.cxx | 26 +++++++++++++++++++++-----
1 Datei ge=C3=A4ndert, 21 Zeilen hinzugef=C3=BCgt(+), 5 Zeilen entfern=
t(-)
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemIn=
formation.cxx
index 1077b11..7b50b74 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3101,13 +3101,29 @@ int SystemInformationImplementation::RetreiveIn=
formationFromCpuInfoFile()
this->ChipID.ModelName =3D this->ExtractValueFromCpuInfoFile(buffer,=
"model name").c_str();
=20
// L1 Cache size
- kwsys_stl::string cacheSize =3D this->ExtractValueFromCpuInfoFile(bu=
ffer,"cache size");
- pos =3D cacheSize.find(" KB");
- if(pos!=3DcacheSize.npos)
+ // Different architectures may show different names for the caches.
+ // Sum up everything we find.
+ kwsys_stl::vector<const char*> cachename;
+ cachename.clear();
+
+ cachename.push_back("cache size"); // e.g. x86
+ cachename.push_back("I-cache"); // e.g. PA-RISC
+ cachename.push_back("D-cache"); // e.g. PA-RISC
+
+ this->Features.L1CacheSize =3D 0;
+ for (int index =3D 0; index < cachename.size(); index ++)
{
- cacheSize =3D cacheSize.substr(0,pos);
+ kwsys_stl::string cacheSize =3D this->ExtractValueFromCpuInfoFile(=
buffer,cachename[index]);
+ if (!cacheSize.empty())
+ {
+ pos =3D cacheSize.find(" KB");
+ if(pos!=3DcacheSize.npos)
+ {
+ cacheSize =3D cacheSize.substr(0,pos);
+ }
+ this->Features.L1CacheSize +=3D atoi(cacheSize.c_str());
+ }
}
- this->Features.L1CacheSize =3D atoi(cacheSize.c_str());
return 1;
}
=20
--=20
1.7.11.5
--nextPart3387433.jFLW4W1fOq
Content-Disposition: attachment; filename="0003-kwsys-PA-RISC-chips-are-from-HP.patch"
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; charset="UTF-8"; name="0003-kwsys-PA-RISC-chips-are-from-HP.patch"
More information about the cmake-developers
mailing list