mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-08 07:10:12 -05:00
KWSys 2022-11-06 (9aebb97f)
Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit 9aebb97f836b104b94d876df843889d9a1956612 (master).
Upstream Shortlog
-----------------
Ben Boeckel (1):
4226d5e5 Status: detect and diagnose X11 symbol conflicts
Brad King (1):
b72169e5 Process: Suppress clang -Wshorten-64-to-32 diagnostic on macOS
Clemens Wasser (1):
550b5734 SystemTools: Use unordered_map for path caches
Michael Hirsch (1):
f0223ad1 SystemInformation: correct function name spelling
This commit is contained in:
committed by
Brad King
parent
f98fa3e543
commit
ee9c09548c
@@ -2011,6 +2011,14 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__clang__) && defined(__has_warning)
|
||||||
|
# if __has_warning("-Wshorten-64-to-32")
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wshorten-64-to-32"
|
||||||
|
# define KWSYSPE_CLANG_DIAG_WSHORTEN
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get the length of time before the given timeout time arrives.
|
/* Get the length of time before the given timeout time arrives.
|
||||||
Returns 1 if the time has already arrived, and 0 otherwise. */
|
Returns 1 if the time has already arrived, and 0 otherwise. */
|
||||||
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
|
||||||
@@ -2061,6 +2069,11 @@ static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(KWSYSPE_CLANG_DIAG_WSHORTEN)
|
||||||
|
# undef KWSYSPE_CLANG_DIAG_WSHORTEN
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
static double kwsysProcessTimeToDouble(kwsysProcessTime t)
|
static double kwsysProcessTimeToDouble(kwsysProcessTime t)
|
||||||
{
|
{
|
||||||
return (double)t.tv_sec + (double)(t.tv_usec) * 0.000001;
|
return (double)t.tv_sec + (double)(t.tv_usec) * 0.000001;
|
||||||
|
|||||||
@@ -7,6 +7,16 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect a symbol collision with the name of this class. X11 headers use
|
||||||
|
* `#define Status int` instead of using `typedef` which poisons any other
|
||||||
|
* usage of this name.
|
||||||
|
*/
|
||||||
|
#if defined(Status) && defined(_X11_XLIB_H_)
|
||||||
|
# error \
|
||||||
|
"Status.hxx must be included *before* any X11 headers to avoid a collision with the `Status` define that is made in its API."
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace @KWSYS_NAMESPACE@ {
|
namespace @KWSYS_NAMESPACE@ {
|
||||||
|
|
||||||
/** \class Status
|
/** \class Status
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ protected:
|
|||||||
unsigned int); // For windows
|
unsigned int); // For windows
|
||||||
|
|
||||||
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
|
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
|
||||||
bool RetreiveInformationFromCpuInfoFile();
|
bool RetrieveInformationFromCpuInfoFile();
|
||||||
std::string ExtractValueFromCpuInfoFile(std::string buffer, const char* word,
|
std::string ExtractValueFromCpuInfoFile(std::string buffer, const char* word,
|
||||||
size_t init = 0);
|
size_t init = 0);
|
||||||
|
|
||||||
@@ -1520,7 +1520,7 @@ void SystemInformationImplementation::RunCPUCheck()
|
|||||||
#elif defined(__hpux)
|
#elif defined(__hpux)
|
||||||
this->QueryHPUXProcessor();
|
this->QueryHPUXProcessor();
|
||||||
#elif defined(__linux) || defined(__CYGWIN__)
|
#elif defined(__linux) || defined(__CYGWIN__)
|
||||||
this->RetreiveInformationFromCpuInfoFile();
|
this->RetrieveInformationFromCpuInfoFile();
|
||||||
#else
|
#else
|
||||||
this->QueryProcessor();
|
this->QueryProcessor();
|
||||||
#endif
|
#endif
|
||||||
@@ -3435,7 +3435,7 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Query for the cpu status */
|
/** Query for the cpu status */
|
||||||
bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
|
bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
|
||||||
{
|
{
|
||||||
this->NumberOfLogicalCPU = 0;
|
this->NumberOfLogicalCPU = 0;
|
||||||
this->NumberOfPhysicalCPU = 0;
|
this->NumberOfPhysicalCPU = 0;
|
||||||
|
|||||||
+34
-6
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <cwchar>
|
# include <cwchar>
|
||||||
|
# include <unordered_map>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Work-around CMake dependency scanning limitation. This must
|
// Work-around CMake dependency scanning limitation. This must
|
||||||
@@ -506,16 +507,39 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct SystemToolsPathCaseCmp
|
# if defined(_WIN64)
|
||||||
|
static constexpr size_t FNV_OFFSET_BASIS = 14695981039346656037ULL;
|
||||||
|
static constexpr size_t FNV_PRIME = 1099511628211ULL;
|
||||||
|
# else
|
||||||
|
static constexpr size_t FNV_OFFSET_BASIS = 2166136261U;
|
||||||
|
static constexpr size_t FNV_PRIME = 16777619U;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// Case insensitive Fnv1a hash
|
||||||
|
struct SystemToolsPathCaseHash
|
||||||
|
{
|
||||||
|
size_t operator()(std::string const& path) const
|
||||||
|
{
|
||||||
|
size_t hash = FNV_OFFSET_BASIS;
|
||||||
|
for (auto c : path) {
|
||||||
|
hash ^= static_cast<size_t>(std::tolower(c));
|
||||||
|
hash *= FNV_PRIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SystemToolsPathCaseEqual
|
||||||
{
|
{
|
||||||
bool operator()(std::string const& l, std::string const& r) const
|
bool operator()(std::string const& l, std::string const& r) const
|
||||||
{
|
{
|
||||||
# ifdef _MSC_VER
|
# ifdef _MSC_VER
|
||||||
return _stricmp(l.c_str(), r.c_str()) < 0;
|
return _stricmp(l.c_str(), r.c_str()) == 0;
|
||||||
# elif defined(__GNUC__)
|
# elif defined(__GNUC__)
|
||||||
return strcasecmp(l.c_str(), r.c_str()) < 0;
|
return strcasecmp(l.c_str(), r.c_str()) == 0;
|
||||||
# else
|
# else
|
||||||
return SystemTools::Strucmp(l.c_str(), r.c_str()) < 0;
|
return SystemTools::Strucmp(l.c_str(), r.c_str()) == 0;
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -540,8 +564,12 @@ public:
|
|||||||
bool const cache);
|
bool const cache);
|
||||||
static std::string GetActualCaseForPathCached(std::string const& path);
|
static std::string GetActualCaseForPathCached(std::string const& path);
|
||||||
static const char* GetEnvBuffered(const char* key);
|
static const char* GetEnvBuffered(const char* key);
|
||||||
std::map<std::string, std::string, SystemToolsPathCaseCmp> FindFileMap;
|
std::unordered_map<std::string, std::string, SystemToolsPathCaseHash,
|
||||||
std::map<std::string, std::string, SystemToolsPathCaseCmp> PathCaseMap;
|
SystemToolsPathCaseEqual>
|
||||||
|
FindFileMap;
|
||||||
|
std::unordered_map<std::string, std::string, SystemToolsPathCaseHash,
|
||||||
|
SystemToolsPathCaseEqual>
|
||||||
|
PathCaseMap;
|
||||||
std::map<std::string, std::string> EnvMap;
|
std::map<std::string, std::string> EnvMap;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
|
|||||||
Reference in New Issue
Block a user