1 /* Test concurrent dlopen and pthread_create: BZ 19329.
2 Copyright (C) 2021-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
22 #include <stdatomic.h>
23 #include <support/xdlfcn.h>
24 #include <support/xthread.h>
28 static atomic_int done
;
33 /* Load a module with many dependencies that each have TLS. */
34 xdlopen ("tst-tls21mod.so", RTLD_LAZY
);
35 atomic_store_explicit (&done
, 1, memory_order_release
);
51 /* Load a module with lots of dependencies and TLS. */
52 t1
= xpthread_create (0, start
, 0);
54 /* Concurrently create lots of threads until dlopen is observably done. */
55 for (i
= 0; i
< THREADS
; i
++)
57 if (atomic_load_explicit (&done
, memory_order_acquire
) != 0)
59 t2
= xpthread_create (0, nop
, 0);
64 printf ("threads created during dlopen: %d\n", i
);
68 #include <support/test-driver.c>