Index: runtime/platform/thread_win.cc |
diff --git a/runtime/platform/thread_win.cc b/runtime/platform/thread_win.cc |
index 17d3c59867a6762ceb9b563543faa124d28689ff..18a85a91f81cdcd530fc4ed8cda44c1054c7bf5e 100644 |
--- a/runtime/platform/thread_win.cc |
+++ b/runtime/platform/thread_win.cc |
@@ -62,6 +62,36 @@ int Thread::Start(ThreadStartFunction function, uword parameter) { |
} |
+ThreadLocalKey Thread::kUnsetThreadLocalKey = TLS_OUT_OF_INDEXES; |
+ |
+ |
+ThreadLocalKey Thread::CreateThreadLocal() { |
+ ThreadLocalKey key = TlsAlloc(); |
+ if (key == kUnsetThreadLocalKey) { |
+ FATAL("TlsAlloc failed"); |
+ } |
+ return key; |
+} |
+ |
+ |
+void Thread::DeleteThreadLocal(ThreadLocalKey key) { |
+ ASSERT(key != kUnsetThreadLocalKey); |
+ BOOL result = TlsFree(key); |
+ if (!result) { |
+ FATAL("TlsFree failed"); |
+ } |
+} |
+ |
+ |
+void Thread::SetThreadLocal(ThreadLocalKey key, uword value) { |
+ ASSERT(key != kUnsetThreadLocalKey); |
+ BOOL result = TlsSetValue(key, reinterpret_cast<void*>(value)); |
+ if (!result) { |
+ FATAL("TlsSetValue failed"); |
+ } |
+} |
+ |
+ |
Mutex::Mutex() { |
// Allocate unnamed semaphore with initial count 1 and max count 1. |
data_.semaphore_ = CreateSemaphore(NULL, 1, 1, NULL); |