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

Unified Diff: runtime/vm/os_thread_fuchsia.cc

Issue 2117593002: Fuchsia: Initial check-in. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 6 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/vm/os_thread_fuchsia.h ('k') | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_thread_fuchsia.cc
diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_fuchsia.cc
similarity index 88%
copy from runtime/vm/os_thread_linux.cc
copy to runtime/vm/os_thread_fuchsia.cc
index 969504270e97e5a773c9bb6fddae4363a139b86c..c3e8d25173152579227bde779fa1c3fc798b53ec 100644
--- a/runtime/vm/os_thread_linux.cc
+++ b/runtime/vm/os_thread_fuchsia.cc
@@ -1,30 +1,24 @@
-// 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" // NOLINT
-
-#if defined(TARGET_OS_LINUX)
+#if defined(TARGET_OS_FUCHSIA)
#include "vm/os_thread.h"
+#include "vm/os_thread_fuchsia.h"
#include <errno.h> // NOLINT
-#include <sys/resource.h> // NOLINT
-#include <sys/syscall.h> // NOLINT
-#include <sys/time.h> // NOLINT
+#include <magenta/syscalls.h>
+#include <magenta/types.h>
#include "platform/assert.h"
-#include "platform/signal_blocker.h"
-#include "platform/utils.h"
namespace dart {
#define VALIDATE_PTHREAD_RESULT(result) \
if (result != 0) { \
- const int kBufferSize = 1024; \
- char error_buf[kBufferSize]; \
- FATAL2("pthread error: %d (%s)", result, \
- Utils::StrError(result, error_buf, kBufferSize)); \
+ FATAL1("pthread error: %d", result); \
}
@@ -41,9 +35,8 @@ namespace dart {
if (result != 0) { \
const int kBufferSize = 1024; \
char error_buf[kBufferSize]; \
- fprintf(stderr, "%s:%d: pthread error: %d (%s)\n", \
- __FILE__, __LINE__, result, \
- Utils::StrError(result, error_buf, kBufferSize)); \
+ fprintf(stderr, "%s:%d: pthread error: %d\n", \
+ __FILE__, __LINE__, result); \
return result; \
}
#else
@@ -53,11 +46,12 @@ namespace dart {
static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
- int64_t secs = micros / kMicrosecondsPerSecond;
- int64_t nanos =
- (micros - (secs * kMicrosecondsPerSecond)) * kNanosecondsPerMicrosecond;
- int result = clock_gettime(CLOCK_MONOTONIC, ts);
- ASSERT(result == 0);
+ // time in nanoseconds.
+ mx_time_t now = _magenta_current_time();
+ mx_time_t target = now + (micros * kNanosecondsPerMicrosecond);
+ int64_t secs = target / kNanosecondsPerSecond;
+ int64_t nanos = target - (secs * kNanosecondsPerSecond);
+
ts->tv_sec += secs;
ts->tv_nsec += nanos;
if (ts->tv_nsec >= kNanosecondsPerSecond) {
@@ -87,21 +81,6 @@ class ThreadStartData {
};
-// Spawned threads inherit their spawner's signal mask. We sometimes spawn
-// threads for running Dart code from a thread that is blocking SIGPROF.
-// This function explicitly unblocks SIGPROF so the profiler continues to
-// sample this thread.
-static void UnblockSIGPROF() {
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set, SIGPROF);
- int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
- USE(r);
- ASSERT(r == 0);
- ASSERT(!CHECK_IS_BLOCKING(SIGPROF));
-}
-
-
// Dispatch to the thread start function provided by the caller. This trampoline
// is used to ensure that the thread is properly destroyed if the thread just
// exits.
@@ -118,7 +97,6 @@ static void* ThreadStart(void* data_ptr) {
if (thread != NULL) {
OSThread::SetCurrent(thread);
thread->set_name(name);
- UnblockSIGPROF();
// Call the supplied thread start function handing it its parameters.
function(parameter);
}
@@ -189,9 +167,12 @@ ThreadId OSThread::GetCurrentThreadId() {
}
+#ifndef PRODUCT
ThreadId OSThread::GetCurrentThreadTraceId() {
- return syscall(__NR_gettid);
+ UNIMPLEMENTED();
+ return 0;
}
+#endif // PRODUCT
ThreadJoinId OSThread::GetCurrentThreadJoinId(OSThread* thread) {
@@ -452,4 +433,4 @@ void Monitor::NotifyAll() {
} // namespace dart
-#endif // defined(TARGET_OS_LINUX)
+#endif // defined(TARGET_OS_FUCHSIA)
« no previous file with comments | « runtime/vm/os_thread_fuchsia.h ('k') | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698