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

Side by Side Diff: runtime/bin/thread_openbsd.cc

Issue 1559053002: Refs #10260 OpenBSD support #25327 Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address code review issues 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/thread_openbsd.h ('k') | runtime/bin/utils_openbsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_OPENBSD)
7 7
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/thread_openbsd.h"
9 10
10 #include <errno.h> // NOLINT 11 #include <errno.h> // NOLINT
11 #include <sys/time.h> // NOLINT 12 #include <sys/time.h> // NOLINT
12 13
13 #include "platform/assert.h" 14 #include "platform/assert.h"
14 #include "platform/utils.h" 15 #include "platform/utils.h"
15 16
16 namespace dart { 17 namespace dart {
17 namespace bin { 18 namespace bin {
18 19
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 142 }
142 143
143 144
144 intptr_t Thread::GetMaxStackSize() { 145 intptr_t Thread::GetMaxStackSize() {
145 const int kStackSize = (128 * kWordSize * KB); 146 const int kStackSize = (128 * kWordSize * KB);
146 return kStackSize; 147 return kStackSize;
147 } 148 }
148 149
149 150
150 ThreadId Thread::GetCurrentThreadId() { 151 ThreadId Thread::GetCurrentThreadId() {
151 return gettid(); 152 return pthread_self();
152 } 153 }
153 154
154 155
155 bool Thread::Join(ThreadId id) { 156 bool Thread::Join(ThreadId id) {
156 return false; 157 return false;
157 } 158 }
158 159
159 160
160 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) { 161 intptr_t Thread::ThreadIdToIntPtr(ThreadId id) {
161 ASSERT(sizeof(id) == sizeof(intptr_t)); 162 ASSERT(sizeof(id) == sizeof(intptr_t));
162 return static_cast<intptr_t>(id); 163 return reinterpret_cast<intptr_t>(id);
163 } 164 }
164 165
165 166
166 bool Thread::Compare(ThreadId a, ThreadId b) { 167 bool Thread::Compare(ThreadId a, ThreadId b) {
167 return a == b; 168 return pthread_equal(a, b) != 0;
168 } 169 }
169 170
170 171
171 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { 172 void Thread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) {
172 ASSERT(thread_id == GetCurrentThreadId()); 173 ASSERT(thread_id == GetCurrentThreadId());
173 ASSERT(cpu_usage != NULL); 174 ASSERT(cpu_usage != NULL);
174 struct timespec ts; 175 struct timespec ts;
175 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); 176 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
176 ASSERT(r == 0); 177 ASSERT(r == 0);
177 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) / 178 *cpu_usage = (ts.tv_sec * kNanosecondsPerSecond + ts.tv_nsec) /
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 326
326 void Monitor::NotifyAll() { 327 void Monitor::NotifyAll() {
327 // TODO(iposva): Do we need to track lock owners? 328 // TODO(iposva): Do we need to track lock owners?
328 int result = pthread_cond_broadcast(data_.cond()); 329 int result = pthread_cond_broadcast(data_.cond());
329 VALIDATE_PTHREAD_RESULT(result); 330 VALIDATE_PTHREAD_RESULT(result);
330 } 331 }
331 332
332 } // namespace bin 333 } // namespace bin
333 } // namespace dart 334 } // namespace dart
334 335
335 #endif // defined(TARGET_OS_ANDROID) 336 #endif // defined(TARGET_OS_OPENBSD)
OLDNEW
« no previous file with comments | « runtime/bin/thread_openbsd.h ('k') | runtime/bin/utils_openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698