From patchwork Tue Jul 4 19:53:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 107022 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1362040qge; Tue, 4 Jul 2017 12:56:08 -0700 (PDT) X-Received: by 10.99.124.16 with SMTP id x16mr17627421pgc.280.1499198168747; Tue, 04 Jul 2017 12:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499198168; cv=none; d=google.com; s=arc-20160816; b=GgGL5liKRjR2t/sCmAEjFGBTZHfB2BEj2h0HFEFk6oNeK/HOgUtE6hmDGOaEydCZu1 hvUFcPLTnLocxPF5FlS1blkK2neLuy/ooLp3RpV9OeuCetkJsyUp8K81jGDS9/V679jz WECRWr6no4olyco1OBcHiLijYqtu4S2UD2UY/5W7Dhg80KJdgMTD8JsqnOdH82P04nKS kJFpgl3aziCIpIMskqhPFB2cJiPl3y33qTcVivGBs74aNoGnKVqV5H08qkkn4Lbm+zrA uzaBoT0u/z9/8cQkXGPucxvnYgPzpQ3IM0VMAprdK/alyAeDd/b9qTUwQMAg2DjnVju7 jZlw== 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=p6HG+b6eIzAnjPvTxHDJmJmo5eGstVb1TOBMj0ncJEQ=; b=m5mXtjs5YaLHTkeOghZccTKGH4ek6jE3fgZQ4YZsO6BAGhZCfDD+53uz8GpN0O24Mp eCeagO4g+vfG8fgqmebOUWL3fJ7YF+SXa2vw936jlMKq99NgF1FwoWg7x9GRtfVJa1Dn Ljqo57T1cfkGp9NH12LwKtr0qYb+u6y1WggF0HzeP4SY8vwG/WvyWFdRsTN8cp3RlfHE 8zUJrwMsOFeRAKTdxXgxSLoR5YqkC/0HhrsqGGGfbkYPngEwxuhUud0r6FH0DrhQMzMe L0p+pi+qrHUO3FefIOmEMkmHx9Kr2xe8LJxnX9VQLkVw0ygjnwQIgNYddGcG3Qjn6qmx lGcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.b=Rpjlo16s; spf=pass (google.com: domain of libc-alpha-return-81671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81671-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 u192si15064851pgb.46.2017.07.04.12.56.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jul 2017 12:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-81671-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=Rpjlo16s; spf=pass (google.com: domain of libc-alpha-return-81671-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-81671-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=Zl2RiTCXAqw1LGOCv+D/NcDs8REbUaZ rv8w0GxnX+S8lscAWu4D/1lXbRjMk60ryLbDmzqMtpxVzkcEFxllqryI+Pd6Zuc+ RNyKoQPthZJZedpxRmQC1dxKzsjIqSStPFOuWTHRiWV8oWt0Xn1DXcffmnoW/NAp 6IS4EYTNIurE= 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=eHYnMP9pOVHmoIHXRAx8l4vkJh4=; b=Rpjlo 16spyqBqXVVaZOM5ePCURcpWuXd4kSp01Byj6pqTa/8XyevXwqS14YzAfxT1kkZa ZisSS83YXlRx38BBYZnndCRR7BFSQXxcUjiLhPZYr+GTbuAH7zYv5s5s4uU1EbFc L2Cjck1DCGlz8FpP/ZJMch+Rro3VqtA9ovgm+4= Received: (qmail 74980 invoked by alias); 4 Jul 2017 19:54:25 -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 74077 invoked by uid 89); 4 Jul 2017 19:54:18 -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=suspend X-HELO: mail-qk0-f172.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=p6HG+b6eIzAnjPvTxHDJmJmo5eGstVb1TOBMj0ncJEQ=; b=ehgksQZ7SaRBQLX/6Gy4bOUqAvxRX/W44O/plAl++Q+PkoP/oipCvHUO0kwZuyWGGS 7RMtN4nYzzM8t5x/MjnzFxzv+W03O3IfCFy4GVO8ZNNfTzFysbtbMbUb6sxEB+SaPRSs vThVUAEOf5RBfVHXopmShazM9x9ZIlHqBvAJZ1V72jiNy8eGLIB0haZOGJ39HFBxe9Uc TzH4pYXm7+03P3RHi6zoKjJ2a6f4TogHfkOs4E05P6ULWhgqc/k5l9brUM19g8aLTibW MmJ4ZKPyvd7IfIgDBgjzf4qdX4M9mlzdHEiVYBwrA15FBRPUX0WDIlFMQTaF4fdFE8Rk ujSw== X-Gm-Message-State: AIVw112O+u4/zFBYSXc3IgKuCDC/G6lpPuvTQL/zreBCdjksqKjVSQfQ a4gFJ2Q/FJWDWhnpMQ7LyA== X-Received: by 10.55.209.139 with SMTP id o11mr2146217qkl.144.1499198054996; Tue, 04 Jul 2017 12:54:14 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/14] Consolidate non cancellable pause call Date: Tue, 4 Jul 2017 16:53:49 -0300 Message-Id: <1499198034-5837-10-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-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 +++++++++ nptl/pthread_mutex_lock.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/not-cancel.h | 10 ++-------- sysdeps/unix/sysv/linux/pause.c | 14 +++++++++++++- 5 files changed, 26 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c index b76475b..8fa23c6 100644 --- a/nptl/pthread_mutex_lock.c +++ b/nptl/pthread_mutex_lock.c @@ -425,7 +425,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 6c3afc2..e80b89a 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/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 3047848..00070fd 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)