Title: [226304] trunk/Source/WTF
Revision
226304
Author
[email protected]
Date
2017-12-28 06:17:06 -0800 (Thu, 28 Dec 2017)

Log Message

[WTF] Add clock_gettime based monotonicallyIncreasingTime implementation for Linux and BSDs
https://bugs.webkit.org/show_bug.cgi?id=181175

Reviewed by Michael Catanzaro.

Use platform-provided POSIX APIs to get monotonic time.

* wtf/CurrentTime.cpp:
(WTF::monotonicallyIncreasingTime):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (226303 => 226304)


--- trunk/Source/WTF/ChangeLog	2017-12-27 22:55:43 UTC (rev 226303)
+++ trunk/Source/WTF/ChangeLog	2017-12-28 14:17:06 UTC (rev 226304)
@@ -1,3 +1,15 @@
+2017-12-27  Yusuke Suzuki  <[email protected]>
+
+        [WTF] Add clock_gettime based monotonicallyIncreasingTime implementation for Linux and BSDs
+        https://bugs.webkit.org/show_bug.cgi?id=181175
+
+        Reviewed by Michael Catanzaro.
+
+        Use platform-provided POSIX APIs to get monotonic time.
+
+        * wtf/CurrentTime.cpp:
+        (WTF::monotonicallyIncreasingTime):
+
 2017-12-26  Carlos Alberto Lopez Perez  <[email protected]>
 
         REGRESSION(r225769): Build error with constexpr std::max // std::min in libdstdc++4

Modified: trunk/Source/WTF/wtf/CurrentTime.cpp (226303 => 226304)


--- trunk/Source/WTF/wtf/CurrentTime.cpp	2017-12-27 22:55:43 UTC (rev 226303)
+++ trunk/Source/WTF/wtf/CurrentTime.cpp	2017-12-28 14:17:06 UTC (rev 226304)
@@ -267,6 +267,15 @@
     return (mach_absolute_time() * timebaseInfo.numer) / (1.0e9 * timebaseInfo.denom);
 }
 
+#elif OS(LINUX) || OS(FREEBSD) || OS(OPENBSD) || OS(NETBSD)
+
+double monotonicallyIncreasingTime()
+{
+    struct timespec ts { };
+    clock_gettime(CLOCK_MONOTONIC, &ts);
+    return static_cast<double>(ts.tv_sec) + ts.tv_nsec / 1.0e9;
+}
+
 #else
 
 double monotonicallyIncreasingTime()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to