From 3572c54d2830879e434751b07e668c10d5590d8e Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer <eike@sf-mail.de> Date: Thu, 20 Dec 2012 23:26:33 +0100 Subject: [PATCH] SystemInformation: count CPUs on HP-UX Change-Id: Ib480a8295d817f84219a747744b84b148a3d8d9a --- CMakeLists.txt | 7 +++++++ SystemInformation.cxx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccdff12..6bfcab0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -596,6 +596,13 @@ IF(KWSYS_USE_SystemInformation) ENDIF() ENDIF() ENDIF() + IF(CMAKE_SYSTEM MATCHES "HP-UX") + CHECK_INCLUDE_FILES("sys/mpctl.h" KWSYS_SYS_HAS_MPCTL_H) + IF(KWSYS_SYS_HAS_MPCTL_H) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1) + ENDIF() + ENDIF() IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1) ENDIF() diff --git a/SystemInformation.cxx b/SystemInformation.cxx index b418e12..efcd8cc 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -142,6 +142,9 @@ typedef struct rlimit ResourceLimitType; #elif defined( __hpux ) # include <sys/param.h> # include <sys/pstat.h> +# if defined(KWSYS_SYS_HAS_MPCTL_H) +# include <sys/mpctl.h> +# endif #endif #ifdef __HAIKU__ @@ -461,6 +464,9 @@ protected: bool QueryBSDMemory(); bool QueryBSDProcessor(); + //For HP-UX + bool QueryHPUXProcessor(); + // Evaluate the memory information. int QueryMemory(); size_t TotalVirtualMemory; @@ -1272,6 +1278,8 @@ void SystemInformationImplementation::RunCPUCheck() this->QueryQNXProcessor(); #elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) this->QueryBSDProcessor(); +#elif defined(__hpux) + this->QueryHPUXProcessor(); #else this->RetreiveInformationFromCpuInfoFile(); #endif @@ -4267,6 +4275,28 @@ bool SystemInformationImplementation::QueryBSDProcessor() #endif } +bool SystemInformationImplementation::QueryHPUXProcessor() +{ +#if defined(__hpux) +# if defined(KWSYS_SYS_HAS_MPCTL_H) + int c = mpctl(MPC_GETNUMSPUS_SYS, 0, 0); + if (c <= 0) + { + return false; + } + + this->NumberOfPhysicalCPU = c; + this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU; + + return true; +# else + return false; +# endif +#else + return false; +#endif +} + /** Query the operating system information */ bool SystemInformationImplementation::QueryOSInformation() { -- GitLab