Brad King wrote:
> On 09/08/2012 12:45 PM, Rolf Eike Beer wrote:
> > I was a bit bored and decided to hack a bit on a bug I filed long ago
> > (http://cmake.org/Bug/view.php?id=10895). I have attached the first 3
> > patches I came up with. I think #1 should just be applied without any
> > further checks ;)
> The copy of KWSys in VTK has had more development on this:
> 
>  http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=595216ab
>  http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=32f08e67
>  http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=72deb33e
> 
> I haven't had time to cherry-pick the changes into CMake and deal
> with all the problems on platforms where CMake builds but VTK does
> not (if any).  Some of the changes conflict with your patches,
> probably because they do some of the same things.

Ok, I guess we now have the new stuff already in CMake. It would be good if 
you could just take the first of that patches as it just fixes some typos. 
I've attached a rebased version of these patches for easier testing.

Eike
-- 
>From e2dd2e4be5b4fc21bfe8cf71b39ad717e816026c Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Sat, 8 Sep 2012 17:08:36 +0200
Subject: [PATCH 1/3] kwsys: fix typos

---
 Source/kwsys/SystemInformation.cxx | 10 +++++-----
 1 Datei geändert, 5 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 6d990a9..1077b11 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -1670,7 +1670,7 @@ bool SystemInformationImplementation::RetrieveCPUFeatures()
 #endif
       ; <<CPUID>>
       ; eax = 1 --> eax: CPU ID - bits 31..16 - unused, bits 15..12 - type, bits 11..8 - family, bits 7..4 - model, bits 3..0 - mask revision
-      ;        ebx: 31..24 - default APIC ID, 23..16 - logical processsor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID
+      ;        ebx: 31..24 - default APIC ID, 23..16 - logical processor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID
       ;        edx: CPU feature flags
       mov eax,1
       CPUID_INSTRUCTION
@@ -1809,7 +1809,7 @@ bool SystemInformationImplementation::RetrieveCPUIdentity()
 
       ; <<CPUID>>
       ; eax = 1 --> eax: CPU ID - bits 31..16 - unused, bits 15..12 - type, bits 11..8 - family, bits 7..4 - model, bits 3..0 - mask revision
-      ;        ebx: 31..24 - default APIC ID, 23..16 - logical processsor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID
+      ;        ebx: 31..24 - default APIC ID, 23..16 - logical processor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID
       ;        edx: CPU feature flags
       mov eax,1
       CPUID_INSTRUCTION
@@ -2436,7 +2436,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures()
 #endif
       ; <<CPUID>>
       ; eax = 0x80000001 --> eax: CPU ID - bits 31..16 - unused, bits 15..12 - type, bits 11..8 - family, bits 7..4 - model, bits 3..0 - mask revision
-      ;             ebx: 31..24 - default APIC ID, 23..16 - logical processsor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID
+      ;             ebx: 31..24 - default APIC ID, 23..16 - logical processor ID, 15..8 - CFLUSH chunk size , 7..0 - brand ID
       ;             edx: CPU feature flags
       mov eax,0x80000001
       CPUID_INSTRUCTION
@@ -3073,7 +3073,7 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
     this->NumberOfLogicalCPU = atoi(cpucount.c_str());
 #endif
   // gotta have one, and if this is 0 then we get a / by 0n
-  // beter to have a bad answer than a crash
+  // better to have a bad answer than a crash
   if(this->NumberOfPhysicalCPU <= 0)
     {
     this->NumberOfPhysicalCPU = 1;
@@ -3082,7 +3082,7 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
   this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical=
       this->NumberOfLogicalCPU/this->NumberOfPhysicalCPU;
 
-  // CPU speed (checking only the first proc
+  // CPU speed (checking only the first processor)
   kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz");
   this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str()));
 
-- 
1.7.11.5

>From 8eff8ed92380844449f48a2701c469db2376d30c Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Sat, 8 Sep 2012 17:25:03 +0200
Subject: [PATCH 2/3] kwsys: sum up all caches found in /proc/cpuinfo

Non-x86 architectures (namely PA-RISC) may not have the "cache size" line, but
others. Search for all and sum up their results.
---
 Source/kwsys/SystemInformation.cxx | 26 +++++++++++++++++++++-----
 1 Datei geändert, 21 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 1077b11..7b50b74 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -3101,13 +3101,29 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
   this->ChipID.ModelName = this->ExtractValueFromCpuInfoFile(buffer,"model name").c_str();
 
   // L1 Cache size
