string test alignment fix by Mahesh Bodapati
[libc-test.git] / src / regression / tls_get_new-dtv.c
bloba183fffb5b291d4f27ca4356ac3ddfac4727beee
1 // __tls_get_new did not allocate new dtv for threads properly
2 #include <pthread.h>
3 #include <dlfcn.h>
4 #include "test.h"
6 #define N 10
8 #define T(c) ((c) || (t_error(#c " failed\n"),0))
10 static pthread_barrier_t b;
11 static void *mod;
13 static void *start(void *a)
15 void *(*f)(void);
17 pthread_barrier_wait(&b);
18 T(f = dlsym(mod, "f"));
19 f();
20 return 0;
23 int main()
25 pthread_t td[N];
26 int i;
28 pthread_barrier_init(&b, 0, N+1);
29 for (i=0; i<N; i++)
30 T(!pthread_create(td+i, 0, start, 0));
32 T(mod = dlopen("tls_get_new-dtv_dso.so", RTLD_NOW));
33 pthread_barrier_wait(&b);
35 for (i=0; i<N; i++)
36 T(!pthread_join(td[i], 0));
37 return t_status;