Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(611)

Side by Side Diff: base/threading/thread_local_storage.cc

Issue 1507413003: clang/win: Let some chromium_code targets build with -Wextra. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: content_browsertests Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/threading/thread_local_storage.h ('k') | base/time/time_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 using base::internal::PlatformThreadLocalStorage; 10 using base::internal::PlatformThreadLocalStorage;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if (key == PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES) { 69 if (key == PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES) {
70 PlatformThreadLocalStorage::TLSKey tmp = key; 70 PlatformThreadLocalStorage::TLSKey tmp = key;
71 CHECK(PlatformThreadLocalStorage::AllocTLS(&key) && 71 CHECK(PlatformThreadLocalStorage::AllocTLS(&key) &&
72 key != PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES); 72 key != PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES);
73 PlatformThreadLocalStorage::FreeTLS(tmp); 73 PlatformThreadLocalStorage::FreeTLS(tmp);
74 } 74 }
75 // Atomically test-and-set the tls_key. If the key is 75 // Atomically test-and-set the tls_key. If the key is
76 // TLS_KEY_OUT_OF_INDEXES, go ahead and set it. Otherwise, do nothing, as 76 // TLS_KEY_OUT_OF_INDEXES, go ahead and set it. Otherwise, do nothing, as
77 // another thread already did our dirty work. 77 // another thread already did our dirty work.
78 if (PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES != 78 if (PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES !=
79 base::subtle::NoBarrier_CompareAndSwap(&g_native_tls_key, 79 static_cast<PlatformThreadLocalStorage::TLSKey>(
80 PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES, key)) { 80 base::subtle::NoBarrier_CompareAndSwap(
81 &g_native_tls_key,
82 PlatformThreadLocalStorage::TLS_KEY_OUT_OF_INDEXES, key))) {
81 // We've been shortcut. Another thread replaced g_native_tls_key first so 83 // We've been shortcut. Another thread replaced g_native_tls_key first so
82 // we need to destroy our index and use the one the other thread got 84 // we need to destroy our index and use the one the other thread got
83 // first. 85 // first.
84 PlatformThreadLocalStorage::FreeTLS(key); 86 PlatformThreadLocalStorage::FreeTLS(key);
85 key = base::subtle::NoBarrier_Load(&g_native_tls_key); 87 key = base::subtle::NoBarrier_Load(&g_native_tls_key);
86 } 88 }
87 } 89 }
88 CHECK(!PlatformThreadLocalStorage::GetTLSValue(key)); 90 CHECK(!PlatformThreadLocalStorage::GetTLSValue(key));
89 91
90 // Some allocators, such as TCMalloc, make use of thread local storage. 92 // Some allocators, such as TCMalloc, make use of thread local storage.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 PlatformThreadLocalStorage::GetTLSValue( 242 PlatformThreadLocalStorage::GetTLSValue(
241 base::subtle::NoBarrier_Load(&g_native_tls_key))); 243 base::subtle::NoBarrier_Load(&g_native_tls_key)));
242 if (!tls_data) 244 if (!tls_data)
243 tls_data = ConstructTlsVector(); 245 tls_data = ConstructTlsVector();
244 DCHECK_GT(slot_, 0); 246 DCHECK_GT(slot_, 0);
245 DCHECK_LT(slot_, kThreadLocalStorageSize); 247 DCHECK_LT(slot_, kThreadLocalStorageSize);
246 tls_data[slot_] = value; 248 tls_data[slot_] = value;
247 } 249 }
248 250
249 } // namespace base 251 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/thread_local_storage.h ('k') | base/time/time_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698