1 /* Copyright (C) 2003-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
28 void (*test1
) (void), (*test2
) (void);
30 pthread_barrier_t b2
, b3
;
37 for (i
= 0; i
<= (uintptr_t) arg
; ++i
)
39 int r
= pthread_barrier_wait (&b3
);
40 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
42 puts ("tf: barrier_wait failed");
49 for (i
= 0; i
< 3; ++i
)
51 int r
= pthread_barrier_wait (&b3
);
52 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
54 puts ("tf: barrier_wait failed");
61 for (i
= 0; i
< 3 - (uintptr_t) arg
; ++i
)
63 int r
= pthread_barrier_wait (&b3
);
64 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
66 puts ("tf: barrier_wait failed");
77 int r
= pthread_barrier_wait (&b2
);
78 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
80 puts ("tf2: barrier_wait failed");
85 for (i
= 0; i
< N
; ++i
)
94 const char *modules
[N
]
95 = { "tst-tls4moda.so", "tst-tls4moda.so", "tst-tls4modb.so" };
97 if (pthread_barrier_init (&b2
, NULL
, 2) != 0)
99 puts ("barrier_init failed");
103 if (pthread_barrier_init (&b3
, NULL
, 3) != 0)
105 puts ("barrier_init failed");
109 if (pthread_create (&th
[0], NULL
, tf2
, (void *) (uintptr_t) 1))
111 puts ("pthread_create failed");
115 int r
= pthread_barrier_wait (&b2
);
116 if (r
!= 0 && r
!= PTHREAD_BARRIER_SERIAL_THREAD
)
118 puts ("barrier_wait failed");
123 for (i
= 0; i
< N
; ++i
)
125 void *h
= dlopen (modules
[i
], RTLD_LAZY
);
128 printf ("dlopen failed %s\n", dlerror ());
132 test1
= dlsym (h
, "test1");
135 printf ("dlsym for test1 failed %s\n", dlerror ());
139 test2
= dlsym (h
, "test2");
142 printf ("dlsym for test2 failed %s\n", dlerror ());
146 if (pthread_create (&th
[1], NULL
, tf
, (void *) (uintptr_t) 2))
148 puts ("pthread_create failed");
152 tf ((void *) (uintptr_t) 0);
154 if (pthread_join (th
[1], NULL
) != 0)
156 puts ("join failed");
162 puts ("dlclose failed");
166 printf ("test %d with %s succeeded\n", i
, modules
[i
]);
169 if (pthread_join (th
[0], NULL
) != 0)
171 puts ("join failed");
178 #define TEST_FUNCTION do_test ()
179 #include "../test-skeleton.c"