]>
git.saurik.com Git - apple/libpthread.git/blob - tests/detach.c
5 #include <dispatch/dispatch.h>
8 #include "darwintest_defaults.h"
11 thread_routine(void *loc
)
13 uintptr_t i
= (uintptr_t)loc
;
20 pthread_exit(pthread_self());
21 __builtin_unreachable();
28 T_DECL(pthread_detach
, "Test creating and detaching threads in a loop",
29 T_META_CHECK_LEAKS(NO
), T_META_ALL_VALID_ARCHS(YES
))
31 const size_t count
= 32;
34 for (size_t i
= 0; i
< 100; i
++) {
35 for (size_t j
= 0; j
< count
; j
++) {
36 T_ASSERT_POSIX_ZERO(pthread_create(&ths
[j
], NULL
,
37 thread_routine
, (void *)j
), "thread creation");
38 T_ASSERT_POSIX_ZERO(pthread_detach(ths
[j
]), "thread detach");