summaryrefslogtreecommitdiffstats
path: root/Source/cmFileTimeComparison.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-10-08 17:37:37 (GMT)
committerBrad King <brad.king@kitware.com>2015-10-08 17:37:37 (GMT)
commit8d27b407787549a90d47d273a753bb0000e5e73e (patch)
treeca451d334cd4f68290fd3bfca449c4c38fecf7f0 /Source/cmFileTimeComparison.cxx
parent0faccb839a75ab94f1ab39681a1ebe567647be6b (diff)
downloadCMake-8d27b407787549a90d47d273a753bb0000e5e73e.zip
CMake-8d27b407787549a90d47d273a753bb0000e5e73e.tar.gz
CMake-8d27b407787549a90d47d273a753bb0000e5e73e.tar.bz2
cmFileTimeComparison: Port to OS X nanosecond times (#15769)
Diffstat (limited to 'Source/cmFileTimeComparison.cxx')
-rw-r--r--Source/cmFileTimeComparison.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 8d5e08d..279b61d 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -166,6 +166,24 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
{
return 1;
}
+# elif CMake_STAT_HAS_ST_MTIMESPEC
+ // Compare using nanosecond resolution.
+ if(s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec)
+ {
+ return -1;
+ }
+ else if(s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec)
+ {
+ return 1;
+ }
+ else if(s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec)
+ {
+ return -1;
+ }
+ else if(s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec)
+ {
+ return 1;
+ }
# else
// Compare using 1 second resolution.
if(s1->st_mtime < s2->st_mtime)
@@ -207,6 +225,23 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
{
return false;
}
+# elif CMake_STAT_HAS_ST_MTIMESPEC
+ // Times are integers in units of 1ns.
+ long long bil = 1000000000;
+ long long t1 = s1->st_mtimespec.tv_sec * bil + s1->st_mtimespec.tv_nsec;
+ long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec;
+ if(t1 < t2)
+ {
+ return (t2 - t1) >= bil;
+ }
+ else if(t2 < t1)
+ {
+ return (t1 - t2) >= bil;
+ }
+ else
+ {
+ return false;
+ }
# else
// Times are integers in units of 1s.
if(s1->st_mtime < s2->st_mtime)