1 /*
2 * This program tests if a new thread's initial tls data
3 * is clean.
4 *
5 * David Xu <davidxu@freebsd.org>
6 */
7
8 #include <stdio.h>
9 #include <pthread.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12
13 int __thread n;
14
15 void
f1(void * arg)16 *f1(void *arg)
17 {
18 if (n != 0) {
19 printf("bug, n == %d \n", n);
20 exit(1);
21 }
22 n = 1;
23 return (0);
24 }
25
26 int
main(void)27 main(void)
28 {
29 pthread_t td;
30 int i;
31
32 for (i = 0; i < 1000; ++i) {
33 pthread_create(&td, NULL, f1, NULL);
34 pthread_join(td, NULL);
35 }
36 sleep(2);
37 for (i = 0; i < 1000; ++i) {
38 pthread_create(&td, NULL, f1, NULL);
39 pthread_join(td, NULL);
40 }
41 return (0);
42 }
43