-  kwsys_stl::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer,"cache size");
-  pos = cacheSize.find(" KB");
-  if(pos!=cacheSize.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 = 0;
+  for (int index = 0; index < cachename.size(); index ++)
     {
-    cacheSize = cacheSize.substr(0,pos);
+    kwsys_stl::string cacheSize = this->ExtractValueFromCpuInfoFile(buffer,cachename[index]);
+    if (!cacheSize.empty())
+      {
+      pos = cacheSize.find(" KB");
+      if(pos!=cacheSize.npos)
+        {
+        cacheSize = cacheSize.substr(0,pos);
+        }
+      this->Features.L1CacheSize += atoi(cacheSize.c_str());
+      }
     }
-  this->Features.L1CacheSize = atoi(cacheSize.c_str());
   return 1;
 }
 
-- 
1.7.11.5

>From f639d341de65086a45f6537f04f84d55336d635d Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Sat, 8 Sep 2012 18:40:17 +0200
Subject: [PATCH 3/3] kwsys: PA-RISC chips are from HP

---
 Source/kwsys/SystemInformation.cxx | 28 +++++++++++++++++++++++-----
 1 Datei geändert, 23 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-)

diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 7b50b74..15f2325 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -307,7 +307,7 @@ public:
   enum Manufacturer
     {
     AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM,
-    Motorola, UnknownManufacturer
+    Motorola, HP, UnknownManufacturer
     };
 
 protected:
@@ -346,7 +346,7 @@ protected:
   static void Delay (unsigned int);
   static void DelayOverhead (unsigned int);
 
-  void FindManufacturer();
+  void FindManufacturer(const kwsys_stl::string &family = "");
 
   // For Mac
   bool ParseSysCtl();
@@ -1415,6 +1415,8 @@ const char * SystemInformationImplementation::GetVendorID()
       return "IBM";
     case Motorola:
       return "Motorola";
+    case HP:
+      return "Hewlett-Packard";
     default:
       return "Unknown Manufacturer";
     }
@@ -1755,7 +1757,7 @@ bool SystemInformationImplementation::RetrieveCPUFeatures()
 
 
 /** Find the manufacturer given the vendor id */
-void SystemInformationImplementation::FindManufacturer()
+void SystemInformationImplementation::FindManufacturer(const kwsys_stl::string& family)
 {
   if (this->ChipID.Vendor == "GenuineIntel")       this->ChipManufacturer = Intel;        // Intel Corp.
   else if (this->ChipID.Vendor == "UMC UMC UMC ")  this->ChipManufacturer = UMC;          // United Microelectronics Corp.
@@ -1771,6 +1773,8 @@ void SystemInformationImplementation::FindManufacturer()
   else if (this->ChipID.Vendor == "Sun")           this->ChipManufacturer = Sun;          // Sun Microelectronics
   else if (this->ChipID.Vendor == "IBM")           this->ChipManufacturer = IBM;          // IBM Microelectronics
   else if (this->ChipID.Vendor == "Motorola")      this->ChipManufacturer = Motorola;          // Motorola Microelectronics
+  else if (family.substr(0, 7) == "PA-RISC")
+    this->ChipManufacturer = HP;           // Hewlett-Packard
   else                                             this->ChipManufacturer = UnknownManufacturer;  // Unknown manufacturer
 }
 
@@ -3087,11 +3091,25 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
   this->CPUSpeedInMHz = static_cast<float>(atof(CPUSpeed.c_str()));
 
   // Chip family
-  this->ChipID.Family = atoi(this->ExtractValueFromCpuInfoFile(buffer,"cpu family").c_str());
+  const kwsys_stl::string familyStr =
+    this->ExtractValueFromCpuInfoFile(buffer,"cpu family");
+  this->ChipID.Family = atoi(familyStr.c_str());
 
   // Chip Vendor
   this->ChipID.Vendor = this->ExtractValueFromCpuInfoFile(buffer,"vendor_id");
-  this->FindManufacturer();
+  this->FindManufacturer(familyStr);
+
+  // second try for setting family
+  if (this->ChipID.Family == 0 && this->ChipManufacturer == HP)
+    {
+    if (familyStr == "PA-RISC 1.1a")
+      this->ChipID.Family = 0x11a;
+    else if (familyStr == "PA-RISC 2.0")
+      this->ChipID.Family = 0x200;
+    // If you really get CMake to work on a machine not belonging to
+    // any of those families I owe you a dinner if you get it to
+    // contribute nightly builds regularly.
+    }
 
   // Chip Model
   this->ChipID.Model = atoi(this->ExtractValueFromCpuInfoFile(buffer,"model").c_str());
-- 
1.7.11.5

Attachment: signature.asc
Description: This is a digitally signed message part.

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to