summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Host/TimeValue.h2
-rw-r--r--lldb/source/Host/common/TimeValue.cpp26
2 files changed, 9 insertions, 19 deletions
diff --git a/lldb/include/lldb/Host/TimeValue.h b/lldb/include/lldb/Host/TimeValue.h
index 2ddea46e33f..d8e3f8a6469 100644
--- a/lldb/include/lldb/Host/TimeValue.h
+++ b/lldb/include/lldb/Host/TimeValue.h
@@ -35,7 +35,7 @@ public:
TimeValue();
TimeValue(const TimeValue& rhs);
TimeValue(const struct timespec& ts);
- explicit TimeValue(uint32_t seconds, uint32_t nanos = 0);
+ explicit TimeValue(uint32_t seconds, uint64_t nanos = 0);
~TimeValue();
//------------------------------------------------------------------
diff --git a/lldb/source/Host/common/TimeValue.cpp b/lldb/source/Host/common/TimeValue.cpp
index b471a3dd1f1..db74527950b 100644
--- a/lldb/source/Host/common/TimeValue.cpp
+++ b/lldb/source/Host/common/TimeValue.cpp
@@ -20,6 +20,8 @@
#endif
// C++ Includes
+#include <chrono>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Stream.h"
@@ -48,7 +50,7 @@ TimeValue::TimeValue(const struct timespec& ts) :
{
}
-TimeValue::TimeValue(uint32_t seconds, uint32_t nanos) :
+TimeValue::TimeValue(uint32_t seconds, uint64_t nanos) :
m_nano_seconds((uint64_t) seconds * NanoSecPerSec + nanos)
{
}
@@ -123,23 +125,11 @@ TimeValue::OffsetWithNanoSeconds (uint64_t nsec)
TimeValue
TimeValue::Now()
{
- uint32_t seconds, nanoseconds;
-#if _MSC_VER
- SYSTEMTIME st;
- GetSystemTime(&st);
- nanoseconds = st.wMilliseconds * 1000000;
- FILETIME ft;
- SystemTimeToFileTime(&st, &ft);
-
- seconds = ((((uint64_t)ft.dwHighDateTime) << 32 | ft.dwLowDateTime) / 10000000) - 11644473600ULL;
-#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- seconds = tv.tv_sec;
- nanoseconds = tv.tv_usec * NanoSecPerMicroSec;
-#endif
- TimeValue now(seconds, nanoseconds);
- return now;
+ using namespace std::chrono;
+ auto now = system_clock::now();
+ auto ns_since_epoch = duration_cast<std::chrono::nanoseconds>(now.time_since_epoch()).count();
+
+ return TimeValue(0, ns_since_epoch);
}
//----------------------------------------------------------------------
OpenPOWER on IntegriCloud