OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/threading/thread_local_storage.h" | 5 #include "base/threading/thread_local_storage.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 | 12 |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 bool PlatformThreadLocalStorage::AllocTLS(TLSKey* key) { | 15 bool PlatformThreadLocalStorage::AllocTLS(TLSKey* key) { |
16 TLSKey value = TlsAlloc(); | 16 TLSKey value = TlsAlloc(); |
17 if (value != TLS_OUT_OF_INDEXES) { | 17 if (value != TLS_OUT_OF_INDEXES) { |
18 *key = value; | 18 *key = value; |
19 return true; | 19 return true; |
20 } | 20 } |
21 return false; | 21 return false; |
22 } | 22 } |
23 | 23 |
24 void PlatformThreadLocalStorage::FreeTLS(TLSKey key) { | 24 void PlatformThreadLocalStorage::FreeTLS(TLSKey key) { |
25 BOOL ret = TlsFree(key); | 25 BOOL ret = TlsFree(key); |
26 DCHECK(ret); | 26 DCHECK(ret); |
27 } | 27 } |
28 | 28 |
29 void* PlatformThreadLocalStorage::GetTLSValue(TLSKey key) { | |
30 return TlsGetValue(key); | |
31 } | |
32 | |
33 void PlatformThreadLocalStorage::SetTLSValue(TLSKey key, void* value) { | 29 void PlatformThreadLocalStorage::SetTLSValue(TLSKey key, void* value) { |
34 BOOL ret = TlsSetValue(key, value); | 30 BOOL ret = TlsSetValue(key, value); |
35 DCHECK(ret); | 31 DCHECK(ret); |
36 } | 32 } |
37 | 33 |
38 } // namespace internal | 34 } // namespace internal |
39 | 35 |
40 } // namespace base | 36 } // namespace base |
41 | 37 |
42 // Thread Termination Callbacks. | 38 // Thread Termination Callbacks. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 #else // _WIN64 | 98 #else // _WIN64 |
103 | 99 |
104 #pragma data_seg(".CRT$XLB") | 100 #pragma data_seg(".CRT$XLB") |
105 PIMAGE_TLS_CALLBACK p_thread_callback_base = OnThreadExit; | 101 PIMAGE_TLS_CALLBACK p_thread_callback_base = OnThreadExit; |
106 | 102 |
107 // Reset the default section. | 103 // Reset the default section. |
108 #pragma data_seg() | 104 #pragma data_seg() |
109 | 105 |
110 #endif // _WIN64 | 106 #endif // _WIN64 |
111 } // extern "C" | 107 } // extern "C" |
OLD | NEW |