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..51b0100c9be3b3e3a4948de30c5365156abb923b 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" |
@@ -135,7 +135,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,7 +165,7 @@ intptr_t OSThread::GetMaxStackSize() { |
ThreadId OSThread::GetCurrentThreadId() { |
- return gettid(); |
+ return pthread_self(); |
} |
@@ -188,17 +187,17 @@ void OSThread::Join(ThreadJoinId id) { |
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 +229,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 +241,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 +253,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 +267,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 +276,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 +414,4 @@ void Monitor::NotifyAll() { |
} // namespace dart |
-#endif // defined(TARGET_OS_ANDROID) |
+#endif // defined(TARGET_OS_OPENBSD) |