diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:20:27 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-10-08 09:20:27 +0900 |
commit | f7fbee1ce7e4f73a5a46681cf010a9ac85c3ad87 (patch) | |
tree | a0d779b32b006b5dbbc54a95cce0cd5d0309eebf /Source/cmFileTime.h | |
parent | 50e508f0913d5580aa156327527da3d29a66b90c (diff) | |
download | cmake-f7fbee1ce7e4f73a5a46681cf010a9ac85c3ad87.tar.gz cmake-f7fbee1ce7e4f73a5a46681cf010a9ac85c3ad87.tar.bz2 cmake-f7fbee1ce7e4f73a5a46681cf010a9ac85c3ad87.zip |
Imported Upstream version 3.19.1upstream/3.19.1
Diffstat (limited to 'Source/cmFileTime.h')
-rw-r--r-- | Source/cmFileTime.h | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/Source/cmFileTime.h b/Source/cmFileTime.h index f496cdc82..441988065 100644 --- a/Source/cmFileTime.h +++ b/Source/cmFileTime.h @@ -13,9 +13,15 @@ class cmFileTime { public: - using NSC = long long; - static constexpr NSC NsPerS = 1000000000; - + using TimeType = long long; + // unit time per second +#if !defined(_WIN32) || defined(__CYGWIN__) + // unit time is one nanosecond + static constexpr TimeType UtPerS = 1000000000; +#else + // unit time is 100 nanosecond + static constexpr TimeType UtPerS = 10000000; +#endif cmFileTime() = default; ~cmFileTime() = default; @@ -28,22 +34,28 @@ public: /** * @brief Return true if this is older than ftm */ - bool Older(cmFileTime const& ftm) const { return (this->NS - ftm.NS) < 0; } + bool Older(cmFileTime const& ftm) const + { + return (this->Time - ftm.Time) < 0; + } /** * @brief Return true if this is newer than ftm */ - bool Newer(cmFileTime const& ftm) const { return (ftm.NS - this->NS) < 0; } + bool Newer(cmFileTime const& ftm) const + { + return (ftm.Time - this->Time) < 0; + } /** * @brief Return true if this is the same as ftm */ - bool Equal(cmFileTime const& ftm) const { return this->NS == ftm.NS; } + bool Equal(cmFileTime const& ftm) const { return this->Time == ftm.Time; } /** * @brief Return true if this is not the same as ftm */ - bool Differ(cmFileTime const& ftm) const { return this->NS != ftm.NS; } + bool Differ(cmFileTime const& ftm) const { return this->Time != ftm.Time; } /** * @brief Compare file modification times. @@ -51,7 +63,7 @@ public: */ int Compare(cmFileTime const& ftm) const { - NSC const diff = this->NS - ftm.NS; + TimeType const diff = this->Time - ftm.Time; if (diff == 0) { return 0; } @@ -65,7 +77,7 @@ public: */ bool OlderS(cmFileTime const& ftm) const { - return (ftm.NS - this->NS) >= cmFileTime::NsPerS; + return (ftm.Time - this->Time) >= cmFileTime::UtPerS; } /** @@ -73,7 +85,7 @@ public: */ bool NewerS(cmFileTime const& ftm) const { - return (this->NS - ftm.NS) >= cmFileTime::NsPerS; + return (this->Time - ftm.Time) >= cmFileTime::UtPerS; } /** @@ -81,11 +93,11 @@ public: */ bool EqualS(cmFileTime const& ftm) const { - NSC diff = this->NS - ftm.NS; + TimeType diff = this->Time - ftm.Time; if (diff < 0) { diff = -diff; } - return (diff < cmFileTime::NsPerS); + return (diff < cmFileTime::UtPerS); } /** @@ -93,11 +105,11 @@ public: */ bool DifferS(cmFileTime const& ftm) const { - NSC diff = this->NS - ftm.NS; + TimeType diff = this->Time - ftm.Time; if (diff < 0) { diff = -diff; } - return (diff >= cmFileTime::NsPerS); + return (diff >= cmFileTime::UtPerS); } /** @@ -107,21 +119,21 @@ public: */ int CompareS(cmFileTime const& ftm) const { - NSC const diff = this->NS - ftm.NS; - if (diff <= -cmFileTime::NsPerS) { + TimeType const diff = this->Time - ftm.Time; + if (diff <= -cmFileTime::UtPerS) { return -1; } - if (diff >= cmFileTime::NsPerS) { + if (diff >= cmFileTime::UtPerS) { return 1; } return 0; } /** - * @brief The file modification time in nanoseconds + * @brief The file modification time in unit time per second */ - NSC GetNS() const { return this->NS; } + TimeType GetTime() const { return this->Time; } private: - NSC NS = 0; + TimeType Time = 0; }; |