]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/tls/ttls4/ttls4.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / tls / ttls4 / ttls4.c
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  * $FreeBSD$
8  */
9
10 #include <stdio.h>
11 #include <pthread.h>
12 #include <unistd.h>
13
14 int __thread n;
15
16 void *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()
27 {
28         pthread_t td;
29         int i;
30
31         for (i = 0; i < 1000; ++i) {
32                 pthread_create(&td, NULL, f1, NULL);
33                 pthread_join(td, NULL);
34         }
35         sleep(2);
36         for (i = 0; i < 1000; ++i) {
37                 pthread_create(&td, NULL, f1, NULL);
38                 pthread_join(td, NULL);
39         }
40         return (0);
41 }