Merge branch 'upstream-KWSys' into update-kwsys

# By KWSys Upstream
* upstream-KWSys:
  KWSys 2022-11-06 (9aebb97f)
This commit is contained in:
Brad King
2022-11-06 08:33:10 -05:00
4 changed files with 60 additions and 9 deletions

View File

@@ -2011,6 +2011,14 @@ static int kwsysProcessGetTimeoutTime(kwsysProcess* cp,
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.
Returns 1 if the time has already arrived, and 0 otherwise. */
static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
@@ -2061,6 +2069,11 @@ static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
return current;
}
#if defined(KWSYSPE_CLANG_DIAG_WSHORTEN)
# undef KWSYSPE_CLANG_DIAG_WSHORTEN
# pragma clang diagnostic pop
#endif
static double kwsysProcessTimeToDouble(kwsysProcessTime t)
{
return (double)t.tv_sec + (double)(t.tv_usec) * 0.000001;

View File

@@ -7,6 +7,16 @@
#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@ {
/** \class Status

View File

@@ -482,7 +482,7 @@ protected:
unsigned int); // For windows
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
bool RetreiveInformationFromCpuInfoFile();
bool RetrieveInformationFromCpuInfoFile();
std::string ExtractValueFromCpuInfoFile(std::string buffer, const char* word,
size_t init = 0);
@@ -1520,7 +1520,7 @@ void SystemInformationImplementation::RunCPUCheck()
#elif defined(__hpux)
this->QueryHPUXProcessor();
#elif defined(__linux) || defined(__CYGWIN__)
this->RetreiveInformationFromCpuInfoFile();
this->RetrieveInformationFromCpuInfoFile();
#else
this->QueryProcessor();
#endif
@@ -3435,7 +3435,7 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(
}
/** Query for the cpu status */
bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
{
this->NumberOfLogicalCPU = 0;
this->NumberOfPhysicalCPU = 0;

View File

@@ -36,6 +36,7 @@
#ifdef _WIN32
# include <cwchar>
# include <unordered_map>
#endif
// Work-around CMake dependency scanning limitation. This must
@@ -506,16 +507,39 @@ public:
};
#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
{
# ifdef _MSC_VER
return _stricmp(l.c_str(), r.c_str()) < 0;
return _stricmp(l.c_str(), r.c_str()) == 0;
# elif defined(__GNUC__)
return strcasecmp(l.c_str(), r.c_str()) < 0;
return strcasecmp(l.c_str(), r.c_str()) == 0;
# else
return SystemTools::Strucmp(l.c_str(), r.c_str()) < 0;
return SystemTools::Strucmp(l.c_str(), r.c_str()) == 0;
# endif
}
};
@@ -540,8 +564,12 @@ public:
bool const cache);
static std::string GetActualCaseForPathCached(std::string const& path);
static const char* GetEnvBuffered(const char* key);
std::map<std::string, std::string, SystemToolsPathCaseCmp> FindFileMap;
std::map<std::string, std::string, SystemToolsPathCaseCmp> PathCaseMap;
std::unordered_map<std::string, std::string, SystemToolsPathCaseHash,
SystemToolsPathCaseEqual>
FindFileMap;
std::unordered_map<std::string, std::string, SystemToolsPathCaseHash,
SystemToolsPathCaseEqual>
PathCaseMap;
std::map<std::string, std::string> EnvMap;
#endif
#ifdef __CYGWIN__