]>
git.saurik.com Git - apple/libpthread.git/blob - tests/pthread_setspecific.c
7 * $Log: pthread_test3.c,v $
8 * Revision 1.1.4.2 1996/10/03 17:53:38 emcmanus
9 * Changed fprintf(stderr...) to printf(...) to allow building with
11 * [1996/10/03 16:17:34 emcmanus]
13 * Revision 1.1.4.1 1996/10/01 07:36:02 emcmanus
14 * Copied from rt3_merge.
15 * Include <stdlib.h> for malloc() prototype.
16 * [1996/10/01 07:35:53 emcmanus]
18 * Revision 1.1.2.1 1996/09/27 13:12:15 gdt
19 * Add support for thread specific data
20 * [1996/09/27 13:11:17 gdt]
26 * Test POSIX Thread Specific Data
34 #include <darwintest.h>
36 static pthread_key_t key
;
42 T_LOG("thread %lx here: %s\n", (uintptr_t)pthread_self(), (char *)arg
);
44 sprintf(msg
, "This is thread specific data for %lx\n", (uintptr_t)pthread_self());
45 T_ASSERT_POSIX_ZERO(pthread_setspecific(key
, msg
), NULL
);
50 grim_reaper(void * param
)
52 T_LOG("grim_reaper - self: %lx, param: %lx value: %s", (uintptr_t)pthread_self(), (uintptr_t)param
, (char *)param
);
56 T_DECL(pthread_setspecific
, "pthread_setspecific",
57 T_META_ALL_VALID_ARCHS(YES
))
61 T_ASSERT_POSIX_ZERO(pthread_key_create(&key
, grim_reaper
), NULL
);
62 T_ASSERT_POSIX_ZERO(pthread_create(&t1
, (pthread_attr_t
*)NULL
, thread
, "thread #1 arg"), NULL
);
63 T_ASSERT_POSIX_ZERO(pthread_create(&t2
, (pthread_attr_t
*)NULL
, thread
, "thread #2 arg"), NULL
);
64 T_ASSERT_POSIX_ZERO(pthread_join(t1
, &thread_res
), NULL
);
65 T_ASSERT_POSIX_ZERO(pthread_join(t2
, &thread_res
), NULL
);