[Cmake-commits] CMake branch, next, updated. v2.8.10.2-1601-g0e1e6e3

Brad King brad.king at kitware.com
Mon Jan 14 09:52:03 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  0e1e6e37210efaf68809c24d7adc47be026376a8 (commit)
       via  e2c756fcf06058249392d7daba4f6740dd437d2b (commit)
       via  4ba0ac7be4bbe38a7cb3334504e69db039288ad8 (commit)
      from  db1098843424b5f3553600799f162aa08214ecb3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0e1e6e37210efaf68809c24d7adc47be026376a8
commit 0e1e6e37210efaf68809c24d7adc47be026376a8
Merge: db10988 e2c756f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jan 14 09:51:58 2013 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Jan 14 09:51:58 2013 -0500

    Merge topic 'update-kwsys' into next
    
    e2c756f Merge branch 'upstream-kwsys' into update-kwsys
    4ba0ac7 KWSys 2013-01-14 (6fa1c99f)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e2c756fcf06058249392d7daba4f6740dd437d2b
commit e2c756fcf06058249392d7daba4f6740dd437d2b
Merge: 6f57a90 4ba0ac7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Jan 14 09:41:52 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jan 14 09:41:52 2013 -0500

    Merge branch 'upstream-kwsys' into update-kwsys


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ba0ac7be4bbe38a7cb3334504e69db039288ad8
commit 4ba0ac7be4bbe38a7cb3334504e69db039288ad8
Author:     KWSys Robot <kwrobot at kitware.com>
AuthorDate: Mon Jan 14 09:26:01 2013 -0500
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Jan 14 09:41:45 2013 -0500

    KWSys 2013-01-14 (6fa1c99f)
    
    Extract upstream KWSys using the following shell commands.
    
    $ git archive --prefix=upstream-kwsys/ 6fa1c99f | tar x
    $ git shortlog --no-merges --abbrev=8 --format='%h %s' 608d6b47..6fa1c99f
    Brad King (1):
          84827cc1 Process: Avoid argv[0]==NULL from parsing empty command line
    
    Rolf Eike Beer (8):
          e041cd66 SystemInformation: factor out QueryMemoryBySysconf()
          ea850fa0 SystemInformation: factor out QueryProcessorBySysconf()
          57f06d49 SystemInformation: count processors with sysconf() on Solaris
          c6057a06 SystemInformation: fix "Multi-character character constant"
          5a27bd4f SystemInformation: make IsHyperThreadingSupported() return bool
          342c0ad2 SystemInformation: query memory size with sysconf() on Solaris
          f0b857c1 SystemInformation: cache result of IsHyperThreadingSupported()
          ab0c2a09 SystemInformation: try using assembler with BorlandC
    
    Change-Id: I072371ed35eed892a5ef62a9e9e6cad734e961d9

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5df5a74..124b8ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -574,6 +574,8 @@ IF(KWSYS_USE_SystemTools)
 ENDIF()
 
 IF(KWSYS_USE_SystemInformation)
+  SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+    COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
   IF(NOT CYGWIN)
     INCLUDE(CheckIncludeFiles)
     CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H)
@@ -638,6 +640,20 @@ IF(KWSYS_USE_SystemInformation)
     SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
       COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1)
   ENDIF()
+  IF(BORLAND)
+    KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM
+      "Checking whether Borland CXX compiler supports assembler instructions" DIRECT)
+    IF(KWSYS_CXX_HAS_BORLAND_ASM)
+      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+        COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM=1)
+      KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM_CPUID
+        "Checking whether Borland CXX compiler supports CPUID assembler instruction" DIRECT)
+      IF(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
+        SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
+          COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM_CPUID=1)
+      ENDIF()
+    ENDIF()
+  ENDIF()
   IF(KWSYS_USE___INT64)
     SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
       COMPILE_DEFINITIONS KWSYS_USE___INT64=1)
diff --git a/ProcessUNIX.c b/ProcessUNIX.c
index 83838af..2db1254 100644
--- a/ProcessUNIX.c
+++ b/ProcessUNIX.c
@@ -418,9 +418,10 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
        parse it.  */
     newCommands[cp->NumberOfCommands] =
       kwsysSystem_Parse_CommandForUnix(*command, 0);
-    if(!newCommands[cp->NumberOfCommands])
+    if(!newCommands[cp->NumberOfCommands] ||
+       !newCommands[cp->NumberOfCommands][0])
       {
-      /* Out of memory.  */
+      /* Out of memory or no command parsed.  */
       free(newCommands);
       return 0;
       }
diff --git a/SystemInformation.cxx b/SystemInformation.cxx
index 59a9abe..b20d724 100644
--- a/SystemInformation.cxx
+++ b/SystemInformation.cxx
@@ -202,7 +202,7 @@ typedef struct rlimit ResourceLimitType;
 #define USE_CPUID_INTRINSICS 0
 #endif
 
