1 /*
2  * This file is subject to the terms and conditions of the LGPV V2.1
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2019 Kalray Inc.
7  */
8 
9 #include <sysdep.h>
10 #include <tls.h>
11 #ifndef __ASSEMBLER__
12 # include <pthreadP.h>
13 #endif
14 
15 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
16 
17 # if defined IS_IN_libpthread
18 #  define __local_multiple_threads __pthread_multiple_threads
19 # elif !defined NOT_IN_libc
20 #  define __local_multiple_threads __libc_multiple_threads
21 # endif
22 
23 # if defined IS_IN_libpthread || !defined NOT_IN_libc
24 extern int __local_multiple_threads attribute_hidden;
25 #  define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
26 # else
27 /*  There is no __local_multiple_threads for librt, so use the TCB.  */
28 #  define SINGLE_THREAD_P						\
29   __builtin_expect (THREAD_GETMEM (THREAD_SELF,				\
30 				   header.multiple_threads) == 0, 1)
31 # endif
32 
33 #else
34 
35 /* For rtld, et cetera.  */
36 # define SINGLE_THREAD_P 1
37 # define NO_CANCELLATION 1
38 
39 #endif
40 
41 # define RTLD_SINGLE_THREAD_P \
42   __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
43 				   header.multiple_threads) == 0, 1)
44