13 static const int kValueCount = 128;
15 static Thread::LocalStorageKey keys[kValueCount];
17 static void* GetValue(
int num) {
18 return reinterpret_cast<void*
>(
static_cast<intptr_t
>(num + 1));
21 static void DoTest() {
22 for (
int i = 0; i < kValueCount; i++) {
23 CHECK(!Thread::HasThreadLocal(keys[i]));
25 for (
int i = 0; i < kValueCount; i++) {
26 Thread::SetThreadLocal(keys[i], GetValue(i));
28 for (
int i = 0; i < kValueCount; i++) {
29 CHECK(Thread::HasThreadLocal(keys[i]));
31 for (
int i = 0; i < kValueCount; i++) {
32 CHECK_EQ(GetValue(i), Thread::GetThreadLocal(keys[i]));
33 CHECK_EQ(GetValue(i), Thread::GetExistingThreadLocal(keys[i]));
35 for (
int i = 0; i < kValueCount; i++) {
36 Thread::SetThreadLocal(keys[i], GetValue(kValueCount - i - 1));
38 for (
int i = 0; i < kValueCount; i++) {
39 CHECK(Thread::HasThreadLocal(keys[i]));
41 for (
int i = 0; i < kValueCount; i++) {
42 CHECK_EQ(GetValue(kValueCount - i - 1),
43 Thread::GetThreadLocal(keys[i]));
44 CHECK_EQ(GetValue(kValueCount - i - 1),
45 Thread::GetExistingThreadLocal(keys[i]));
59 for (
int i = 0; i < kValueCount; i++) {
60 keys[i] = Thread::CreateThreadLocalKey();
#define CHECK_EQ(expected, value)