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

Unified Diff: runtime/bin/utils_fuchsia.cc

Issue 2168193002: Fuchsia: Build standalone VM. Make it run "Hello, World!". (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 5 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 | « runtime/bin/stdio_fuchsia.cc ('k') | runtime/bin/vmservice/vmservice_io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/utils_fuchsia.cc
diff --git a/runtime/bin/utils_linux.cc b/runtime/bin/utils_fuchsia.cc
similarity index 61%
copy from runtime/bin/utils_linux.cc
copy to runtime/bin/utils_fuchsia.cc
index 2029071abebae223b5e3d1cb21f85d6b1d06d9f7..1df2aba4e45547cfa9228ce9da418a97114a0263 100644
--- a/runtime/bin/utils_linux.cc
+++ b/runtime/bin/utils_fuchsia.cc
@@ -1,14 +1,13 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "platform/globals.h"
-#if defined(TARGET_OS_LINUX)
+#if defined(TARGET_OS_FUCHSIA)
-#include <errno.h> // NOLINT
-#include <netdb.h> // NOLINT
-#include <sys/time.h> // NOLINT
-#include <time.h> // NOLINT
+#include <errno.h>
+#include <magenta/syscalls.h>
+#include <magenta/types.h>
#include "bin/utils.h"
#include "platform/assert.h"
@@ -34,7 +33,7 @@ void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {
char error_buf[kBufferSize];
SetMessage(Utils::StrError(code, error_buf, kBufferSize));
} else if (sub_system == kGetAddressInfo) {
- SetMessage(gai_strerror(code));
+ UNIMPLEMENTED();
} else {
UNREACHABLE();
}
@@ -84,41 +83,17 @@ int64_t TimerUtils::GetCurrentMonotonicMillis() {
int64_t TimerUtils::GetCurrentMonotonicMicros() {
- struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
- UNREACHABLE();
- return 0;
- }
- // Convert to microseconds.
- int64_t result = ts.tv_sec;
- result *= kMicrosecondsPerSecond;
- result += (ts.tv_nsec / kNanosecondsPerMicrosecond);
- return result;
+ int64_t ticks = mx_current_time();
+ return ticks / kNanosecondsPerMicrosecond;
}
void TimerUtils::Sleep(int64_t millis) {
- struct timespec req; // requested.
- struct timespec rem; // remainder.
- int64_t micros = millis * kMicrosecondsPerMillisecond;
- int64_t seconds = micros / kMicrosecondsPerSecond;
- micros = micros - seconds * kMicrosecondsPerSecond;
- int64_t nanos = micros * kNanosecondsPerMicrosecond;
- req.tv_sec = seconds;
- req.tv_nsec = nanos;
- while (true) {
- int r = nanosleep(&req, &rem);
- if (r == 0) {
- break;
- }
- // We should only ever see an interrupt error.
- ASSERT(errno == EINTR);
- // Copy remainder into requested and repeat.
- req = rem;
- }
+ mx_nanosleep(
+ millis * kMicrosecondsPerMillisecond * kNanosecondsPerMicrosecond);
}
} // namespace bin
} // namespace dart
-#endif // defined(TARGET_OS_LINUX)
+#endif // defined(TARGET_OS_FUCHSIA)
« no previous file with comments | « runtime/bin/stdio_fuchsia.cc ('k') | runtime/bin/vmservice/vmservice_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698