From patchwork Mon Oct 30 19:25:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 117502 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2961627qgn; Mon, 30 Oct 2017 12:25:55 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QrbB3mOzMk0/hGz8T8wELhE+AiQbM7ySpwAp3yTf4PnFMXje1/e9vZrSnvW6QFC3DFVO7s X-Received: by 10.98.105.134 with SMTP id e128mr9563091pfc.29.1509391555793; Mon, 30 Oct 2017 12:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509391555; cv=none; d=google.com; s=arc-20160816; b=u7eqddLvcx929Zj+FP2hQFB0fbC3NaE8WuxU6LHSZLBnqD9MGNvoeJgpcibL3d81JU +3UVzJMvliINiVr3Z7sQg3RSZxjDPOyL+UfizwlVp7zCfnGRlZcGvhXCT0rCcICfu2cw 4TPnDKdB1/4+7J1o8gOwTjozysVUUpTfSCOJ0nXUrtHYTzoJmIHj5bMZXl1W2CLa5b3L u1cdf0yFbdA/bstVl4FeWpvq8ivvL0g+GD5uHHY1UWaUaprXgCaGXanQ5zDxFvnNgVCP m6h5ot/1rO0bK0H4XLyo3458xgaOvv0lKCBBB0LOsk0KtC0B2Tk+lAUQREw0FooPcrQf pHYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=9epGDeDYEjgRZkyOWGD1qpoxOdX1NMGj7BNCkZ5WWkE=; b=dDwClM0ZmEBF+C7aX/WOn6Do33x3Dc72pzFnY0lSY10ma96tdvznuzJXI96uPbaVVt Q2o/+Lc9GpoSf4gjpqVC6S8Ii/EVAY9tg/yO3McjLFxYOr8JshrkTnDbKEBHxdgFVikg kNz768QfL281meMmN0WyCEJ8yRL71cFQk/gwAgcanwMvZGMaWq+vfNCGJMTBj83ubyY2 NuY0nfgaDxWyKJmeagE8AkcSRSzzlKqFxDBLRXs6DDL+J+FIlK+U2A/BP4ZYs9vRTojK ZvawHDIv+t40rYtsh+j2ZguZ5VHAPguglwfeixKd+8HzOIhVxQ7r7i/Kf/LGmDe7E9d7 TPdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BB5rPzfh; spf=pass (google.com: domain of libc-alpha-return-86555-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86555-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g6si10481491pgq.135.2017.10.30.12.25.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 12:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-86555-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BB5rPzfh; spf=pass (google.com: domain of libc-alpha-return-86555-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86555-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=YtSsAad4lDI6ewlAPjGG5veEkTcenQH+xhb/1nRKA8x0ED3mPUmhw xHZFMih8CEmiaa2s2Qs5gKCLuAfRIqv1tXwkd66hhnALCeIPyatEZo0KH/fOSQXG qQzZFIQpb/kcIe/PaMD5scvyl8lVJ+lOjLbzpYVN+jxI29MsP/FkSs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=GAS4NEx9seOMOuxIhP/Iia8Yu9Q=; b=BB5rPzfhtD22SymnRJ5oJtgzVboX 7cAgbzvOY/dQJXku75Xeo8ylOhW54zLMazNN4QxlBx9BoE7y+5I62Fw1WygJB3gE Q4prMxD4IAB6NeMNyB6Gu7jldrglhiWVtQbatvI8KWbRiHBYSSjUH+Yo2creIHRI lIL7d78zl75F0Fw= Received: (qmail 36119 invoked by alias); 30 Oct 2017 19:25:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 36074 invoked by uid 89); 30 Oct 2017 19:25:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=fork, Variable X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=9epGDeDYEjgRZkyOWGD1qpoxOdX1NMGj7BNCkZ5WWkE=; b=dsEU1jRzXs7FDzMlIGeg4px0iYx3/qlHbvtvvcc1+WivxsKJjoVhDXTm9C25A9Gw2p 74JsYP/4b99pMRGT0psC6Hih1WhEaVYHf6kZpw9TXwCB0BsOyGTJEddfV1aCeLw1MV8R CZdqMbHeizI5TLR/RNiev6ZrfOMBkXBllzkjJvKwzm5At+rlRofF/T3W8MbRTxyY0Sj4 rv8T/E5d0gM+aL85ay/0j38/1ybUyQL4A3oyqbZmGQkQwQ3Qi4PqMOd2Ury9OSPiWWtu QaZxxxMhVf+fs9MSbS0oZ6N6AxG9IW7duQZFD5l8ywLCE55+6v6X2dT4uluuCmMzyY45 0NoA== X-Gm-Message-State: AMCzsaUQX0L7a6Y1Dkq4k07QVPnoMmyWRMwFJ/YmEK68pAgV43fGh16x aLII6jNPXihh+VWe8PEikwcIWYM6Ldw= X-Received: by 10.200.7.75 with SMTP id k11mr14857621qth.122.1509391538527; Mon, 30 Oct 2017 12:25:38 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2] Remove TLS_MULTIPLE_THREADS_IN_TCB define Date: Mon, 30 Oct 2017 17:25:34 -0200 Message-Id: <1509391534-25291-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version [1]: - Removed TLS_MULTIPLE_THREADS_IN_TCB define. --- GLIBC current uses the TLS_MULTIPLE_THREADS_IN_TCB define to declare and set the single thread optimization (STO) access by either a global variable or a field in TCB. However STO refactor (09c76a740998) added a new variable, SINGLE_THREAD_BY_GLOBAL, which essentially provides the same semantic. This patch remove the TLS_MULTIPLE_THREADS_IN_TCB and uses SINGLE_THREAD_BY_GLOBAL instead. It also adds some macros to access and modify the STO field depending of the prefered architecture way. It also make the archictures that actually use the global variable to include them on final lib{c,pthread}.so. For instance m68k lib{c,pthread}.so defines {__{pthread,libc}_multiple threads even though its STO is implemented by TCB access. Checked on x86_64-linux-gnu and on a build with major touched ABIs (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf, hppa-linux-gnu, i686-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, mips-linux-gnu, mips64-linux-gnu, powerpc-linux-gnu, powerpc64le-linux-gnu, s390-linux-gnu, s390x-linux-gnu, sh4-linux-gnu, sparcv9-linux-gnu, sparc64-linux-gnu, tilegx-linux-gnu). * nptl/allocatestack.c (allocate_state): Use SET_SINGLE_THREAD_PTHREAD macro. * nptl/pthread_cancel.c (__pthread_cancel): Likewise. * nptl/libc_multiple_threads.c (__libc_multiple_threads): Define for libc and SINGLE_THREAD_BY_GLOBAL. * nptl/libc_pthread_init.c (__libc_pthread_init): Use same signature whether SINGLE_THREAD_BY_GLOBAL is set or not. * nptl/pthreadP.h (__libc_pthread_init): Likewise. * nptl/nptl-init.c (__libc_multiple_threads_ptr): Use MULTIPLE_THREADS_PTR_DEF. (__pthread_initialize_minimal_internal): Use MULTIPLE_THREADS_PTR_SET macro. * nptl/vars.c (__pthread_multiple_threads): Define for libpthread and SINGLE_THREAD_BY_GLOBAL. * sysdeps/unix/sysv/linux/sysdep-cancel.h (MULTIPLE_THREADS_PTR_DEF): Define. (MULTIPLE_THREADS_PTR_SET): Likewise. (SET_SINGLE_THREAD_PTHREAD): Likewise. * sysdeps/i386/nptl/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Remove. * sysdeps/ia64/nptl/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Likewise. * sysdeps/powerpc/nptl/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Likewise. * sysdeps/s390/nptl/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Likewise. * sysdeps/sh/nptl/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Likewise. * sysdeps/tile/nptl/tls.h (TLS_MULTIPLE_THREADS_IN_TCB): Likewise. * sysdeps/powerpc/nptl/tcb-offsets.sym (TLS_MULTIPLE_THREADS_IN_TCB): Likewise. [1] https://sourceware.org/ml/libc-alpha/2017-08/msg00238.html Signed-off-by: Adhemerval Zanella --- ChangeLog | 29 +++++++++++++++++++++++++++++ nptl/allocatestack.c | 9 +++------ nptl/libc_multiple_threads.c | 4 +--- nptl/libc_pthread_init.c | 12 ++++-------- nptl/nptl-init.c | 14 +++++--------- nptl/pthreadP.h | 13 ------------- nptl/pthread_cancel.c | 7 +++---- nptl/vars.c | 2 +- sysdeps/i386/nptl/tls.h | 2 -- sysdeps/ia64/nptl/tls.h | 2 -- sysdeps/powerpc/nptl/tcb-offsets.sym | 2 -- sysdeps/powerpc/nptl/tls.h | 3 --- sysdeps/s390/nptl/tls.h | 4 ---- sysdeps/sh/nptl/tls.h | 2 -- sysdeps/tile/nptl/tls.h | 3 --- sysdeps/unix/sysv/linux/sysdep-cancel.h | 27 +++++++++++++++++++++++++-- 16 files changed, 71 insertions(+), 64 deletions(-) -- 2.7.4 diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index ad9add8..b85767d 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifndef NEED_SEPARATE_REGISTER_STACK @@ -482,9 +483,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* This is at least the second thread. */ pd->header.multiple_threads = 1; -#ifndef TLS_MULTIPLE_THREADS_IN_TCB - __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; -#endif + SET_SINGLE_THREAD_PTHREAD (1); #ifndef __ASSUME_PRIVATE_FUTEX /* The thread must know when private futexes are supported. */ @@ -602,9 +601,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* This is at least the second thread. */ pd->header.multiple_threads = 1; -#ifndef TLS_MULTIPLE_THREADS_IN_TCB - __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; -#endif + SET_SINGLE_THREAD_PTHREAD (1); #ifndef __ASSUME_PRIVATE_FUTEX /* The thread must know when private futexes are supported. */ diff --git a/nptl/libc_multiple_threads.c b/nptl/libc_multiple_threads.c index ef6a4be..1ae23e2 100644 --- a/nptl/libc_multiple_threads.c +++ b/nptl/libc_multiple_threads.c @@ -18,11 +18,9 @@ #include -#if IS_IN (libc) -# ifndef TLS_MULTIPLE_THREADS_IN_TCB +#if IS_IN (libc) && defined (SINGLE_THREAD_BY_GLOBAL) /* Variable set to a nonzero value either if more than one thread runs or ran, or if a single-threaded process is trying to cancel itself. See nptl/descr.h for more context on the single-threaded process case. */ int __libc_multiple_threads attribute_hidden; -# endif #endif diff --git a/nptl/libc_pthread_init.c b/nptl/libc_pthread_init.c index 875b27e..8bac037 100644 --- a/nptl/libc_pthread_init.c +++ b/nptl/libc_pthread_init.c @@ -26,18 +26,12 @@ #include #include #include - +#include unsigned long int *__fork_generation_pointer; -#ifdef TLS_MULTIPLE_THREADS_IN_TCB -void -#else -extern int __libc_multiple_threads attribute_hidden; - int * -#endif __libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), const struct pthread_functions *functions) { @@ -73,8 +67,10 @@ __libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), __libc_pthread_functions_init = 1; #endif -#ifndef TLS_MULTIPLE_THREADS_IN_TCB +#ifdef SINGLE_THREAD_BY_GLOBAL return &__libc_multiple_threads; +# else + return NULL; #endif } diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index 2921607..a1320f3 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -38,11 +38,9 @@ #include #include #include +#include -#ifndef TLS_MULTIPLE_THREADS_IN_TCB -/* Pointer to the corresponding variable in libc. */ -int *__libc_multiple_threads_ptr attribute_hidden; -#endif +MULTIPLE_THREADS_PTR_DEF; /* Size and alignment of static TLS block. */ size_t __static_tls_size; @@ -457,11 +455,9 @@ __pthread_initialize_minimal_internal (void) GL(dl_wait_lookup_done) = &__wait_lookup_done; /* Register the fork generation counter with the libc. */ -#ifndef TLS_MULTIPLE_THREADS_IN_TCB - __libc_multiple_threads_ptr = -#endif - __libc_pthread_init (&__fork_generation, __reclaim_stacks, - ptr_pthread_functions); + MULTIPLE_THREADS_PTR_SET (__libc_pthread_init (&__fork_generation, + __reclaim_stacks, + ptr_pthread_functions)); /* Determine whether the machine is SMP or not. */ __is_smp = is_smp_system (); diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index dbf46b0..d89fdca 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -382,23 +382,10 @@ hidden_proto (__nptl_create_event) hidden_proto (__nptl_death_event) /* Register the generation counter in the libpthread with the libc. */ -#ifdef TLS_MULTIPLE_THREADS_IN_TCB -extern void __libc_pthread_init (unsigned long int *ptr, - void (*reclaim) (void), - const struct pthread_functions *functions); -#else extern int *__libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), const struct pthread_functions *functions); -/* Variable set to a nonzero value either if more than one thread runs or ran, - or if a single-threaded process is trying to cancel itself. See - nptl/descr.h for more context on the single-threaded process case. */ -extern int __pthread_multiple_threads attribute_hidden; -/* Pointer to the corresponding variable in libc. */ -extern int *__libc_multiple_threads_ptr attribute_hidden; -#endif - /* Find a thread given its TID. */ extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden #ifdef SHARED diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index 742dfe6..f52ea08 100644 --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -19,10 +19,11 @@ #include #include #include -#include "pthreadP.h" #include #include #include +#include +#include int __pthread_cancel (pthread_t th) @@ -88,9 +89,7 @@ __pthread_cancel (pthread_t th) cannot. So we set multiple_threads to true so that cancellation points get executed. */ THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1); -#ifndef TLS_MULTIPLE_THREADS_IN_TCB - __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; -#endif + SET_SINGLE_THREAD_PTHREAD (1); } /* Mark the thread as canceled. This has to be done atomically since other bits could be modified as well. */ diff --git a/nptl/vars.c b/nptl/vars.c index 198f463..42b8db9 100644 --- a/nptl/vars.c +++ b/nptl/vars.c @@ -30,7 +30,7 @@ int __default_pthread_attr_lock = LLL_LOCK_INITIALIZER; /* Flag whether the machine is SMP or not. */ int __is_smp attribute_hidden; -#ifndef TLS_MULTIPLE_THREADS_IN_TCB +#if IS_IN (libpthread) && defined (SINGLE_THREAD_BY_GLOBAL) /* Variable set to a nonzero value either if more than one thread runs or ran, or if a single-threaded process is trying to cancel itself. See nptl/descr.h for more context on the single-threaded process case. */ diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h index f9a6b11..e0fd6f9 100644 --- a/sysdeps/i386/nptl/tls.h +++ b/sysdeps/i386/nptl/tls.h @@ -52,8 +52,6 @@ typedef struct void *__private_ss; } tcbhead_t; -# define TLS_MULTIPLE_THREADS_IN_TCB 1 - #else /* __ASSEMBLER__ */ # include #endif diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h index 400caf3..9b0cc3d 100644 --- a/sysdeps/ia64/nptl/tls.h +++ b/sysdeps/ia64/nptl/tls.h @@ -36,8 +36,6 @@ typedef struct register struct pthread *__thread_self __asm__("r13"); -# define TLS_MULTIPLE_THREADS_IN_TCB 1 - #else /* __ASSEMBLER__ */ # include #endif diff --git a/sysdeps/powerpc/nptl/tcb-offsets.sym b/sysdeps/powerpc/nptl/tcb-offsets.sym index 7c9fd33..77c9a4f 100644 --- a/sysdeps/powerpc/nptl/tcb-offsets.sym +++ b/sysdeps/powerpc/nptl/tcb-offsets.sym @@ -10,9 +10,7 @@ # define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem)) -#if TLS_MULTIPLE_THREADS_IN_TCB MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads) -#endif TID thread_offsetof (tid) POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t)) TAR_SAVE (offsetof (tcbhead_t, tar_save) - TLS_TCB_OFFSET - sizeof (tcbhead_t)) diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h index 7556e7c..01dc520 100644 --- a/sysdeps/powerpc/nptl/tls.h +++ b/sysdeps/powerpc/nptl/tls.h @@ -43,9 +43,6 @@ # define TLS_DTV_AT_TP 1 # define TLS_TCB_AT_TP 0 -/* We use the multiple_threads field in the pthread struct */ -#define TLS_MULTIPLE_THREADS_IN_TCB 1 - /* Get the thread descriptor definition. */ # include diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h index 7bc6c89..c3adf3c 100644 --- a/sysdeps/s390/nptl/tls.h +++ b/sysdeps/s390/nptl/tls.h @@ -48,10 +48,6 @@ typedef struct void *__private_ss; } tcbhead_t; -# ifndef __s390x__ -# define TLS_MULTIPLE_THREADS_IN_TCB 1 -# endif - #else /* __ASSEMBLER__ */ # include #endif diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h index 547cff1..064ba93 100644 --- a/sysdeps/sh/nptl/tls.h +++ b/sysdeps/sh/nptl/tls.h @@ -36,8 +36,6 @@ typedef struct uintptr_t pointer_guard; } tcbhead_t; -# define TLS_MULTIPLE_THREADS_IN_TCB 1 - #else /* __ASSEMBLER__ */ # include #endif /* __ASSEMBLER__ */ diff --git a/sysdeps/tile/nptl/tls.h b/sysdeps/tile/nptl/tls.h index 7314843..ec64154 100644 --- a/sysdeps/tile/nptl/tls.h +++ b/sysdeps/tile/nptl/tls.h @@ -41,9 +41,6 @@ # define TLS_DTV_AT_TP 1 # define TLS_TCB_AT_TP 0 -/* We use the multiple_threads field in the pthread struct */ -#define TLS_MULTIPLE_THREADS_IN_TCB 1 - /* Get the thread descriptor definition. */ # include diff --git a/sysdeps/unix/sysv/linux/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sysdep-cancel.h index 57bd093..b5a9b29 100644 --- a/sysdeps/unix/sysv/linux/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/sysdep-cancel.h @@ -32,12 +32,24 @@ field. */ #ifdef SINGLE_THREAD_BY_GLOBAL + +extern int __pthread_multiple_threads attribute_hidden; + +/* Variable set to a nonzero value either if more than one thread runs or ran, + or if a single-threaded process is trying to cancel itself. See + nptl/descr.h for more context on the single-threaded process case. */ +# define MULTIPLE_THREADS_PTR_DEF \ + int *__libc_multiple_threads_ptr attribute_hidden + +# define MULTIPLE_THREADS_PTR_SET(__ptr) \ + __libc_multiple_threads_ptr = (__ptr) + # if IS_IN (libc) -extern int __libc_multiple_threads; +extern int __libc_multiple_threads attribute_hidden; # define SINGLE_THREAD_P \ __glibc_likely (__libc_multiple_threads == 0) # elif IS_IN (libpthread) -extern int __pthread_multiple_threads; +extern int *__libc_multiple_threads_ptr attribute_hidden; # define SINGLE_THREAD_P \ __glibc_likely (__pthread_multiple_threads == 0) # elif IS_IN (librt) @@ -48,7 +60,16 @@ extern int __pthread_multiple_threads; /* For rtld, et cetera. */ # define SINGLE_THREAD_P (1) # endif + +# define SET_SINGLE_THREAD_PTHREAD(__value) \ + *__libc_multiple_threads_ptr = __pthread_multiple_threads = (__value) + #else /* SINGLE_THREAD_BY_GLOBAL */ + +# define MULTIPLE_THREADS_PTR_DEF + +# define MULTIPLE_THREADS_PTR_SET(__ptr) __ptr + # if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) # define SINGLE_THREAD_P \ __glibc_likely (THREAD_GETMEM (THREAD_SELF, \ @@ -57,6 +78,8 @@ extern int __pthread_multiple_threads; /* For rtld, et cetera. */ # define SINGLE_THREAD_P (1) # endif + +# define SET_SINGLE_THREAD_PTHREAD(__value) #endif /* SINGLE_THREAD_BY_GLOBAL */ #define RTLD_SINGLE_THREAD_P \