summaryrefslogtreecommitdiffstats
path: root/SystemInformation.cxx
diff options
context:
space:
mode:
authorKWSys Upstream <kwrobot@kitware.com>2017-03-07 18:33:51 (GMT)
committerBrad King <brad.king@kitware.com>2017-03-10 21:24:52 (GMT)
commit8ba8b5537cdee251d412c331267822badc8fafdc (patch)
treee64a8e0e8def4187d7f6ac76245d639df9c5b0cc /SystemInformation.cxx
parentced3396d048c8389327f661a99986fef51ee8a3f (diff)
downloadCMake-8ba8b5537cdee251d412c331267822badc8fafdc.zip
CMake-8ba8b5537cdee251d412c331267822badc8fafdc.tar.gz
CMake-8ba8b5537cdee251d412c331267822badc8fafdc.tar.bz2
KWSys 2017-03-07 (5da8cfe0)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 5da8cfe0544f95697808b0b46ed3183621902f0b (master). Upstream Shortlog ----------------- Ben Boeckel (1): c5529406 SystemTools: use std::string::empty Robert Maynard (1): 27e64d34 SystemInformation: Teach Is64Bits to check host architecture at runtime
Diffstat (limited to 'SystemInformation.cxx')
-rw-r--r--SystemInformation.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/SystemInformation.cxx b/SystemInformation.cxx
index 86f7552..93312e9 100644
--- a/SystemInformation.cxx
+++ b/SystemInformation.cxx
@@ -539,6 +539,7 @@ protected:
std::string OSRelease;
std::string OSVersion;
std::string OSPlatform;
+ bool OSIs64Bit;
};
SystemInformation::SystemInformation()
@@ -1499,6 +1500,7 @@ SystemInformationImplementation::SystemInformationImplementation()
this->OSRelease = "";
this->OSVersion = "";
this->OSPlatform = "";
+ this->OSIs64Bit = (sizeof(void*) == 8);
}
SystemInformationImplementation::~SystemInformationImplementation()
@@ -5320,10 +5322,20 @@ bool SystemInformationImplementation::QueryOSInformation()
this->Hostname = name;
const char* arch = getenv("PROCESSOR_ARCHITECTURE");
+ const char* wow64 = getenv("PROCESSOR_ARCHITEW6432");
if (arch) {
this->OSPlatform = arch;
}
+ if (wow64) {
+ // the PROCESSOR_ARCHITEW6432 is only defined when running 32bit programs
+ // on 64bit OS
+ this->OSIs64Bit = true;
+ } else if (arch) {
+ // all values other than x86 map to 64bit architectures
+ this->OSIs64Bit = (strncmp(arch, "x86", 3) != 0);
+ }
+
#else
struct utsname unameInfo;
@@ -5334,6 +5346,12 @@ bool SystemInformationImplementation::QueryOSInformation()
this->OSRelease = unameInfo.release;
this->OSVersion = unameInfo.version;
this->OSPlatform = unameInfo.machine;
+
+ // This is still insufficient to capture 64bit architecture such
+ // powerpc and possible mips and sparc
+ if (this->OSPlatform.find_first_of("64") != std::string::npos) {
+ this->OSIs64Bit = true;
+ }
}
#ifdef __APPLE__
@@ -5387,6 +5405,6 @@ void SystemInformationImplementation::TrimNewline(std::string& output)
/** Return true if the machine is 64 bits */
bool SystemInformationImplementation::Is64Bits()
{
- return (sizeof(void*) == 8);
+ return this->OSIs64Bit;
}
}