From patchwork Mon Aug 7 21:11:52 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: 109596 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2098285qge; Mon, 7 Aug 2017 14:12:23 -0700 (PDT) X-Received: by 10.99.98.71 with SMTP id w68mr1807943pgb.100.1502140342936; Mon, 07 Aug 2017 14:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502140342; cv=none; d=google.com; s=arc-20160816; b=bjEQCFiX6xQ112hXxbEtgAfNrZPDo+fSs5lMILZqRuN7yeUHod1pLCoUzrsNGKgFxR Jr7blYv8307VlkaP3jNM8zce+uJBb+7ve+/A7uMqSPXOGJKCqmzikF9qY9uosbwFQJIh cwFaCgogJwECPyair2zO6PpdBZDPALg8zceWpHszoXk7boQSTGDU3x3JHBW8J6WaRp/W XMdyOYMiy0607SfqgBBGiDbH4Z4q+PGIEt0Yqp6h+AaGvad6wIH3SJcEA0EdrxHDkBpk LJMSQpbFJMM58y4OMIoafABCUdH3I/RiXlTDts7Z0poG+S0wFSLkKgAdumNtr2jZqFCO xDQw== 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=nSShmUcxOf5zCELc+zjgqPijGgQInYAVAB8P/ksqxYc=; b=gaEF2thLvzhc5CE7mB+txXrPMhO0N2BB5JKnWo6rjyPytk+wSGmOC8jSRPTV4bl+yZ YUJVNTx66NX3KlFGKVXuGNUMozgHCYTn6SKbASGXJHttGvFOsi9CB1HAcer4a1Q3ZIvg +g0hnPyLnAlZ8wjc9eviZY83+yERokj2pC2rt3IpMvJ06X9n+lgZUGfoFNEfK+AbEZg/ 5gaUuUqluI6bJLqi4k+Zz4z09tqRD97UCop6wHI71xalxa/B6MkakMrjOh/3NNgKoYV4 KkSD8NXktUfsq+WY41MlkUTx4fHrmSKnTkr1AEvl+s5rqdRqIKMP6dxohAvclsToNrZI 244w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=pjMbm888; spf=pass (google.com: domain of libc-alpha-return-82820-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82820-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 t12si5889884plm.964.2017.08.07.14.12.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 14:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-82820-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.b=pjMbm888; spf=pass (google.com: domain of libc-alpha-return-82820-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82820-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=dsSRgWPL2t6G1+A3+MFefMG7jzYCoKcGkrdXOpwIb2wgntAA/Lmk1 RWI5T1f5V69GkXYQ0zr4RA6icqaFBXXaeJ1rYpVG6UTiS4JNGptJxopQ956S5fdR Oyd/nlVDpyc9KsOo3zANlLVTs2hKCtoeEmy658+qAFVCMgNTQTeQ98= 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=Uf5K0LgtkTCS5qWI8VWFRJRFSeI=; b=pjMbm888ovAFxbFLbFYnfXPkvmv/ uR0lBv1X9ZyKvVxw9jjHN2xsLb2GXLZSjH5UplD/Wwbcz2n0k/nO8wHVpMq6X2xr FEtlBVpfqx5ytZmvSt0+nq593g7YBeO12m9ve0ERbvg595P19xfQOrNo8ZaI8L1k /neuqAFNtkKkg+Y= Received: (qmail 69247 invoked by alias); 7 Aug 2017 21:12:09 -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 68198 invoked by uid 89); 7 Aug 2017 21:12:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f182.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=nSShmUcxOf5zCELc+zjgqPijGgQInYAVAB8P/ksqxYc=; b=E1u5ujhfV63HnS6FR/E+yokhJ8i0iBHGe7oMU3k4az53cETFQWJQ5vdBOEbcEkz+93 ZI18FYoy2+MxmGRVSpMxIzo0XGptmSeeOxRQUuS69jnc/RxbJCAbRklY8J53703IS4kS HC21tVvVdHVG02/zFmUlEdB8nI2AisQw4y5hXbJGQKygLrsnQV5XFbZBVPe7CJh8qIKd 8MEiUqaKkbR4xbLIGQRF4LHLf1tC3co4qIZfAJh7vDuGtPqPsYz9AHIK34DACrVtxJO3 kBbKGjP7aOudvX5nQLFSsTCLDim5T14d7yjwB4WVDSFDQf1ifnYT4eUkkldbseohTx0P g9yg== X-Gm-Message-State: AHYfb5iWH7wGLWCC0tGMh2pc8vkFvCTg0gXT0qkgoHY+AV/3CJZERSoB fJoOF/jLKwapUQNC+vz94g== X-Received: by 10.200.4.145 with SMTP id s17mr2947677qtg.154.1502140319561; Mon, 07 Aug 2017 14:11:59 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/3] Remove NO_CANCELLATION macro Date: Mon, 7 Aug 2017 18:11:52 -0300 Message-Id: <1502140314-16598-1-git-send-email-adhemerval.zanella@linaro.org> The NO_CANCELLATION macro is used currently on generic headers to define non cancellable syscalls on Linux fcntl to actually implement the non cancellable variation. Former should be handled by not-cancel.h header and former could be simplified to just build the non cancellable version only for loader objects (since Linux already support cancellation as default). This patch thus removes the NO_CANCELLATION macro and its usage. The generic non cancellable fcntl is route to internal fcntl. This is based on my "Remove sysdep-cancel assembly macro" patchset [1]. Checked on x86_64-linux-gnu and i686-linux-gnu. * include/fcntl.h (__fcntl_nocancel): Remove definition. * include/signal.h (__sigsuspend_nocancel): Likewise. * sysdeps/generic/not-cancel.h (__fcntl_nocancel): New macro. * sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (NO_CANCELLATION): Remove macro. * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/arm/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (NO_CANCELLATION): Likewise * sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/tile/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (NO_CANCELLATION): Likewise. * sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): New prototype. * sysdeps/unix/sysv/linux/fcntl.c (__fcntl_nocancel): Define only for !IS_IN (rtld). [1] https://sourceware.org/ml/libc-alpha/2017-08/msg00095.html --- ChangeLog | 42 ++++++++++++++++++++++ include/fcntl.h | 3 -- include/signal.h | 3 -- sysdeps/generic/not-cancel.h | 4 +-- sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/fcntl.c | 24 +++++++------ sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/not-cancel.h | 4 +++ sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 1 - .../unix/sysv/linux/s390/s390-32/sysdep-cancel.h | 1 - .../unix/sysv/linux/s390/s390-64/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/tile/sysdep-cancel.h | 1 - sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h | 1 - 23 files changed, 62 insertions(+), 35 deletions(-) -- 2.7.4 diff --git a/include/fcntl.h b/include/fcntl.h index 9a007c3..3d68c5e 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -9,10 +9,7 @@ extern int __libc_open64 (const char *file, int oflag, ...); extern int __libc_open (const char *file, int oflag, ...); libc_hidden_proto (__libc_open) extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden; -#ifndef NO_CANCELLATION -extern int __fcntl_nocancel (int fd, int cmd, ...) attribute_hidden; libc_hidden_proto (__libc_fcntl) -#endif extern int __open (const char *__file, int __oflag, ...); libc_hidden_proto (__open) extern int __fcntl (int __fd, int __cmd, ...); diff --git a/include/signal.h b/include/signal.h index bcf1455..61ad422 100644 --- a/include/signal.h +++ b/include/signal.h @@ -26,9 +26,6 @@ extern int __sigprocmask (int __how, const sigset_t *__set, sigset_t *__oset); extern int __sigsuspend (const sigset_t *__set); libc_hidden_proto (__sigsuspend) -#ifndef NO_CANCELLATION -extern int __sigsuspend_nocancel (const sigset_t *__set) attribute_hidden; -#endif extern int __sigwait (const sigset_t *__set, int *__sig); libc_hidden_proto (__sigwait) extern int __sigwaitinfo (const sigset_t *__set, siginfo_t *__info); diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 70ead55..3bab664 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -42,5 +42,5 @@ __pause () #define __nanosleep_nocancel(requested_time, remaining) \ __nanosleep (requested_time, remaining) - -#define NO_CANCELLATION 1 +#define __fcntl_nocancel(...) \ + __fcntl(__VA_ARGS__) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h index d39b6a2..2299526 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h @@ -44,7 +44,6 @@ extern int __local_multiple_threads attribute_hidden; /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h index 366cf31..e7d080d 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h @@ -40,7 +40,6 @@ extern int __local_multiple_threads attribute_hidden; #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h index 738e749..3e6840e 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h @@ -43,7 +43,6 @@ extern int __local_multiple_threads attribute_hidden; /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c index 76e846c..cda6be7 100644 --- a/sysdeps/unix/sysv/linux/fcntl.c +++ b/sysdeps/unix/sysv/linux/fcntl.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifndef __NR_fcntl64 # define __NR_fcntl64 __NR_fcntl @@ -46,9 +47,8 @@ fcntl_common (int fd, int cmd, void *arg) return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); } -#ifndef NO_CANCELLATION int -__fcntl_nocancel (int fd, int cmd, ...) +__libc_fcntl (int fd, int cmd, ...) { va_list ap; void *arg; @@ -57,12 +57,18 @@ __fcntl_nocancel (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); + cmd = FCNTL_ADJUST_CMD (cmd); + + if (cmd == F_SETLKW || cmd == F_SETLKW64) + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); + return fcntl_common (fd, cmd, arg); } -#endif +libc_hidden_def (__libc_fcntl) +#if !IS_IN (rtld) int -__libc_fcntl (int fd, int cmd, ...) +__fcntl_nocancel (int fd, int cmd, ...) { va_list ap; void *arg; @@ -71,14 +77,12 @@ __libc_fcntl (int fd, int cmd, ...) arg = va_arg (ap, void *); va_end (ap); - cmd = FCNTL_ADJUST_CMD (cmd); - - if (cmd == F_SETLKW || cmd == F_SETLKW64) - return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg); - return fcntl_common (fd, cmd, arg); } -libc_hidden_def (__libc_fcntl) +#else +strong_alias (__libc_fcntl, __fcntl_nocancel) +#endif +libc_hidden_def (__fcntl_nocancel) weak_alias (__libc_fcntl, __fcntl) libc_hidden_weak (__fcntl) diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h index a6189a7..d5966d9 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h @@ -41,7 +41,6 @@ /* This code should never be used but we define it anyhow. */ # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif /* IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) */ diff --git a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h index 34e2b6f..42ec62f 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h @@ -31,7 +31,6 @@ #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h index 96d04de..02117ad 100644 --- a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h @@ -27,7 +27,6 @@ __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1) #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif #define RTLD_SINGLE_THREAD_P \ diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h index 1603c5f..b91451d 100644 --- a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h @@ -28,7 +28,6 @@ #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION (1) #endif diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h index 7fe030b..ec32745 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h @@ -41,7 +41,6 @@ extern int __local_multiple_threads attribute_hidden; #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION (1) #endif diff --git a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h index fe9a3fc..f40a86d 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h @@ -30,7 +30,6 @@ #else # define SINGLE_THREAD_P 1 -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h index 7647363..b84365a 100644 --- a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h @@ -30,7 +30,6 @@ #else # define SINGLE_THREAD_P 1 -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 8740d40..ef99bac 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -86,4 +86,8 @@ libc_hidden_proto (__pause_nocancel) __typeof (__nanosleep) __nanosleep_nocancel; hidden_proto (__nanosleep_nocancel) +/* Uncancelable fcntl. */ +__typeof (__fcntl) __fcntl_nocancel; +libc_hidden_proto (__fcntl_nocancel) + #endif /* NOT_CANCEL_H */ diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h index 85af880..23dbbbd 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h @@ -29,7 +29,6 @@ #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h index 82763b7..a6ff391 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h @@ -31,7 +31,6 @@ #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h index 952d2af..e54a696 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h @@ -44,7 +44,6 @@ extern int __local_multiple_threads attribute_hidden; #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h index 1ea501b..1b8c5d7 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h @@ -30,7 +30,6 @@ #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h index 61bfa33..f3eb49f 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h @@ -29,7 +29,6 @@ #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h index c8994db..fedabfb 100644 --- a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h @@ -30,7 +30,6 @@ #else # define SINGLE_THREAD_P 1 -# define NO_CANCELLATION 1 #endif diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h index 0979bde..39f9453 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h @@ -46,7 +46,6 @@ extern int __local_multiple_threads attribute_hidden; #else # define SINGLE_THREAD_P (1) -# define NO_CANCELLATION 1 #endif From patchwork Mon Aug 7 21:11:53 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: 109598 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2098630qge; Mon, 7 Aug 2017 14:12:43 -0700 (PDT) X-Received: by 10.98.59.193 with SMTP id w62mr1899300pfj.335.1502140363719; Mon, 07 Aug 2017 14:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502140363; cv=none; d=google.com; s=arc-20160816; b=z0jwnIzYYSGaRrI4aBarRFx/l3fT35qyrkLxRJtj5siQMG+rdIg7Wpa0MBNqJ+SY6F XYAhl0xPmFO1eGhAxJmxR2RKe0cQMqWgmqXb+ZjItGnWdTiLE3ps1kbpQAUkNPN3R136 w//XIN3DAukTCgYuIo0c7u5nd8+OSDfzwCQmmUSkUHljoJ4yWORH6Jy/qNPtB5nw+Dom biswPvlqz+5+YbghCc1NqOztYVU8YdHqNv2FZV2p3pQLcRbHtPACaDT4k1onqIKJrE2/ KB5dFtc7Ly9V359NvHfBYfA7L4WiqRAnysNRCQEaVPW4CIhOIK5dBtwQEm9g7abMUS06 ljoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to: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=En7b4FoivbReJ75QEqSD+vYuLiS47/Rk30DF8UuGmDU=; b=Mj7JXaGl36onMdoCd5qZQI+EPRWteCFT/S3OfIogvGGVdFnDnsk4NhdEm3mf+JZqz0 LnCKhta1+io2quOaWqdDbWXDlq/BC+Yvzcpw0zrcIdzcK+ZiEi+dTbtrx8jZHyzaSV+/ kkdUV9Qf1mkc+QXvCgDJg5rgL8a4+xya+wvvoUH16QRqo5/2slHkxtTR0v1+GhR7Ml+i ZS70XUQQ3DRVHq1NRcFEdnLyq5ZZKo3Dvg/m4SwEFUIgK18T84nTJ7cIPOKvYCYwFBGT rJGahtlsu+wnVNuB3uUjJ85TUGnbHgVodmbi8RT46FQZCFkQuNR5SzUPX7fT4D5eFKJU mONQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=KCfeDK7R; spf=pass (google.com: domain of libc-alpha-return-82822-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82822-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 l63si620141plb.689.2017.08.07.14.12.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 14:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-82822-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.b=KCfeDK7R; spf=pass (google.com: domain of libc-alpha-return-82822-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82822-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:in-reply-to :references; q=dns; s=default; b=Qt5m1qOLP2r6Xug3b7vT5hovjEtoAgQ k0N1Su2+PAGw/rJt9RF0KraU5PQrzRYgTGt/xtO0HTD37Dk9g+mwy04r3mx/hUnU BmT2e2GpcVmfI7aZdDs4hzcwrUIgY1B4rug2U6PmNm5Nb5eNnrs2XKLjQ9iIGZew HeNSOwOnn23s= 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:in-reply-to :references; s=default; bh=i0C6MKVVw+0ubnDc6+MHQjTT6bM=; b=KCfeD K7RtrlkR+Jvi16EIO8SmzjZuBl7a5dGopsNhq7nOSJvEAy88OcKYa8DGUYUDJfJ8 nCGmqooXQSdFwf0YV1XBwz9A4e2CKf8xKydfM42ZlsNgQv02gXkWSdaOgZJ019// Blca9QZXcj7x6mbJgHGstaGK8UUaH2TCpDIj74= Received: (qmail 71102 invoked by alias); 7 Aug 2017 21:12:15 -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 70844 invoked by uid 89); 7 Aug 2017 21:12:14 -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, URIBL_RED autolearn=ham version=3.3.2 spammy=20022017, 2002-2017 X-HELO: mail-qk0-f176.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:in-reply-to :references; bh=En7b4FoivbReJ75QEqSD+vYuLiS47/Rk30DF8UuGmDU=; b=sBJJpjhue82viJoXBEbG0IsOeQ610bxuVBJyhRHfvf7tFuCG28W9X+fIqgmKCPKSEY DjXdIEiK7GAl033vprgjfDnidMj6iaI+CaA14Jz/S5JURYfnjF4qr1ip5XHGiDnGH3zj SmfwF3k7a941hvJiw70uTfE2uIrPFiroG8z6JDG6nqH7/dyJbGQxXdWz4XHQ0Agtp9u7 eXVnJpece0SQJeG9P/Vb4BuFYCatWJV6Zh4BYjaI4QtVbOvlGmfr/xMJuV9VqRlsD7mA w60I6KQWVQ0ISpzUw3cJi5+ircaFrGffyc1vHlv7H/zELg4VRStQxR5xPRrnzSbwZq+C 0A8g== X-Gm-Message-State: AHYfb5hpmwe1zHZBQKWZs7wTedwmOKQrScLnUgtZwYsICaSBZB3pOpzV Jw7bbzL5qIai9JJc5HegDg== X-Received: by 10.55.20.25 with SMTP id e25mr2611047qkh.75.1502140321067; Mon, 07 Aug 2017 14:12:01 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/3] Linux: Consolidate {RTLD_}SINGLE_THREAD_P definition Date: Mon, 7 Aug 2017 18:11:53 -0300 Message-Id: <1502140314-16598-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1502140314-16598-1-git-send-email-adhemerval.zanella@linaro.org> References: <1502140314-16598-1-git-send-email-adhemerval.zanella@linaro.org> Current GLIBC has two ways to implement the single thread optimization on syscalls to avoid calling the cancellation path: either by using global variables (__{libc,pthread}_multiple_thread or by accessing the TCB/pthread_t field (defined by TLS_MULTIPLE_THREADS_IN_TCB). Both the variables and the macros to accessing its values are defined in the architecture sysdep-cancel.h. This patch consolidates its definition on only one header, sysdeps/unix/sysv/linux/sysdep-cancel.h, and adds a new define, SINGLE_THREAD_BY_GLOBAL, which the architecture defines if it prefer to use the global variables instead of the TCP/pthread_t field. This is an optimization, so it the architecture does not define it TCB/pthread_t method will be used (and that's why I have decided not to use two defines so default sysdep-cancel.h could warn if one is not defined). 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). This is based on my "Remove sysdep-cancel assembly macro" patchset [1]. * sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h: Remove file. * sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/arm/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/mips/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/sh/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/tile/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Define. * sysdeps/unix/sysv/linux/aarch64/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Likewise. * sysdeps/unix/sysv/linux/alpha/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Likewise. * sysdeps/unix/sysv/linux/arm/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Likewise. * sysdeps/unix/sysv/linux/hppa/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Likewise. * sysdeps/unix/sysv/linux/microblaze/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (SINGLE_THREAD_BY_GLOBAL): Likewise. [1] https://sourceware.org/ml/libc-alpha/2017-08/msg00095.html --- ChangeLog | 28 ++++++++++ sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 52 ------------------ sysdeps/unix/sysv/linux/aarch64/sysdep.h | 2 + sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 48 ----------------- sysdeps/unix/sysv/linux/alpha/sysdep.h | 2 + sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 51 ------------------ sysdeps/unix/sysv/linux/arm/sysdep.h | 2 + sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 50 ----------------- sysdeps/unix/sysv/linux/hppa/sysdep.h | 2 + sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 39 -------------- sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 34 ------------ sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 37 ------------- sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 49 ----------------- sysdeps/unix/sysv/linux/microblaze/sysdep.h | 2 + sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 38 ------------- sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 38 ------------- sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 37 ------------- .../unix/sysv/linux/s390/s390-32/sysdep-cancel.h | 39 -------------- .../unix/sysv/linux/s390/s390-64/sysdep-cancel.h | 52 ------------------ sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h | 2 + sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 38 ------------- sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 37 ------------- sysdeps/unix/sysv/linux/sysdep-cancel.h | 62 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/tile/sysdep-cancel.h | 38 ------------- sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h | 54 ------------------- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 2 + 26 files changed, 104 insertions(+), 731 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/arm/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/i386/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/mips/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/sh/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h create mode 100644 sysdeps/unix/sysv/linux/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/tile/sysdep-cancel.h delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h deleted file mode 100644 index 2299526..0000000 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# endif - -# if IS_IN (libpthread) || IS_IN (libc) -extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -/* There is no __local_multiple_threads for librt, so use the TCB. */ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# endif - -#else - -/* For rtld, et cetera. */ -# define SINGLE_THREAD_P 1 - -#endif - -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index 4bb9112..c92a480 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -161,6 +161,8 @@ which lead in a non existent __send symbol in libc.so. */ # undef HAVE_INTERNAL_SEND_SYMBOL +# define SINGLE_THREAD_BY_GLOBAL 1 + /* Define a macro which expands into the inline wrapper code for a system call. */ # undef INLINE_SYSCALL diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h deleted file mode 100644 index e7d080d..0000000 --- a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# endif - -# if IS_IN (libpthread) || IS_IN (libc) -extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ - __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# endif - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -# define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h index 4dc2d46..5f4c20e 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -70,6 +70,8 @@ # define __NR_pwrite __NR_pwrite64 #endif +#define SINGLE_THREAD_BY_GLOBAL 1 + /* * In order to get the hidden arguments for rt_sigaction set up * properly, we need to call the assembly version. This shouldn't diff --git a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h deleted file mode 100644 index 3e6840e..0000000 --- a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# endif - -# if IS_IN (libpthread) || IS_IN (libc) -extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -/* There is no __local_multiple_threads for librt, so use the TCB. */ -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# endif - -#else - -/* For rtld, et cetera. */ -# define SINGLE_THREAD_P 1 - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h index 3ca2198..6a64351 100644 --- a/sysdeps/unix/sysv/linux/arm/sysdep.h +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h @@ -437,6 +437,8 @@ __local_syscall_error: \ #define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \ INTERNAL_SYSCALL_RAW (number, err, nr, args) +#define SINGLE_THREAD_BY_GLOBAL 1 + #endif /* __ASSEMBLER__ */ #endif /* linux/arm/sysdep.h */ diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h deleted file mode 100644 index d5966d9..0000000 --- a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2005-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# define __local_multiple_threads __librt_multiple_threads -# else -# error Unsupported library -# endif - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -#else - -/* This code should never be used but we define it anyhow. */ -# define SINGLE_THREAD_P (1) - -#endif -/* IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) */ - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h index c0cd59e..7163ae4 100644 --- a/sysdeps/unix/sysv/linux/hppa/sysdep.h +++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h @@ -504,4 +504,6 @@ L(pre_end): ASM_LINE_SEP \ #define PTR_MANGLE(var) (void) (var) #define PTR_DEMANGLE(var) (void) (var) +#define SINGLE_THREAD_BY_GLOBAL 1 + #endif /* _LINUX_HPPA_SYSDEP_H */ diff --git a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h deleted file mode 100644 index 42ec62f..0000000 --- a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2002-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2002. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h deleted file mode 100644 index 02117ad..0000000 --- a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2002-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2002. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1) -#else -# define SINGLE_THREAD_P (1) -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h deleted file mode 100644 index b91451d..0000000 --- a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2010-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Maxim Kuvyrkov , 2010. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, \ - 1) diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h deleted file mode 100644 index ec32745..0000000 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2014-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# endif - -# if IS_IN (libpthread) || IS_IN (libc) -extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# endif - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h index 1fbbc55..7bf5a4e 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h @@ -308,6 +308,8 @@ SYSCALL_ERROR_LABEL_DCL: \ # define PTR_MANGLE(var) (void) (var) # define PTR_DEMANGLE(var) (void) (var) +# define SINGLE_THREAD_BY_GLOBAL 1 + #endif /* not __ASSEMBLER__ */ #endif /* _LINUX_MICROBLAZE_SYSDEP_H */ diff --git a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h deleted file mode 100644 index f40a86d..0000000 --- a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) \ - == 0, 1) - -#else - -# define SINGLE_THREAD_P 1 - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h deleted file mode 100644 index b84365a..0000000 --- a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Assembler macros with cancellation support, Nios II version. - Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) \ - == 0, 1) - -#else - -# define SINGLE_THREAD_P 1 - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h deleted file mode 100644 index 23dbbbd..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Cancellable system call stubs. Linux/PowerPC version. - Copyright (C) 2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h deleted file mode 100644 index a6ff391..0000000 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2003. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h deleted file mode 100644 index e54a696..0000000 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2003. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# endif - -# if IS_IN (libpthread) || IS_IN (libc) -extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ - __builtin_expect (__local_multiple_threads == 0, 1) - -# else - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -# endif - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h index e22d9b6..622991d 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h @@ -291,6 +291,8 @@ #define HAVE_GETTIMEOFDAY_VSYSCALL 1 #define HAVE_GETCPU_VSYSCALL 1 +#define SINGLE_THREAD_BY_GLOBAL 1 + /* This version is for internal uses when there is no desire to set errno */ #define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \ diff --git a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h deleted file mode 100644 index 1b8c5d7..0000000 --- a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2003-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h deleted file mode 100644 index f3eb49f..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2002. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sysdep-cancel.h new file mode 100644 index 0000000..821114b --- /dev/null +++ b/sysdeps/unix/sysv/linux/sysdep-cancel.h @@ -0,0 +1,62 @@ +/* Single-thread optimization definitions. Linux version. + Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +/* The default way to check if process is single thread is using the + pthread_t 'multiple_threads' field. However for some architectures + it is faster to either use an extra field on TCB or global varibles + (the TCB field is basically used on x86 for some atomic optimizations). + + The ABI might define SINGLE_THREAD_BY_GLOBAL to enable the single + thread check to use global variables instead of the pthread_t + field. */ +#ifdef SINGLE_THREAD_BY_GLOBAL +# if IS_IN (libc) +extern int __libc_multiple_threads; +# 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 +# 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 + +#define RTLD_SINGLE_THREAD_P \ + __glibc_likely (THREAD_GETMEM (THREAD_SELF, \ + header.multiple_threads) == 0) diff --git a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h deleted file mode 100644 index fedabfb..0000000 --- a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2011-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include -#include - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) \ - == 0, 1) - -#else - -# define SINGLE_THREAD_P 1 - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h deleted file mode 100644 index 39f9453..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2002-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Jakub Jelinek , 2002. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include -#ifndef __ASSEMBLER__ -# include -#endif - -#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) - -# if IS_IN (libpthread) -# define __local_multiple_threads __pthread_multiple_threads -# elif IS_IN (libc) -# define __local_multiple_threads __libc_multiple_threads -# elif IS_IN (librt) -# else -# error Unsupported library -# endif - -# if IS_IN (libpthread) || IS_IN (libc) -extern int __local_multiple_threads attribute_hidden; -# define SINGLE_THREAD_P \ - __builtin_expect (__local_multiple_threads == 0, 1) -# else -# define SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) -# endif - -#else - -# define SINGLE_THREAD_P (1) - -#endif - -#define RTLD_SINGLE_THREAD_P \ - __builtin_expect (THREAD_GETMEM (THREAD_SELF, \ - header.multiple_threads) == 0, 1) diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index f299bf2..ad78dd6 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -376,6 +376,8 @@ # define HAVE_GETTIMEOFDAY_VSYSCALL 1 # define HAVE_GETCPU_VSYSCALL 1 +# define SINGLE_THREAD_BY_GLOBAL 1 + #endif /* __ASSEMBLER__ */ From patchwork Mon Aug 7 21:11:54 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: 109597 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp2098417qge; Mon, 7 Aug 2017 14:12:31 -0700 (PDT) X-Received: by 10.84.236.9 with SMTP id q9mr2000444plk.345.1502140351001; Mon, 07 Aug 2017 14:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502140350; cv=none; d=google.com; s=arc-20160816; b=vQMdfVGkFd/0Os81PPdq1sKm6BuYl9oOpfv8PMz+P3gitP074GA9IXcY/0DKci2aGc /WNlY3sg0KYDialwYLYO5Fux5KVD2EntYxTZDb5QDvcN4nhQjEkuXPWic4fzH06yXr/B 74DM31UKKxBibysQpiNj/TMZnqPsm4ogk/6LGKdvtKCuFgpTnz5TdBKNqlkaZMTXbNFu Bagf9JO1Yt3zXBteEGg6psXYct1lvug4ydE6KqHHWY+eDbGr1Uxl+a+NuaeQC0cJjwGL gcGpELkyfCn4Hc5YpFc41z0HcDG3CrLEt0PGfWYGjpwR3YoTuc09ndXd4URxVK5cHtyi ZU6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to: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=hwcpiN9k08tG+LP72w7Rj0dlj2WMKWx8nb2CqZNfhho=; b=KRQtpy+dUjgOQPcntQeQsK2J/YsoMZS4UlzneodhBWkrDxywoTAAnLlOUEEN478Xf3 dlIRbvgcN9yuuPL97v4Q1AY1xPUddPn62PW+orOH5HTnLALoHW9mKJjCwxunMFIcnYYA 6hV/bhMMFGYHcU8GRMqUQWzZ1ftsflghCB5Mzlti4uGKX0c1xyHr8y8zbVCC5+mtyaYe lHhCdIMLjkG8W/ZLj1tgM4vC1Fh0cViZf010csDsOk9Y+YYYDu2XzvxkjEW1DYsNJfXs /f6gWtrpBELrVJuJJ0xgY40l+9ZWmajAawvh46nJBfw473Z12icihgYQVIey06jYx0vO n0gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=PyVWNT9z; spf=pass (google.com: domain of libc-alpha-return-82821-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82821-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 e8si5183716pfd.539.2017.08.07.14.12.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 14:12:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-82821-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.b=PyVWNT9z; spf=pass (google.com: domain of libc-alpha-return-82821-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82821-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:in-reply-to :references; q=dns; s=default; b=pnl9A1P9xqfUigpVyeQB5w6/pEDx84X heSeuC4F05RPIEtd+Lget03fWWnfWgg7wvzjJIA8nMldRsI5UJr0UUebMiOYytcb mQym5UZGOZncPcPCeLINnkIJHF/VfdJYGYhWbQ5qYIgx3f+ym65R3F6LcLEl/0xZ gbcDIQmaSDDo= 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:in-reply-to :references; s=default; bh=eUZuOkChm6vm964KSVTbsiBgErs=; b=PyVWN T9zPQJXBwtzo5j7IQWWJUjvrAHKu9vJvPCg5ZeFTJ8TjpXEZCWdyzRdjjz21x1Nk IAYjR5VdROVeTI3ONYQCuRh5QPI2au91/z4dsIzgc+7aLTfi+udQdsNPWPJ2dgHn F3nhGBDxS+lONof8tvBT53Ba32zr0rGJOkVn8s= Received: (qmail 69941 invoked by alias); 7 Aug 2017 21:12:11 -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 69713 invoked by uid 89); 7 Aug 2017 21:12:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f181.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:in-reply-to :references; bh=hwcpiN9k08tG+LP72w7Rj0dlj2WMKWx8nb2CqZNfhho=; b=iOWYaSFPGd8hQQ76E16nlyHeJobgiKH1ZUMmxCMGaSO4wKvS+uX1pEoQjfkhiQ6z8n gKTLAhInZZXZcQVzWqJol/bkgp9My+1t7XzEr7a26ijWiNwtruUHM23EjQyfTbvOt2QI GJ1ntMHYdWrx4NgPCPMU0rVuKqsYJgDMCIL4vHwMqyKUSYHAIE98OXlypyXUivMfOA/8 BeKZE5P2mxXnMnOaf4mUUBSXtbgs0kKXV9Ie66A+yr2ta0hu2zDQCDmsgvwxrn5YlwBu kICR+OQLOz+E1G3yxACzqifwiEguVPm6Rw2kolabI3TAXlCEg6wgpDJfqfeB51223oLA W42Q== X-Gm-Message-State: AHYfb5jTiDBl5AFZp9OHqPkpGZNRd9NINb0uHEIKC+XSAiBU208+3rAs io+/AMP/ipuv3w9BUeH2pQ== X-Received: by 10.200.36.232 with SMTP id t37mr2887580qtt.273.1502140322408; Mon, 07 Aug 2017 14:12:02 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/3] Single thread optimization refactor Date: Mon, 7 Aug 2017 18:11:54 -0300 Message-Id: <1502140314-16598-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1502140314-16598-1-git-send-email-adhemerval.zanella@linaro.org> References: <1502140314-16598-1-git-send-email-adhemerval.zanella@linaro.org> Current GLIBC uses the define TLS_MULTIPLE_THREADS_IN_TCB to whether declare or not the global variables used for the single thread optimization for cancellable syscalls (STOCS). ALthough it does work correctly, this is not the correct define since there are architectures that do not define TLS_MULTIPLE_THREADS_IN_TCB but does not use the global variables (by prefering accessing the TCB/pthread_t fields instead). With single thread optimization for cancellable syscalls refactored by using SINGLE_THREAD_BY_GLOBAL define, we can use it instead to define where the __{libc,pthread}_multiple_threads is defined. This is based on my "Remove sysdep-cancel assembly macro" patchset [1]. 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. [1] https://sourceware.org/ml/libc-alpha/2017-08/msg00095.html --- ChangeLog | 19 +++++++++++++++++++ nptl/allocatestack.c | 9 +++------ nptl/libc_multiple_threads.c | 4 +--- nptl/libc_pthread_init.c | 12 ++++-------- nptl/nptl-init.c | 14 +++++--------- nptl/pthreadP.h | 14 -------------- nptl/pthread_cancel.c | 7 +++---- nptl/vars.c | 12 ++++++------ sysdeps/unix/sysv/linux/sysdep-cancel.h | 27 +++++++++++++++++++++++++-- 9 files changed, 66 insertions(+), 52 deletions(-) -- 2.7.4 diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index ce2e24a..89cb0de 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifndef NEED_SEPARATE_REGISTER_STACK @@ -456,9 +457,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. */ @@ -576,9 +575,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 0db7a10..aedd92f 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 internal_function __libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), const struct pthread_functions *functions) @@ -74,8 +68,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 6e7d6ff..a79f0b2 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -384,25 +384,11 @@ 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) - internal_function; -#else extern int *__libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void), const struct pthread_functions *functions) internal_function; -/* 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..20ebcd5 100644 --- a/nptl/vars.c +++ b/nptl/vars.c @@ -30,14 +30,14 @@ 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 +/* Table of the key information. */ +struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX] + __attribute__ ((nocommon)); +hidden_data_def (__pthread_keys) + +#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. */ int __pthread_multiple_threads attribute_hidden; #endif - -/* Table of the key information. */ -struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX] - __attribute__ ((nocommon)); -hidden_data_def (__pthread_keys) diff --git a/sysdeps/unix/sysv/linux/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sysdep-cancel.h index 821114b..86044de 100644 --- a/sysdeps/unix/sysv/linux/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/sysdep-cancel.h @@ -30,12 +30,24 @@ thread check to use global variables instead of the pthread_t 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) @@ -46,7 +58,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 + +# 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, \ @@ -55,6 +76,8 @@ extern int __pthread_multiple_threads; /* For rtld, et cetera. */ # define SINGLE_THREAD_P (1) # endif + +# define SET_SINGLE_THREAD_PTHREAD(__value) #endif #define RTLD_SINGLE_THREAD_P \