Remove TimeValue usage from llvm/Support
Summary:
This is a follow-up to D25416. It removes all usages of TimeValue from
llvm/Support library (except for the actual TimeValue declaration), and replaces
them with appropriate usages of std::chrono. To facilitate this, I have added
small utility functions for converting time points and durations into appropriate
OS-specific types (FILETIME, struct timespec, ...).
Reviewers: zturner, mehdi_amini
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D25730
llvm-svn: 284966
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index a01924c..d1d0c5d 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -198,16 +198,12 @@
return "";
}
-TimeValue file_status::getLastAccessedTime() const {
- TimeValue Ret;
- Ret.fromEpochTime(fs_st_atime);
- return Ret;
+TimePoint<> file_status::getLastAccessedTime() const {
+ return toTimePoint(fs_st_atime);
}
-TimeValue file_status::getLastModificationTime() const {
- TimeValue Ret;
- Ret.fromEpochTime(fs_st_mtime);
- return Ret;
+TimePoint<> file_status::getLastModificationTime() const {
+ return toTimePoint(fs_st_mtime);
}
UniqueID file_status::getUniqueID() const {
@@ -446,20 +442,16 @@
return fillStatus(StatRet, Status, Result);
}
-std::error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
+std::error_code setLastModificationAndAccessTime(int FD, TimePoint<> Time) {
#if defined(HAVE_FUTIMENS)
timespec Times[2];
- Times[0].tv_sec = Time.toEpochTime();
- Times[0].tv_nsec = 0;
- Times[1] = Times[0];
+ Times[0] = Times[1] = sys::toTimeSpec(Time);
if (::futimens(FD, Times))
return std::error_code(errno, std::generic_category());
return std::error_code();
#elif defined(HAVE_FUTIMES)
timeval Times[2];
- Times[0].tv_sec = Time.toEpochTime();
- Times[0].tv_usec = 0;
- Times[1] = Times[0];
+ Times[0] = Times[1] = sys::toTimeVal(Time);
if (::futimes(FD, Times))
return std::error_code(errno, std::generic_category());
return std::error_code();