public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Linux: Simplify and fix the definition of SINGLE_THREAD_P
@ 2021-05-10  8:38 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2021-05-10  8:38 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=29d4d1be681fee2fa7cf23205b6d993a3b2a4566

commit 29d4d1be681fee2fa7cf23205b6d993a3b2a4566
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon May 10 10:31:41 2021 +0200

    Linux: Simplify and fix the definition of SINGLE_THREAD_P
    
    Always use __libc_multiple_threads if beneficial, and do not assume
    the the dynamic loader is single-threaded.  This assumption could
    become incorrect by accident once more code is moved from libpthread
    into it.  The previous commit introducing the
    NO_SYSCALL_CANCEL_CHECKING macro enables this change.
    
    Do not hint to the compiler that multi-threaded programs are unlikely
    (which is not quite true anymore).
    
    Tested-by: Carlos O'Donell <carlos@redhat.com>
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>

Diff:
---
 sysdeps/unix/sysv/linux/single-thread.h | 36 +++++++--------------------------
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/single-thread.h b/sysdeps/unix/sysv/linux/single-thread.h
index 841f8c69d5..2fac8dcc11 100644
--- a/sysdeps/unix/sysv/linux/single-thread.h
+++ b/sysdeps/unix/sysv/linux/single-thread.h
@@ -32,35 +32,13 @@ extern int __libc_multiple_threads;
 libc_hidden_proto (__libc_multiple_threads)
 #endif
 
-#ifdef SINGLE_THREAD_BY_GLOBAL
-# if IS_IN (libc)
-#  define SINGLE_THREAD_P \
-  __glibc_likely (__libc_multiple_threads == 0)
-# elif IS_IN (libpthread)
-extern int __pthread_multiple_threads;
-#  define SINGLE_THREAD_P \
-  __glibc_likely (__pthread_multiple_threads == 0)
-# elif IS_IN (librt)
-#   define SINGLE_THREAD_P					\
-  __glibc_likely (THREAD_GETMEM (THREAD_SELF,			\
-				 header.multiple_threads) == 0)
-# else
-/* For rtld, et cetera.  */
-#  define SINGLE_THREAD_P (1)
-# endif
-#else /* SINGLE_THREAD_BY_GLOBAL  */
-# if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-#   define SINGLE_THREAD_P					\
-  __glibc_likely (THREAD_GETMEM (THREAD_SELF,			\
-				 header.multiple_threads) == 0)
-# else
-/* For rtld, et cetera.  */
-#  define SINGLE_THREAD_P (1)
-# endif
-#endif /* SINGLE_THREAD_BY_GLOBAL  */
+#if !defined SINGLE_THREAD_BY_GLOBAL || IS_IN (rtld)
+# define SINGLE_THREAD_P \
+  (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0)
+#else
+# define SINGLE_THREAD_P (__libc_multiple_threads == 0)
+#endif
 
-#define RTLD_SINGLE_THREAD_P \
-  __glibc_likely (THREAD_GETMEM (THREAD_SELF, \
-				 header.multiple_threads) == 0)
+#define RTLD_SINGLE_THREAD_P SINGLE_THREAD_P
 
 #endif /* _SINGLE_THREAD_H  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-10  8:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  8:38 [glibc] Linux: Simplify and fix the definition of SINGLE_THREAD_P Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).