Chromium Code Reviews| Index: runtime/vm/os_thread_openbsd.cc |
| diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_openbsd.cc |
| similarity index 98% |
| copy from runtime/vm/os_thread_android.cc |
| copy to runtime/vm/os_thread_openbsd.cc |
| index c02fd9ab4a81b6f281a06b0b3721b7a8a82ccdc6..f9c00627eb21c7500eb305a1458964b771c92454 100644 |
| --- a/runtime/vm/os_thread_android.cc |
| +++ b/runtime/vm/os_thread_openbsd.cc |
| @@ -3,7 +3,7 @@ |
| // BSD-style license that can be found in the LICENSE file. |
| #include "platform/globals.h" // NOLINT |
| -#if defined(TARGET_OS_ANDROID) |
| +#if defined(TARGET_OS_OPENBSD) |
| #include "vm/os_thread.h" |
| @@ -107,7 +107,6 @@ static void* ThreadStart(void* data_ptr) { |
| return NULL; |
| } |
| - |
|
Ivan Posva
2016/01/11 23:58:40
White space changes.
mulander
2016/01/12 00:22:46
Acknowledged.
|
| int OSThread::Start(const char* name, |
| ThreadStartFunction function, |
| uword parameter) { |
| @@ -135,7 +134,6 @@ const ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0); |
| const ThreadJoinId OSThread::kInvalidThreadJoinId = |
| static_cast<ThreadJoinId>(0); |
| - |
| ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { |
| pthread_key_t key = kUnsetThreadLocalKey; |
| int result = pthread_key_create(&key, destructor); |
| @@ -166,39 +164,35 @@ intptr_t OSThread::GetMaxStackSize() { |
| ThreadId OSThread::GetCurrentThreadId() { |
| - return gettid(); |
| + return pthread_self(); |
| } |
| - |
| ThreadId OSThread::GetCurrentThreadTraceId() { |
| return GetCurrentThreadId(); |
| } |
| - |
| ThreadJoinId OSThread::GetCurrentThreadJoinId() { |
| return pthread_self(); |
| } |
| - |
| void OSThread::Join(ThreadJoinId id) { |
| int result = pthread_join(id, NULL); |
| ASSERT(result == 0); |
| } |
| - |
| intptr_t OSThread::ThreadIdToIntPtr(ThreadId id) { |
| ASSERT(sizeof(id) == sizeof(intptr_t)); |
| - return static_cast<intptr_t>(id); |
| + return reinterpret_cast<intptr_t>(id); |
| } |
| ThreadId OSThread::ThreadIdFromIntPtr(intptr_t id) { |
| - return static_cast<ThreadId>(id); |
| + return reinterpret_cast<ThreadId>(id); |
| } |
| bool OSThread::Compare(ThreadId a, ThreadId b) { |
| - return a == b; |
| + return pthread_equal(a, b) != 0; |
| } |
| @@ -230,8 +224,8 @@ Mutex::Mutex() { |
| result = pthread_mutexattr_destroy(&attr); |
| VALIDATE_PTHREAD_RESULT(result); |
| -#if defined(DEBUG) |
| // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| owner_ = OSThread::kInvalidThreadId; |
| #endif // defined(DEBUG) |
| } |
| @@ -242,8 +236,8 @@ Mutex::~Mutex() { |
| // Verify that the pthread_mutex was destroyed. |
| VALIDATE_PTHREAD_RESULT(result); |
| -#if defined(DEBUG) |
| // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| ASSERT(owner_ == OSThread::kInvalidThreadId); |
| #endif // defined(DEBUG) |
| } |
| @@ -254,8 +248,8 @@ void Mutex::Lock() { |
| // Specifically check for dead lock to help debugging. |
| ASSERT(result != EDEADLK); |
| ASSERT_PTHREAD_SUCCESS(result); // Verify no other errors. |
| -#if defined(DEBUG) |
| // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| owner_ = OSThread::GetCurrentThreadId(); |
| #endif // defined(DEBUG) |
| } |
| @@ -268,8 +262,8 @@ bool Mutex::TryLock() { |
| return false; |
| } |
| ASSERT_PTHREAD_SUCCESS(result); // Verify no other errors. |
| -#if defined(DEBUG) |
| // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| owner_ = OSThread::GetCurrentThreadId(); |
| #endif // defined(DEBUG) |
| return true; |
| @@ -277,8 +271,8 @@ bool Mutex::TryLock() { |
| void Mutex::Unlock() { |
| -#if defined(DEBUG) |
| // When running with assertions enabled we do track the owner. |
| +#if defined(DEBUG) |
| ASSERT(IsOwnedByCurrentThread()); |
| owner_ = OSThread::kInvalidThreadId; |
| #endif // defined(DEBUG) |
| @@ -415,4 +409,4 @@ void Monitor::NotifyAll() { |
| } // namespace dart |
| -#endif // defined(TARGET_OS_ANDROID) |
| +#endif // defined(TARGET_OS_OPENBSD) |