Path: blob/main/tools/regression/tls/ttls4/ttls4.c
48254 views
/*1* This program tests if a new thread's initial tls data2* is clean.3*4* David Xu <[email protected]>5*/67#include <stdio.h>8#include <pthread.h>9#include <stdlib.h>10#include <unistd.h>1112int __thread n;1314void15*f1(void *arg)16{17if (n != 0) {18printf("bug, n == %d \n", n);19exit(1);20}21n = 1;22return (0);23}2425int26main(void)27{28pthread_t td;29int i;3031for (i = 0; i < 1000; ++i) {32pthread_create(&td, NULL, f1, NULL);33pthread_join(td, NULL);34}35sleep(2);36for (i = 0; i < 1000; ++i) {37pthread_create(&td, NULL, f1, NULL);38pthread_join(td, NULL);39}40return (0);41}424344