1 /* Copyright (C) 2003-2017 Free Software Foundation, Inc.
2 
3    The GNU C Library is free software; you can redistribute it and/or
4    modify it under the terms of the GNU Lesser General Public
5    License as published by the Free Software Foundation; either
6    version 2.1 of the License, or (at your option) any later version.
7 
8    The GNU C Library is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    Lesser General Public License for more details.
12 
13    You should have received a copy of the GNU Lesser General Public
14    License along with the GNU C Library; if not, see
15    <http://www.gnu.org/licenses/>.  */
16 
17 #include <sysdep.h>
18 #include <tls.h>
19 #ifndef __ASSEMBLER__
20 # include <pthreadP.h>
21 #endif
22 
23 #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
24 
25 # if defined IS_IN_libpthread
26 #  define __local_multiple_threads __pthread_multiple_threads
27 # elif !defined NOT_IN_libc
28 #  define __local_multiple_threads __libc_multiple_threads
29 # endif
30 
31 # if defined IS_IN_libpthread || !defined NOT_IN_libc
32 extern int __local_multiple_threads attribute_hidden;
33 #  define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
34 # else
35 /*  There is no __local_multiple_threads for librt, so use the TCB.  */
36 #  define SINGLE_THREAD_P						\
37   __builtin_expect (THREAD_GETMEM (THREAD_SELF,				\
38 				   header.multiple_threads) == 0, 1)
39 # endif
40 
41 #else
42 
43 /* For rtld, et cetera.  */
44 # define SINGLE_THREAD_P 1
45 # define NO_CANCELLATION 1
46 
47 #endif
48 
49 # define RTLD_SINGLE_THREAD_P \
50   __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
51 				   header.multiple_threads) == 0, 1)
52