OLD | NEW |
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" // NOLINT | 5 #include "platform/globals.h" // NOLINT |
6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include "vm/os_thread.h" | 8 #include "vm/os_thread.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return false; | 163 return false; |
164 } | 164 } |
165 | 165 |
166 | 166 |
167 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { | 167 intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { |
168 ASSERT(sizeof(id) == sizeof(intptr_t)); | 168 ASSERT(sizeof(id) == sizeof(intptr_t)); |
169 return static_cast<intptr_t>(id); | 169 return static_cast<intptr_t>(id); |
170 } | 170 } |
171 | 171 |
172 | 172 |
| 173 ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { |
| 174 return static_cast<ThreadId>(id); |
| 175 } |
| 176 |
| 177 |
173 bool OSThread::Compare(ThreadId a, ThreadId b) { | 178 bool OSThread::Compare(ThreadId a, ThreadId b) { |
174 return pthread_equal(a, b) != 0; | 179 return pthread_equal(a, b) != 0; |
175 } | 180 } |
176 | 181 |
177 | 182 |
178 void OSThread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { | 183 void OSThread::GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage) { |
179 ASSERT(thread_id == GetCurrentThreadId()); | 184 ASSERT(thread_id == GetCurrentThreadId()); |
180 ASSERT(cpu_usage != NULL); | 185 ASSERT(cpu_usage != NULL); |
181 struct timespec ts; | 186 struct timespec ts; |
182 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); | 187 int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 355 |
351 void Monitor::NotifyAll() { | 356 void Monitor::NotifyAll() { |
352 // TODO(iposva): Do we need to track lock owners? | 357 // TODO(iposva): Do we need to track lock owners? |
353 int result = pthread_cond_broadcast(data_.cond()); | 358 int result = pthread_cond_broadcast(data_.cond()); |
354 VALIDATE_PTHREAD_RESULT(result); | 359 VALIDATE_PTHREAD_RESULT(result); |
355 } | 360 } |
356 | 361 |
357 } // namespace dart | 362 } // namespace dart |
358 | 363 |
359 #endif // defined(TARGET_OS_LINUX) | 364 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |