diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 22:54:52 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 22:54:52 +0000 |
commit | 6a6e657234868ad4044b03bdeb9c6f7e872b5ee6 (patch) | |
tree | 36d9855863e1cf5615b62623b2347ec494447cdb /base/thread_local_storage_unittest.cc | |
parent | 15e8abe105f4c2a08cd5dc51e95ec1791ac440f2 (diff) | |
download | chromium_src-6a6e657234868ad4044b03bdeb9c6f7e872b5ee6.zip chromium_src-6a6e657234868ad4044b03bdeb9c6f7e872b5ee6.tar.gz chromium_src-6a6e657234868ad4044b03bdeb9c6f7e872b5ee6.tar.bz2 |
TrackedObjects assumes you can use a "TLS slot" of -1 to indicate uninitialized. This isn't true for the pthread_key_t type, which is unsigned on Linux and reportedly a struct on Macs. This change modifies the Slot type to be a struct containing an "initialized" flag.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1122 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/thread_local_storage_unittest.cc')
-rw-r--r-- | base/thread_local_storage_unittest.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/base/thread_local_storage_unittest.cc b/base/thread_local_storage_unittest.cc index fff0d2a..ba60c2c 100644 --- a/base/thread_local_storage_unittest.cc +++ b/base/thread_local_storage_unittest.cc @@ -44,28 +44,28 @@ namespace { TEST(ThreadLocalStorageTest, Basics) { - int index = ThreadLocalStorage::Alloc(); - ThreadLocalStorage::Set(index, reinterpret_cast<void*>(123)); - int value = reinterpret_cast<int>(ThreadLocalStorage::Get(index)); + ThreadLocalStorage::Slot slot; + slot.Set(reinterpret_cast<void*>(123)); + int value = reinterpret_cast<int>(slot.Get()); EXPECT_EQ(value, 123); } const int kInitialTlsValue = 0x5555; -static int tls_index = 0; +static ThreadLocalStorage::Slot tls_slot(base::LINKER_INITIALIZED); unsigned __stdcall TLSTestThreadMain(void* param) { // param contains the thread local storage index. int *index = reinterpret_cast<int*>(param); *index = kInitialTlsValue; - ThreadLocalStorage::Set(tls_index, index); + tls_slot.Set(index); - int *ptr = static_cast<int*>(ThreadLocalStorage::Get(tls_index)); + int *ptr = static_cast<int*>(tls_slot.Get()); EXPECT_EQ(ptr, index); EXPECT_EQ(*ptr, kInitialTlsValue); *index = 0; - ptr = static_cast<int*>(ThreadLocalStorage::Get(tls_index)); + ptr = static_cast<int*>(tls_slot.Get()); EXPECT_EQ(ptr, index); EXPECT_EQ(*ptr, 0); return 0; @@ -86,7 +86,7 @@ TEST(ThreadLocalStorageTest, TLSDestructors) { HANDLE threads[kNumThreads]; int values[kNumThreads]; - tls_index = ThreadLocalStorage::Alloc(ThreadLocalStorageCleanup); + tls_slot.Initialize(ThreadLocalStorageCleanup); // Spawn the threads. for (int16 index = 0; index < kNumThreads; index++) { |