-#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS
+#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS || defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
 # define USE_CPUID 1
 #else
 # define USE_CPUID 0
@@ -224,6 +224,7 @@ static bool call_cpuid(int select, int result[4])
   return true;
 #else
   int tmp[4];
+#if defined(_MSC_VER)
   // Use SEH to determine CPUID presence
   __try {
     _asm {
@@ -262,7 +263,24 @@ static bool call_cpuid(int select, int result[4])
     return false;
     }
 
-  memcpy(result, tmp, sizeof(tmp));
+    memcpy(result, tmp, sizeof(tmp));
+#elif defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
+  unsigned int a, b, c, d;
+  __asm {
+    mov EAX, select;
+    cpuid
+    mov a, EAX;
+    mov b, EBX;
+    mov c, ECX;
+    mov d, EDX;
+  }
+
+  result[0] = a;
+  result[1] = b;
+  result[2] = c;
+  result[3] = d;
+#endif
+
   // The cpuid instruction succeeded.
   return true;
 #endif
@@ -432,7 +450,7 @@ protected:
   int CPUCount();
   unsigned char LogicalCPUPerPhysicalCPU();
   unsigned char GetAPICId();
-  unsigned int IsHyperThreadingSupported();
+  bool IsHyperThreadingSupported();
   static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int);
 
   // For Linux and Cygwin, /proc/cpuinfo formats are slightly different
@@ -456,7 +474,8 @@ protected:
   kwsys_stl::string SysCtlBuffer;
 
   // For Solaris
-  bool QuerySolarisInfo();
+  bool QuerySolarisMemory();
+  bool QuerySolarisProcessor();
   kwsys_stl::string ParseValueFromKStat(const char* arguments);
   kwsys_stl::string RunProcess(kwsys_stl::vector<const char*> args);
 
@@ -481,9 +500,11 @@ protected:
   //For AIX
   bool QueryAIXMemory();
 
+  bool QueryProcessorBySysconf();
   bool QueryProcessor();
 
   // Evaluate the memory information.
+  bool QueryMemoryBySysconf();
   bool QueryMemory();
   size_t TotalVirtualMemory;
   size_t AvailableVirtualMemory;
@@ -1287,7 +1308,7 @@ void SystemInformationImplementation::RunCPUCheck()
 #elif defined(__APPLE__)
   this->ParseSysCtl();
 #elif defined (__SVR4) && defined (__sun)
-  this->QuerySolarisInfo();
+  this->QuerySolarisProcessor();
 #elif defined(__HAIKU__)
   this->QueryHaikuInfo();
 #elif defined(__QNX__)
@@ -1313,7 +1334,7 @@ void SystemInformationImplementation::RunMemoryCheck()
 #if defined(__APPLE__)
   this->ParseSysCtl();
 #elif defined (__SVR4) && defined (__sun)
-  this->QuerySolarisInfo();
+  this->QuerySolarisMemory();
 #elif defined(__HAIKU__)
   this->QueryHaikuInfo();
 #elif defined(__QNX__)
@@ -3016,7 +3037,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
   return true;
 }
 
-bool SystemInformationImplementation::QueryProcessor()
+bool SystemInformationImplementation::QueryProcessorBySysconf()
 {
 #if defined(_SC_NPROC_ONLN) && !defined(_SC_NPROCESSORS_ONLN)
 // IRIX names this slightly different
@@ -3039,6 +3060,11 @@ bool SystemInformationImplementation::QueryProcessor()
 #endif
 }
 
+bool SystemInformationImplementation::QueryProcessor()
+{
+  return this->QueryProcessorBySysconf();
+}
+
 /**
 Get total system RAM in units of KiB.
 */
@@ -3559,8 +3585,7 @@ bool SystemInformationImplementation::QueryAIXMemory()
 #endif
 }
 
-/** Query for the memory status */
-bool SystemInformationImplementation::QueryMemory()
+bool SystemInformationImplementation::QueryMemoryBySysconf()
 {
 #if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
   // Assume the mmap() granularity as returned by _SC_PAGESIZE is also
@@ -3597,6 +3622,12 @@ bool SystemInformationImplementation::QueryMemory()
 #endif
 }
 
+/** Query for the memory status */
+bool SystemInformationImplementation::QueryMemory()
+{
+  return this->QueryMemoryBySysconf();
+}
+
 /** */
 size_t SystemInformationImplementation::GetTotalVirtualMemory()
 {
@@ -3729,8 +3760,13 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void)
 
 
 /** Works only for windows */
