* manual/arith.texi: Document MTASC-safety properties.
[jlayton/glibc.git] / nptl / tst-dlsym1.c
1 /* Test case by Hui Huang <hui.huang@sun.com>.  */
2 #include <dlfcn.h>
3 #include <pthread.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7
8 static void *
9 start_routine (void *args)
10 {
11   int i;
12   void **addrs = (void **) args;
13   for (i = 0; i < 10000; ++i)
14     addrs[i % 1024] = dlsym (NULL, "does_not_exist");
15
16   return addrs;
17 }
18
19
20 static int
21 do_test (void)
22 {
23   pthread_t tid1, tid2, tid3;
24
25   void *addrs1[1024];
26   void *addrs2[1024];
27   void *addrs3[1024];
28
29   if (pthread_create (&tid1, NULL, start_routine, addrs1) != 0)
30     {
31       puts ("1st create failed");
32       exit (1);
33     }
34   if (pthread_create (&tid2, NULL, start_routine, addrs2) != 0)
35     {
36       puts ("2nd create failed");
37       exit (1);
38     }
39   if (pthread_create (&tid3, NULL, start_routine, addrs3) != 0)
40     {
41       puts ("3rd create failed");
42       exit (1);
43     }
44
45   if (pthread_join (tid1, NULL) != 0)
46     {
47       puts ("1st join failed");
48       exit (1);
49     }
50   if (pthread_join (tid2, NULL) != 0)
51     {
52       puts ("2nd join failed");
53       exit (1);
54     }
55   if (pthread_join (tid3, NULL) != 0)
56     {
57       puts ("2rd join failed");
58       exit (1);
59     }
60
61   return 0;
62 }
63
64
65 #define TEST_FUNCTION do_test ()
66 #include "../test-skeleton.c"