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