]>
git.saurik.com Git - apple/libpthread.git/blob - tests/pthread_bulk_create.c
3 #include "darwintest_defaults.h"
5 #define MAX_THREADS 512
6 #define THREAD_DEPTH 32
11 T_LOG("thread %lx here: %d", (uintptr_t)pthread_self(), (int)arg
);
15 T_DECL(pthread_bulk_create
, "pthread_bulk_create")
18 pthread_t t
[THREAD_DEPTH
];
20 for (int i
= 0; i
< MAX_THREADS
; i
+= THREAD_DEPTH
) {
21 T_LOG("Creating threads %d..%d\n", i
, i
+ THREAD_DEPTH
- 1);
22 for (int j
= 0; j
< THREAD_DEPTH
; j
++) {
23 void *arg
= (void *)(intptr_t)(i
+ j
);
24 T_QUIET
; T_ASSERT_POSIX_ZERO(
25 pthread_create(&t
[j
], NULL
, thread
, arg
), NULL
);
27 T_LOG("Waiting for threads");
28 for (int j
= 0; j
< THREAD_DEPTH
; j
++) {
29 T_QUIET
; T_ASSERT_POSIX_ZERO(pthread_join(t
[j
], &thread_res
), NULL
);
30 T_QUIET
; T_ASSERT_EQ(i
+ j
, (int)thread_res
, "thread return value");