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 <stdlib.h>
13#include <unistd.h>
14
15int __thread n;
16
17void
18*f1(void *arg)
19{
20	if (n != 0) {
21		printf("bug, n == %d \n", n);
22		exit(1);
23	}
24	n = 1;
25	return (0);
26}
27
28int
29main(void)
30{
31	pthread_t td;
32	int i;
33
34	for (i = 0; i < 1000; ++i) {
35		pthread_create(&td, NULL, f1, NULL);
36		pthread_join(td, NULL);
37	}
38	sleep(2);
39	for (i = 0; i < 1000; ++i) {
40		pthread_create(&td, NULL, f1, NULL);
41		pthread_join(td, NULL);
42	}
43	return (0);
44}
45