]>
git.saurik.com Git - apple/libpthread.git/blob - tests/tsd.c
4 #include <darwintest.h>
6 static void *ptr
= NULL
;
8 static void destructor(void *value
)
13 static void *thread(void *param
)
15 pthread_key_t key
= *(pthread_key_t
*)param
;
16 T_ASSERT_POSIX_ZERO(pthread_setspecific(key
, (void *)0x12345678), NULL
);
17 void *value
= pthread_getspecific(key
);
19 T_ASSERT_POSIX_ZERO(pthread_key_create(&key
, NULL
), NULL
);
20 T_ASSERT_POSIX_ZERO(pthread_setspecific(key
, (void *)0x55555555), NULL
);
26 T_META_ALL_VALID_ARCHS(YES
))
30 T_ASSERT_POSIX_ZERO(pthread_key_create(&key
, destructor
), NULL
);
31 T_LOG("key = %ld", key
);
34 T_ASSERT_POSIX_ZERO(pthread_create(&p
, NULL
, thread
, &key
), NULL
);
37 T_ASSERT_POSIX_ZERO(pthread_join(p
, &value
), NULL
);
38 T_LOG("value = %p; ptr = %p\n", value
, ptr
);
40 T_EXPECT_EQ(ptr
, value
, NULL
);
42 T_ASSERT_POSIX_ZERO(pthread_key_delete(key
), NULL
);