diff options
author | Brad King <brad.king@kitware.com> | 2022-11-06 13:33:10 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-11-06 13:33:10 (GMT) |
commit | 0d35f598d9841a944e030c0b9a5e6439ca0f8674 (patch) | |
tree | 7d8e4af2b8dd97c619839ecfccc601c4f137caaf /Source | |
parent | b46f582bc399211dc0b4dbda8d2b57d8d1cd59a8 (diff) | |
parent | ee9c09548cf4fa8c7edf0eb53494367fc17c859a (diff) | |
download | CMake-0d35f598d9841a944e030c0b9a5e6439ca0f8674.zip CMake-0d35f598d9841a944e030c0b9a5e6439ca0f8674.tar.gz CMake-0d35f598d9841a944e030c0b9a5e6439ca0f8674.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream
* upstream-KWSys:
KWSys 2022-11-06 (9aebb97f)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/kwsys/ProcessUNIX.c | 13 | ||||
-rw-r--r-- | Source/kwsys/Status.hxx.in | 10 | ||||
-rw-r--r-- | Source/kwsys/SystemInformation.cxx | 6 | ||||
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 40 |
4 files changed, 60 insertions, 9 deletions
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 45a9e6f..b25b258 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -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; diff --git a/Source/kwsys/Status.hxx.in b/Source/kwsys/Status.hxx.in index 16efaef..7cef029 100644 --- a/Source/kwsys/Status.hxx.in +++ b/Source/kwsys/Status.hxx.in @@ -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 diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index e6cc48f..20e2edb 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -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; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index a20901c..fdd6b2d 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -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__ |