Index: runtime/platform/thread_linux.cc |
diff --git a/runtime/platform/thread_linux.cc b/runtime/platform/thread_linux.cc |
index 7efa2b5d09b2f6343813ffce8a3d16b01d0e586a..ef307a6be40faac899317cd077041efbb8dee92f 100644 |
--- a/runtime/platform/thread_linux.cc |
+++ b/runtime/platform/thread_linux.cc |
@@ -103,6 +103,32 @@ int Thread::Start(ThreadStartFunction function, uword parameter) { |
} |
+ThreadLocalKey Thread::kUnsetThreadLocalKey = static_cast<pthread_key_t>(-1); |
+ |
+ |
+ThreadLocalKey Thread::CreateThreadLocal() { |
+ pthread_key_t key = kUnsetThreadLocalKey; |
+ int result = pthread_key_create(&key, NULL); |
+ VALIDATE_PTHREAD_RESULT(result); |
+ ASSERT(key != kUnsetThreadLocalKey); |
+ return key; |
+} |
+ |
+ |
+void Thread::DeleteThreadLocal(ThreadLocalKey key) { |
+ ASSERT(key != kUnsetThreadLocalKey); |
+ int result = pthread_key_delete(key); |
+ VALIDATE_PTHREAD_RESULT(result); |
+} |
+ |
+ |
+void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
+ ASSERT(key != kUnsetThreadLocalKey); |
+ int result = pthread_setspecific(key, reinterpret_cast<void*>(value)); |
+ VALIDATE_PTHREAD_RESULT(result); |
+} |
+ |
+ |
Mutex::Mutex() { |
pthread_mutexattr_t attr; |
int result = pthread_mutexattr_init(&attr); |