]>
git.saurik.com Git - apple/libpthread.git/blob - tests/pthread_threadid_np.c
2 #include <pthread/private.h>
3 #include <dispatch/dispatch.h>
5 #include "darwintest_defaults.h"
7 extern __uint64_t
__thread_selfid( void );
9 static void *do_test(void * __unused arg
)
11 uint64_t threadid
= __thread_selfid();
12 T_ASSERT_NOTNULL(threadid
, NULL
);
14 uint64_t pth_threadid
= 0;
15 T_ASSERT_POSIX_ZERO(pthread_threadid_np(NULL
, &pth_threadid
), NULL
);
16 T_ASSERT_POSIX_ZERO(pthread_threadid_np(pthread_self(), &pth_threadid
), NULL
);
17 T_EXPECT_EQ(threadid
, pth_threadid
, "pthread_threadid_np()");
19 pth_threadid
= _pthread_threadid_self_np_direct();
20 T_EXPECT_EQ(threadid
, pth_threadid
, "pthread_threadid_np_direct()");
25 T_DECL(pthread_threadid_np
, "pthread_threadid_np",
26 T_META_ALL_VALID_ARCHS(YES
))
33 T_ASSERT_POSIX_ZERO(pthread_create(&pth
, NULL
, do_test
, NULL
), NULL
);
34 T_ASSERT_POSIX_ZERO(pthread_join(pth
, NULL
), NULL
);
36 T_LOG("Workqueue Thread");
37 dispatch_queue_t dq
= dispatch_queue_create("myqueue", NULL
);
38 dispatch_async(dq
, ^{ do_test(NULL
); });
39 dispatch_sync(dq
, ^{});
41 T_LOG("Workqueue Thread Reuse");
42 dispatch_async(dq
, ^{ do_test(NULL
); });
43 dispatch_sync(dq
, ^{});