[Cmake-commits] [cmake-commits] hoffman committed SystemInformation.cxx 1.43 1.44
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue May 19 21:50:22 EDT 2009
Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv26366
Modified Files:
SystemInformation.cxx
Log Message:
ENH: revert back because it does not build on older macs for now
Index: SystemInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemInformation.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -C 2 -d -r1.43 -r1.44
*** SystemInformation.cxx 19 May 2009 20:56:47 -0000 1.43
--- SystemInformation.cxx 20 May 2009 01:50:19 -0000 1.44
***************
*** 50,61 ****
#endif
- #ifdef __APPLE__
- #include <sys/sysctl.h>
- #include <mach/vm_statistics.h>
- #include <mach/host_info.h>
- #include <mach/mach.h>
- #include <mach/mach_types.h>
- #endif
-
#ifdef __linux
# include <sys/procfs.h>
--- 50,53 ----
***************
*** 204,208 ****
enum Manufacturer
{
! AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, IBM, Motorola, UnknownManufacturer
};
protected:
--- 196,200 ----
enum Manufacturer
{
! AMD, Intel, NSC, UMC, Cyrix, NexGen, IDT, Rise, Transmeta, Sun, UnknownManufacturer
};
protected:
***************
*** 638,645 ****
case Sun:
return "Sun Microelectronics";
- case IBM:
- return "IBM";
- case Motorola:
- return "Motorola";
default:
return "Unknown Manufacturer";
--- 630,633 ----
***************
*** 981,987 ****
else if (strcmp (this->ChipID.Vendor, "TransmetaCPU") == 0) this->ChipManufacturer = Transmeta; // Transmeta
else if (strcmp (this->ChipID.Vendor, "Geode By NSC") == 0) this->ChipManufacturer = NSC; // National Semiconductor
! else if (strcmp (this->ChipID.Vendor, "Sun") == 0) this->ChipManufacturer = Sun; // Sun Microelectronics
! else if (strcmp (this->ChipID.Vendor, "IBM") == 0) this->ChipManufacturer = IBM; // IBM Microelectronics
! else if (strcmp (this->ChipID.Vendor, "Motorola") == 0) this->ChipManufacturer = Motorola; // Motorola Microelectronics
else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer
}
--- 969,973 ----
else if (strcmp (this->ChipID.Vendor, "TransmetaCPU") == 0) this->ChipManufacturer = Transmeta; // Transmeta
else if (strcmp (this->ChipID.Vendor, "Geode By NSC") == 0) this->ChipManufacturer = NSC; // National Semiconductor
! else if (strcmp (this->ChipID.Vendor, "Sun") == 0) this->ChipManufacturer = Sun; // Sun Microelectronics
else this->ChipManufacturer = UnknownManufacturer; // Unknown manufacturer
}
***************
*** 1928,1932 ****
case 0xa: sprintf (this->ChipID.ProcessorName,"Pentium III (0.18 micron) With 1 Or 2 MB On-Die L2 Cache "); break;
case 0xb: sprintf (this->ChipID.ProcessorName,"Pentium III (0.13 micron) With 256 Or 512 KB On-Die L2 Cache "); break;
- case 23: sprintf (this->ChipID.ProcessorName, "Intel(R) Core(TM)2 Duo CPU T9500 @ 2.60GHz"); break;
default: sprintf (this->ChipID.ProcessorName,"Unknown P6 family"); return false;
}
--- 1914,1917 ----
***************
*** 2559,2576 ****
}
#endif
-
- #ifdef __APPLE__
- size_t len = 4;
- int cores_per_package = 0;
- int err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, NULL, 0);
- if (err != 0)
- {
- return 1; // That name was not found, default to 1
- }
- else
- {
- return static_cast<unsigned char>(cores_per_package);
- }
- #endif
return static_cast<unsigned char> ((Regebx & NUM_LOGICAL_BITS) >> 16);
}
--- 2544,2547 ----
***************
*** 2766,2873 ****
}
! /** For Mac use sysctlbyname calls to find system info */
bool SystemInformationImplementation::ParseSysCtl()
{
! #if defined(__APPLE__)
! int err = 0;
! uint64_t value = 0;
! size_t len = sizeof(value);
! sysctlbyname("hw.memsize", &value, &len, NULL, 0);
! this->TotalPhysicalMemory = value/1048576;
// Parse values for Mac
this->AvailablePhysicalMemory = 0;
! vm_statistics_data_t vmstat;
! mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
! if ( host_statistics(mach_host_self(), HOST_VM_INFO,
! (host_info_t) &vmstat, &count) == KERN_SUCCESS )
! {
! err = sysctlbyname("hw.pagesize", &value, &len, NULL, 0);
! int64_t available_memory = vmstat.free_count * value;
! this->AvailablePhysicalMemory = available_memory / 1048576;
! }
! // Virtual memory.
! int mib[2] = { CTL_VM, VM_SWAPUSAGE };
! size_t miblen = sizeof(mib) / sizeof(mib[0]);
! struct xsw_usage swap;
! len = sizeof(struct xsw_usage);
! err = sysctl(mib, miblen, &swap, &len, NULL, 0);
! if (err == 0)
{
! this->AvailableVirtualMemory = swap.xsu_avail/1048576;
! this->TotalVirtualMemory = swap.xsu_total/1048576;
}
! // CPU Info
! len = sizeof(this->NumberOfPhysicalCPU);
! sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, NULL, 0);
! sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, NULL, 0);
! this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical =
! this->LogicalCPUPerPhysicalCPU();
!
! len = sizeof(value);
! sysctlbyname("hw.cpufrequency", &value, &len, NULL, 0);
! this->CPUSpeedInMHz = value / 1048576;
!
// Chip family
! len = sizeof(this->ChipID.Family);
! //Seems only the intel chips will have this name so if this fails it is
! //probably a PPC machine
! err = sysctlbyname("machdep.cpu.family",
! &this->ChipID.Family, &len, NULL, 0);
! if (err != 0) // Go back to names we know but are less descriptive
! {
! this->ChipID.Family = 0;
! char retBuf[32];
! ::memset(retBuf, 0, 32);
! len = 32;
! err = sysctlbyname("hw.machine", &retBuf, &len, NULL, 0);
! kwsys_stl::string machineBuf(retBuf);
! if (machineBuf.find_first_of("Power") != kwsys_stl::string::npos)
! {
! strcpy(this->ChipID.Vendor, "IBM");
! len = 4;
! err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, NULL, 0);
! err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, NULL, 0);
! this->FindManufacturer();
! }
! }
! else // Should be an Intel Chip.
! {
! len = sizeof(this->ChipID.Family);
! int err =
! sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0);
!
! char retBuf[128];
! ::memset(retBuf, 0, 128);
! len = 128;
! err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, NULL, 0);
! // Chip Vendor
! strcpy(this->ChipID.Vendor,retBuf);
! this->FindManufacturer();
!
! len=CHIPNAME_STRING_LENGTH;
! err =
! sysctlbyname("machdep.cpu.brand_string",
! this->ChipID.ProcessorName, &len, NULL, 0);
- // Chip Model
- len = sizeof(value);
- err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0);
- this->ChipID.Model = value;
- }
// Cache size
! len = sizeof(value);
! err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0);
! this->Features.L1CacheSize = value;
! err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0);
! this->Features.L2CacheSize = value;
!
return true;
- #else
- return false;
- #endif
}
--- 2737,2785 ----
}
! /** For Mac we Parse the sysctl -a output */
bool SystemInformationImplementation::ParseSysCtl()
{
! // Extract the arguments from the command line
! kwsys_stl::vector<const char*> args;
! args.push_back("sysctl");
! args.push_back("-a");
! args.push_back(0);
+ this->SysCtlBuffer = this->RunProcess(args);
+
// Parse values for Mac
+ this->TotalPhysicalMemory = static_cast<unsigned long>(
+ atoi(this->ExtractValueFromSysCtl("hw.memsize:").c_str())/(1024*1024));
+ this->TotalVirtualMemory = 0;
this->AvailablePhysicalMemory = 0;
! this->AvailableVirtualMemory = 0;
! this->NumberOfPhysicalCPU = static_cast<unsigned int>(atoi(this->ExtractValueFromSysCtl("hw.physicalcpu:").c_str()));
! this->NumberOfLogicalCPU = static_cast<unsigned int>(atoi(this->ExtractValueFromSysCtl("hw.logicalcpu:").c_str()));
!
! if(this->NumberOfPhysicalCPU!=0)
{
! this->NumberOfLogicalCPU /= this->NumberOfPhysicalCPU;
}
! this->CPUSpeedInMHz = static_cast<float>(atoi(this->ExtractValueFromSysCtl("hw.cpufrequency:").c_str()));
! this->CPUSpeedInMHz /= 1000000;
// Chip family
! this->ChipID.Family = atoi(this->ExtractValueFromSysCtl("machdep.cpu.family:").c_str());
!
! // Chip Vendor
! strcpy(this->ChipID.Vendor,this->ExtractValueFromSysCtl("machdep.cpu.vendor:").c_str());
! this->FindManufacturer();
!
! // Chip Model
! this->ChipID.Model = atoi(this->ExtractValueFromSysCtl("machdep.cpu.model:").c_str());
! this->RetrieveClassicalCPUIdentity();
// Cache size
! this->Features.L1CacheSize = atoi(this->ExtractValueFromSysCtl("hw.l1icachesize:").c_str());
! this->Features.L2CacheSize = atoi(this->ExtractValueFromSysCtl("hw.l2cachesize:").c_str());
!
return true;
}
More information about the Cmake-commits
mailing list