]>
Commit | Line | Data |
---|---|---|
706ad1e7 | 1 | /* Test support for single-thread optimizations. No threads, static dlopen. |
6d7e8eda | 2 | Copyright (C) 2020-2023 Free Software Foundation, Inc. |
706ad1e7 FW |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
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. */ | |
22 | ||
23 | #include <stddef.h> | |
24 | #include <support/check.h> | |
25 | #include <support/xdlfcn.h> | |
26 | #include <sys/single_threaded.h> | |
27 | ||
28 | static int | |
29 | do_test (void) | |
30 | { | |
31 | TEST_VERIFY (__libc_single_threaded); | |
32 | ||
33 | /* Defined in tst-single-threaded-mod1.o. */ | |
34 | extern _Bool single_threaded_1 (void); | |
35 | TEST_VERIFY (single_threaded_1 ()); | |
36 | ||
37 | /* A failed dlopen does not change the multi-threaded status. */ | |
38 | TEST_VERIFY (dlopen ("tst-single_threaded-does-not-exist.so", RTLD_LAZY) | |
39 | == NULL); | |
40 | TEST_VERIFY (__libc_single_threaded); | |
41 | TEST_VERIFY (single_threaded_1 ()); | |
42 | ||
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 ()); | |
51 | ||
52 | xdlclose (handle_mod2); | |
53 | ||
54 | return 0; | |
55 | } | |
56 | ||
57 | #include <support/test-driver.c> |