Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: runtime/bin/utils_macos.cc

Issue 1571343003: Fix iOS implementation of |GetCurrentMonotonicMicros|. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/utils_macos.cc
diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc
index 5ac414fb9b5ca399e7970403e4ba28d415d68365..eea4cb750b077503736bc228d18a32d445e5163c 100644
--- a/runtime/bin/utils_macos.cc
+++ b/runtime/bin/utils_macos.cc
@@ -13,6 +13,10 @@
#include <sys/time.h> // NOLINT
#include <time.h> // NOLINT
+#if TARGET_OS_IOS
+#include <sys/sysctl.h> // NOLINT
+#endif
+
#include "bin/utils.h"
#include "platform/assert.h"
#include "platform/utils.h"
@@ -85,6 +89,20 @@ int64_t TimerUtils::GetCurrentMonotonicMillis() {
return GetCurrentMonotonicMicros() / 1000;
}
+#if TARGET_OS_IOS
+
+static int64_t GetCurrentTimeMicros() {
+ // gettimeofday has microsecond resolution.
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) < 0) {
+ UNREACHABLE();
+ return 0;
+ }
+ return (static_cast<int64_t>(tv.tv_sec) * 1000000) + tv.tv_usec;
+}
+
+#endif // TARGET_OS_IOS
+
int64_t TimerUtils::GetCurrentMonotonicMicros() {
#if TARGET_OS_IOS
// On iOS mach_absolute_time stops while the device is sleeping. Instead use
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698