]> granicus.if.org Git - llvm/commitdiff
[Chrono] Fix !HAVE_FUTIMENS build
authorPavel Labath <labath@google.com>
Mon, 24 Oct 2016 14:19:28 +0000 (14:19 +0000)
committerPavel Labath <labath@google.com>
Mon, 24 Oct 2016 14:19:28 +0000 (14:19 +0000)
If we don't have futimens(), we fall back to futimes(), which only supports
microsecond timestamps. In that case, we need to explicitly cast away the extra
precision in setLastModificationAndAccessTime().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284977 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Unix/Path.inc

index d1d0c5d2694b3ef9c0386a8f28baf3a074829c1a..881a2631ec0af8619978a4b98ea96cde1c22b28e 100644 (file)
@@ -451,7 +451,8 @@ std::error_code setLastModificationAndAccessTime(int FD, TimePoint<> Time) {
   return std::error_code();
 #elif defined(HAVE_FUTIMES)
   timeval Times[2];
-  Times[0] = Times[1] = sys::toTimeVal(Time);
+  Times[0] = Times[1] = sys::toTimeVal(
+      std::chrono::time_point_cast<std::chrono::microseconds>(Time));
   if (::futimes(FD, Times))
     return std::error_code(errno, std::generic_category());
   return std::error_code();