-unsigned int SystemInformationImplementation::IsHyperThreadingSupported()
+bool SystemInformationImplementation::IsHyperThreadingSupported()
 {
+  if (this->Features.ExtendedFeatures.SupportsHyperthreading)
+    {
+    return true;
+    }
+
 #if USE_CPUID
   int Regs[4] = { 0, 0, 0, 0 },
              VendorId[4] = { 0, 0, 0, 0 };
@@ -3748,13 +3784,15 @@ unsigned int SystemInformationImplementation::IsHyperThreadingSupported()
 
   if (((Regs[0] & FAMILY_ID) == PENTIUM4_ID) || (Regs[0] & EXT_FAMILY_ID))
     {
-    if (VendorId[1] == 'uneG')
+    if (VendorId[1] == 0x756e6547) // 'uneG'
       {
-      if (VendorId[3] == 'Ieni')
+      if (VendorId[3] == 0x49656e69) // 'Ieni'
         {
-        if (VendorId[2] == 'letn')
+        if (VendorId[2] == 0x6c65746e) // 'letn'
           {
-          return(Regs[3] & HT_BIT);    // Genuine Intel with hyper-Threading technology
+          // Genuine Intel with hyper-Threading technology
+          this->Features.ExtendedFeatures.SupportsHyperthreading = ((Regs[3] & HT_BIT) != 0);
+          return this->Features.ExtendedFeatures.SupportsHyperthreading;
           }
         }
       }
@@ -4251,16 +4289,40 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha
   return value;
 }
 
-
 /** Querying for system information from Solaris */
-bool SystemInformationImplementation::QuerySolarisInfo()
+bool SystemInformationImplementation::QuerySolarisMemory()
 {
-  // Parse values
-  this->NumberOfPhysicalCPU = static_cast<unsigned int>(
-    atoi(this->ParseValueFromKStat("-n syste_misc -s ncpus").c_str()));
-  this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU;
-  this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = 1;
+#if defined (__SVR4) && defined (__sun)
+  // Solaris allows querying this value by sysconf, but if this is
+  // a 32 bit process on a 64 bit host the returned memory will be
+  // limited to 4GiB. So if this is a 32 bit process or if the sysconf
+  // method fails use the kstat interface.
+#if SIZEOF_VOID_P == 8
+  if (this->QueryMemoryBySysconf())
+    {
+    return true;
+    }
+#endif
 
+  char* tail;
+  unsigned long totalMemory =
+       strtoul(this->ParseValueFromKStat("-s physmem").c_str(),&tail,0);
+  this->TotalPhysicalMemory = totalMemory/128;
+
+  return true;
+#else
+  return false;
+#endif
+}
+
+bool SystemInformationImplementation::QuerySolarisProcessor()
+{
+  if (!this->QueryProcessorBySysconf())
+    {
+    return false;
+    }
+
+  // Parse values
   this->CPUSpeedInMHz = static_cast<float>(atoi(this->ParseValueFromKStat("-s clock_MHz").c_str()));
 
   // Chip family
@@ -4277,20 +4339,6 @@ bool SystemInformationImplementation::QuerySolarisInfo()
     this->FindManufacturer();
     }
 
-  // Cache size
-  this->Features.L1CacheSize = 0;
-  this->Features.L2CacheSize = 0;
-
-  char* tail;
-  unsigned long totalMemory =
-       strtoul(this->ParseValueFromKStat("-s physmem").c_str(),&tail,0);
-  this->TotalPhysicalMemory = totalMemory/128;
-
-  // Undefined values (for now at least)
-  this->TotalVirtualMemory = 0;
-  this->AvailablePhysicalMemory = 0;
-  this->AvailableVirtualMemory = 0;
-
   return true;
 }
 
diff --git a/kwsysPlatformTestsCXX.cxx b/kwsysPlatformTestsCXX.cxx
index ae58703..48976c4 100644
--- a/kwsysPlatformTestsCXX.cxx
+++ b/kwsysPlatformTestsCXX.cxx
@@ -580,3 +580,30 @@ int main()
     }
 }
 #endif
+
+#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM
+int main()
+{
+  int a = 1;
+  __asm {
+    xor EBX, EBX;
+    mov a, EBX;
+  }
+
+  return a;
+}
+#endif
+
+#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM_CPUID
+int main()
+{
+  int a = 0;
+  __asm {
+    xor EAX, EAX;
+    cpuid;
+    mov a, EAX;
+  }
+
+  return a;
+}
+#endif

-----------------------------------------------------------------------

Summary of changes:
 Source/kwsys/CMakeLists.txt            |   16 ++++
 Source/kwsys/ProcessUNIX.c             |    5 +-
 Source/kwsys/SystemInformation.cxx     |  118 ++++++++++++++++++++++----------
 Source/kwsys/kwsysPlatformTestsCXX.cxx |   27 +++++++
 4 files changed, 129 insertions(+), 37 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list