1 /* Test support for single-thread optimizations. No threads, static dlopen.
2 Copyright (C) 2020-2024 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 <https://www.gnu.org/licenses/>. */
19 /* In a static dlopen scenario, the single-threaded optimization is
20 not possible because their is no globally shared dynamic linker
21 across all namespaces. */
24 #include <support/check.h>
25 #include <support/xdlfcn.h>
26 #include <sys/single_threaded.h>
31 TEST_VERIFY (__libc_single_threaded
);
33 /* Defined in tst-single-threaded-mod1.o. */
34 extern _Bool
single_threaded_1 (void);
35 TEST_VERIFY (single_threaded_1 ());
37 /* A failed dlopen does not change the multi-threaded status. */
38 TEST_VERIFY (dlopen ("tst-single_threaded-does-not-exist.so", RTLD_LAZY
)
40 TEST_VERIFY (__libc_single_threaded
);
41 TEST_VERIFY (single_threaded_1 ());
43 /* And neither does a successful dlopen for outer (static) libc. */
44 void *handle_mod2
= xdlopen ("tst-single_threaded-mod2.so", RTLD_LAZY
);
45 _Bool (*single_threaded_2
) (void)
46 = xdlsym (handle_mod2
, "single_threaded_2");
47 TEST_VERIFY (__libc_single_threaded
);
48 TEST_VERIFY (single_threaded_1 ());
49 /* The inner libc always assumes multi-threaded use. */
50 TEST_VERIFY (!single_threaded_2 ());
52 xdlclose (handle_mod2
);
57 #include <support/test-driver.c>