From patchwork Thu Aug 3 13:11:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 109332 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp763782qge; Thu, 3 Aug 2017 06:13:11 -0700 (PDT) X-Received: by 10.84.211.44 with SMTP id b41mr1881620pli.444.1501765991275; Thu, 03 Aug 2017 06:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501765991; cv=none; d=google.com; s=arc-20160816; b=jmFrbrlMy6OqevKC9rFoJNBt0kBe16DuPxvWhtkzRsB1h1BI4FGErz6+NemWBF0Pzk ux7O3qVlXMXT16d1++KUKhVtJsKJIGrzjPQF96yDplG++h9vf8BPQbZ8PvLpRol+kj0z BUUsss9FM+e/XJDJcKfgd/h4vOurEzaBW5gRCEcg86x8k/GWEn2Vve82vbJ6wSBijMFK JRI5ZB03jDKzEPIcMPz2LupjmPpalqSpatftXeSsAPparm39gTnLR0YCSBeTNNgkR31j +4uAjzt0lNwnZzpPt+K7biIoP0l1iSwObEqc5kOxLYz3kBeYwgKj7yzlxLLpmKDVVhgX LETA== 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=A9zc9JLkhlY5gbmcBPYhp0NSNcLC3YSod27Y2zeQ4Xc=; b=AqH1nRhft9+i36c1LOQBMcv3eYQ4aGYAkWkYfUsBQY4oSdBCec/r5kr9gBCPOs4OLt yo6wA7mPvHglOpbYCq3AWv3GN4EiuhZCyMIx1OjzMLXWi+87yx//9w6at0HwReLKHCuW gXiR6o1FLFkfh9sMAkOEa2pMPbCbgVB9YxiX48/OjzqejhJ0tzoSygEJ3mVmJVZI7z2M fFTbVMXCfHLgLFby4VMB0rPWsW604wrWbJLRm6aKPgkFCeRkc/bXcOHPMG1ELcU3Jujd XjjRDHjIlX4KoqiGQHuTe9JCGkd6dMCHSYGByoNAPbq1aCrKnl7HltGyOn1K79xbKyxJ UOzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=fKOkF6+U; spf=pass (google.com: domain of libc-alpha-return-82686-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82686-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 s13si7596765plj.719.2017.08.03.06.13.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Aug 2017 06:13:11 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-82686-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=fKOkF6+U; spf=pass (google.com: domain of libc-alpha-return-82686-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-82686-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=Yv2C/Jiyy+ARmwf7lprVouJusF4oXPy 78gadRwQxAwavX4BLCdM/bgiizhl8elEcfwnC7NabH4+7OuhEtgz8uVEY8twpMZD Tc3Ob4eNHYWWFb4r0DNsSjzmofB/7gy+JQimDGHh+lebaVaCD/aEdFwW8QZ0/FxT 6Gbq5MfvN5hQ= 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=a5DJNsA73miWRVDGY+Cb6LTPXiY=; b=fKOkF 6+UqTfn89TSXRZM7Eef4v3Bl+Seb2TU5ALTeJzmr95TrYN0EGTxXs71YS5aUdav/ xkRuCSmn+ryvZJMsJB0VWsd+sHRXSnrcaCrrOsIpbGdoN2lMlwfDesAVTRm5eYuT uQlp73mC85cL2ZB0FbJ7DdGStRAZ7T6PAdeWN8= Received: (qmail 61740 invoked by alias); 3 Aug 2017 13:11:54 -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 61695 invoked by uid 89); 3 Aug 2017 13:11:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:5063, arrives 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=A9zc9JLkhlY5gbmcBPYhp0NSNcLC3YSod27Y2zeQ4Xc=; b=MybjGfWhH1x7+XReOZIfSySZN8Be7OYIKTjQOfvQ+R6FjNaAMgG/eynOiex5T3Xdb1 9DQuaxZ/Mqp6QaZQHoEgjIzK0BGYnn+EcBp+uWHZlAgbNsebtrcwoop/za/kRnrJJ+WE AookXVoe/ynKV9g/rLv06rfWU6N4xqf6MC5Ax4jjDn2tIvHCJw7PROWvOqNcCu+KJTCO 9x3A3fXiRMLArtWnQdGfuqCqFFU30J5m7osQEHzoXUs/1ivMpCysjecAZ5+lhkYdju/o H9vO9ntvvYA8drR0qer82BiA+2HJb6CdlH2UgdgpeILbughzgGyfiI7n2I8hyjEIdluJ 8d4A== X-Gm-Message-State: AIVw110L+2j80wLi+BOHDUTbtyf4uDOFIq9omkRiBtHX6Z89TwzRsXwn QZyQs2USMmCS+N/lxlaYwQ== X-Received: by 10.200.44.29 with SMTP id d29mr1957212qta.123.1501765909600; Thu, 03 Aug 2017 06:11:49 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/14] Consolidate non cancellable pause call Date: Thu, 3 Aug 2017 10:11:09 -0300 Message-Id: <1501765874-6201-10-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1501765874-6201-1-git-send-email-adhemerval.zanella@linaro.org> References: <1501765874-6201-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable pause calls to use the __pause_nocancel identifier. For non cancellable targets it will be just a macro to call the default respective symbol while on Linux will be a internal one. Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace pause_not_cancel with __pause_nocancel. * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro. (__pause_nocancel): New macro. * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove macro. (__pause_nocancel): New prototype. * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function. --- ChangeLog | 9 +++++++++ include/unistd.h | 2 -- nptl/pthread_mutex_lock.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/posix/pause.c | 15 --------------- sysdeps/unix/sysv/linux/not-cancel.h | 10 ++-------- sysdeps/unix/sysv/linux/pause.c | 14 +++++++++++++- 7 files changed, 26 insertions(+), 28 deletions(-) -- 2.7.4 diff --git a/ChangeLog b/ChangeLog index e1df1c1..877c5d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2017-08-02 Adhemerval Zanella + * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace + pause_not_cancel with __pause_nocancel. + * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro. + (__pause_nocancel): New macro. + * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove + macro. + (__pause_nocancel): New prototype. + * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function. + * login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with __fcntl_nocancel. * sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro. diff --git a/include/unistd.h b/include/unistd.h index 7f1c2cc..a5625ed 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -172,8 +172,6 @@ extern __pid_t __libc_fork (void); /* Suspend the process until a signal arrives. This always returns -1 and sets `errno' to EINTR. */ extern int __libc_pause (void); -/* Not cancelable variant. */ -extern int __pause_nocancel (void) attribute_hidden; extern int __getlogin_r_loginuid (char *name, size_t namesize) attribute_hidden; diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index 8c48503..b158607 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -428,7 +428,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) /* Delay the thread indefinitely. */ while (1) - pause_not_cancel (); + __pause_nocancel (); } oldval = mutex->__data.__lock; diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 3f924c8..f2140c2 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -38,7 +38,7 @@ (void) __writev (fd, iov, n) # define __waitpid_nocancel(pid, stat_loc, options) \ __waitpid (pid, stat_loc, options) -#define pause_not_cancel() \ +#define __pause_nocancel() \ __pause () #define nanosleep_not_cancel(requested_time, remaining) \ __nanosleep (requested_time, remaining) diff --git a/sysdeps/posix/pause.c b/sysdeps/posix/pause.c index 7996cd6..53e143d 100644 --- a/sysdeps/posix/pause.c +++ b/sysdeps/posix/pause.c @@ -39,18 +39,3 @@ __libc_pause (void) weak_alias (__libc_pause, pause) LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */ - -#ifndef NO_CANCELLATION -# include - -int -__pause_nocancel (void) -{ - sigset_t set; - - __sigemptyset (&set); - __sigprocmask (SIG_BLOCK, NULL, &set); - - return sigsuspend_not_cancel (&set); -} -#endif diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index ad46d62..89c1f46 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -78,14 +78,8 @@ __typeof (waitpid) __waitpid_nocancel; libc_hidden_proto (__waitpid_nocancel) /* Uncancelable pause. */ -#define pause_not_cancel() \ - ({ sigset_t set; \ - int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set, \ - _NSIG / 8); \ - if (__rc == 0) \ - __rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8); \ - __rc; \ - }) +__typeof (pause) __pause_nocancel; +libc_hidden_proto (__pause_nocancel) /* Uncancelable nanosleep. */ #define nanosleep_not_cancel(requested_time, remaining) \ diff --git a/sysdeps/unix/sysv/linux/pause.c b/sysdeps/unix/sysv/linux/pause.c index 4ccce9e..ad105d9 100644 --- a/sysdeps/unix/sysv/linux/pause.c +++ b/sysdeps/unix/sysv/linux/pause.c @@ -18,11 +18,12 @@ #include #include + #include +#include /* Suspend the process until a signal arrives. This always returns -1 and sets errno to EINTR. */ - int __libc_pause (void) { @@ -33,3 +34,14 @@ __libc_pause (void) #endif } weak_alias (__libc_pause, pause) + +int +__pause_nocancel (void) +{ +#ifdef __NR_pause + return INLINE_SYSCALL_CALL (pause); +#else + return INLINE_SYSCALL_CALL (ppoll, NULL, 0, NULL, NULL); +#endif +} +libc_hidden_def (__pause_nocancel)