]>
Commit | Line | Data |
---|---|---|
fdb8a0be | 1 | /* Single thread optimization, Linux version. |
6d7e8eda | 2 | Copyright (C) 2019-2023 Free Software Foundation, Inc. |
fdb8a0be AZ |
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 | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
fdb8a0be AZ |
18 | |
19 | #ifndef _SINGLE_THREAD_H | |
20 | #define _SINGLE_THREAD_H | |
21 | ||
e070501d AZ |
22 | #ifndef __ASSEMBLER__ |
23 | # include <sys/single_threaded.h> | |
24 | #endif | |
25 | ||
fdb8a0be AZ |
26 | /* The default way to check if the process is single thread is by using the |
27 | pthread_t 'multiple_threads' field. However, for some architectures it is | |
28 | faster to either use an extra field on TCB or global variables (the TCB | |
29 | field is also used on x86 for some single-thread atomic optimizations). | |
30 | ||
31 | The ABI might define SINGLE_THREAD_BY_GLOBAL to enable the single thread | |
32 | check to use global variables instead of the pthread_t field. */ | |
33 | ||
29d4d1be FW |
34 | #if !defined SINGLE_THREAD_BY_GLOBAL || IS_IN (rtld) |
35 | # define SINGLE_THREAD_P \ | |
36 | (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0) | |
37 | #else | |
e070501d | 38 | # define SINGLE_THREAD_P (__libc_single_threaded_internal != 0) |
29d4d1be | 39 | #endif |
fdb8a0be | 40 | |
29d4d1be | 41 | #define RTLD_SINGLE_THREAD_P SINGLE_THREAD_P |
fdb8a0be AZ |
42 | |
43 | #endif /* _SINGLE_THREAD_H */ |