From patchwork Mon Nov 6 13:36:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118041 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2775261qgn; Mon, 6 Nov 2017 05:37:32 -0800 (PST) X-Google-Smtp-Source: ABhQp+StIfN9U6cFFB4R8O5MqSEzIFssn58Z9dh5cWyZpxes9zoWaeKP9Bz+butv/HM5hv11amH1 X-Received: by 10.84.132.104 with SMTP id 95mr14544734ple.170.1509975452536; Mon, 06 Nov 2017 05:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975452; cv=none; d=google.com; s=arc-20160816; b=D3mlvm6k3BLjWnAPvEqXkQ+TwRjAMd+Hn17i2OaBAi07DladZlUI33XQ1JJQhmCSgo CAwM1bSnEEfScuC+P7c6VabWnkn8lPx5y9ob0vJlgNe/uFkRIJDNM8zUMEQzxgzZh9t/ CzV0Tfnoy8v+37lqRIj9oK5f5GfmopXh7R7UFdcDFMxOzZDPtAor3EzN4E0lQfY22IsJ RjeFUGx77srDVe7vBeJIbmUT1KNVXaUpqS0MgXNkZEmju09xmWQQaPGuq3PDdCPPVd+/ ftyMUIO8CQfZZZIHKOYytSFWhTm02L430TTXDfoylJLvor3SCerrkN3pxPHzY4KTT2k4 HeZg== 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=q5/Q2qbZbWqt4tQ9POZxp3UGrVVbfQfAQAxvvxBrkWo=; b=vIw9ftSJeXWjn2tO99rQhbzX4xL5p/O8+DzBooIT5NLHB12LWDru5iBoibqcyRm9BD vgN+MzOKlUEgi7S8pm7meNP5ff8z3OtMvsPfXqMBBKaru+VnUFQCvSI9dMzQbQoLJOCc PnPYdJjVXIvIfOtVqoIC1WmtWQ3UUaPkFyDmCK/UPUBc6W00Gqv1WUAZT1x14DjRAO+1 cJIVIH9dBSm5we7fbudcRDIODs1UBdsSa6GX4hyRmHBKhGwUu2lqc2FvAzbgX3CFSa7n COjzZWsbJMl7NcwMc98gIPSoiPZi4JsSTVFzevrPQlqciHQu2pvmsksvq9emmwrhHWa4 q9SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HLQ/KjRL; spf=pass (google.com: domain of libc-alpha-return-86792-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86792-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 w10si11001237pgr.25.2017.11.06.05.37.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:37:32 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86792-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HLQ/KjRL; spf=pass (google.com: domain of libc-alpha-return-86792-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86792-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=htVZot7SjMzQc9NXVdFEi23TNziDm4whevAhyUL3UH82I+NCBr1dp UMCRDknsLdbru3YGLSjX7Vyh98EUlWptxmR968YzjgIhIO2gs+rWexn6ZdDIkEZb ulESQ2SSsjr6HCejvEg8Kfh8ppW0BS9iZNBlFQnb2XCsbVof1kwt5Q= 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=vn+YNDGH0LusaHyYOxGZ4Np22SI=; b=HLQ/KjRLRTeGSL6MOfDsGQC8SvMA 0dQ+UTt3dXEuvqE91/cvKMYhPmjz8SP4VnEzyiZq+eL6Ro1GbQwlH3woDF4xhouG iIe5RWqL+IcMbXePN/4ORy981cE8a8sdci6w0Io4Ur/9FJ8vx0J1lH9anolTwxzG zrE4Egm42Now1Bk= Received: (qmail 33283 invoked by alias); 6 Nov 2017 13:37:19 -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 33268 invoked by uid 89); 6 Nov 2017 13:37:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, 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=communicate, sk:INTERNA X-HELO: mail-qt0-f195.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=q5/Q2qbZbWqt4tQ9POZxp3UGrVVbfQfAQAxvvxBrkWo=; b=LDvUB8EumXoeb3mmpFycZN+q2Liz9MybHgGLy+BHUxgO8uvJWWo0W4aWBUr017wh/4 CX4PUDPErsU0AVzcLf2EJS0934Y1ccibYdIwq6G4ATkMPcYoBJfWN9HL0KVC6sQB/ecI u6sBhsYkVsj+kWiBQrNmrZd+FojQqLJX9jZOnX3n6zFWFEk6YTOvdn5MiTku5SRwcd0h /DgliSsmntARFkIymhlAaxnYiefH/ZVIijWCYeFoUi00eGTvnZ956NFewZSLJ8FxrMNf PiVoM19FBcXNHltrE9CHx7ImyQoFOxnYzdBkwxYLq7kY+8SlGsiv+fpr/H//GS8Sksnn QS7w== X-Gm-Message-State: AMCzsaUJxYcsyDB3nDEZlhWBlLVa51XjS9XE7qH6gOB7EAqTYWfSIUzT nrZT5fRwQn3FJ7h5s5ePjP6dy5x3rvw= X-Received: by 10.200.3.205 with SMTP id z13mr23751438qtg.25.1509975434878; Mon, 06 Nov 2017 05:37:14 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 1/8] Rename nptl-signals.h to internal-signals.h Date: Mon, 6 Nov 2017 11:36:59 -0200 Message-Id: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> This patch renames the nptl-signals.h header to internal-signals.h. On Linux the definitions and functions are not only NPTL related, but used for other POSIX definitions as well (for instance SIGTIMER for posix times, SIGSETXID for id functions, and signal block/restore helpers) and since generic functions will be places and used in generic implementation it makes more sense to decouple it from NPTL. Checked on x86_64-linux-gnu. * sysdeps/nptl/nptl-signals.h: Move to ... * sysdeps/generic/internal-signals.h: ... here. Adjust internal comments. * sysdeps/unix/sysv/linux/internal-signals.h: Add include guards. (__nptl_is_internal_signal): Rename to __is_internal_signal. (__nptl_clear_internal_signals): Rename to __clear_internal_signals. * sysdeps/unix/sysv/linux/raise.c: Adjust nptl-signal.h to include-signals.h rename. * nptl/pthreadP.h: Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Call __is_internal_signal instead of __nptl_is_internal_signal. Signed-off-by: Adhemerval Zanella --- ChangeLog | 14 ++++++++++++++ nptl/pthreadP.h | 2 +- .../{nptl/nptl-signals.h => generic/internal-signals.h} | 7 +------ .../unix/sysv/linux/{nptl-signals.h => internal-signals.h} | 13 +++++++++---- sysdeps/unix/sysv/linux/raise.c | 2 +- sysdeps/unix/sysv/linux/spawni.c | 2 +- 6 files changed, 27 insertions(+), 13 deletions(-) rename sysdeps/{nptl/nptl-signals.h => generic/internal-signals.h} (74%) rename sysdeps/unix/sysv/linux/{nptl-signals.h => internal-signals.h} (91%) -- 2.7.4 diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index dbf46b0..e0872b9 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include /* Atomic operations on TLS memory. */ diff --git a/sysdeps/nptl/nptl-signals.h b/sysdeps/generic/internal-signals.h similarity index 74% rename from sysdeps/nptl/nptl-signals.h rename to sysdeps/generic/internal-signals.h index 298acf2..55bc07d 100644 --- a/sysdeps/nptl/nptl-signals.h +++ b/sysdeps/generic/internal-signals.h @@ -1,4 +1,4 @@ -/* Special use of signals in NPTL internals. Stub version. +/* Special use of signals internally. Stub version. Copyright (C) 2014-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -15,8 +15,3 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see . */ - -/* This file can define the macros SIGCANCEL, SIGTIMER, and SIGSETXID to - signal numbers reserved by libpthread for those internal purposes. - - Note that some code presumes SIGTIMER is the same as SIGCANCEL. */ diff --git a/sysdeps/unix/sysv/linux/nptl-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h similarity index 91% rename from sysdeps/unix/sysv/linux/nptl-signals.h rename to sysdeps/unix/sysv/linux/internal-signals.h index f30c597..797698b 100644 --- a/sysdeps/unix/sysv/linux/nptl-signals.h +++ b/sysdeps/unix/sysv/linux/internal-signals.h @@ -1,4 +1,4 @@ -/* Special use of signals in NPTL internals. Linux version. +/* Special use of signals internally. Linux version. Copyright (C) 2014-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,6 +16,9 @@ License along with the GNU C Library; if not, see . */ +#ifndef __INTERNAL_SIGNALS_H +# define __INTERNAL_SIGNALS_H + #include #include @@ -35,14 +38,14 @@ /* Return is sig is used internally. */ static inline int -__nptl_is_internal_signal (int sig) +__is_internal_signal (int sig) { return (sig == SIGCANCEL) || (sig == SIGTIMER) || (sig == SIGSETXID); } /* Remove internal glibc signal from the mask. */ static inline void -__nptl_clear_internal_signals (sigset_t *set) +__clear_internal_signals (sigset_t *set) { __sigdelset (set, SIGCANCEL); __sigdelset (set, SIGTIMER); @@ -66,7 +69,7 @@ static inline int __libc_signal_block_app (sigset_t *set) { sigset_t allset = SIGALL_SET; - __nptl_clear_internal_signals (&allset); + __clear_internal_signals (&allset); INTERNAL_SYSCALL_DECL (err); return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &allset, set, _NSIG / 8); @@ -83,3 +86,5 @@ __libc_signal_restore_set (const sigset_t *set) /* Used to communicate with signal handler. */ extern struct xid_command *__xidcmd attribute_hidden; + +#endif diff --git a/sysdeps/unix/sysv/linux/raise.c b/sysdeps/unix/sysv/linux/raise.c index 70e5a98..1167950 100644 --- a/sysdeps/unix/sysv/linux/raise.c +++ b/sysdeps/unix/sysv/linux/raise.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include int raise (int sig) diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index fb83c2e..af464b5 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -144,7 +144,7 @@ __spawni_child (void *arguments) } else if (sigismember (&hset, sig)) { - if (__nptl_is_internal_signal (sig)) + if (__is_internal_signal (sig)) sa.sa_handler = SIG_IGN; else { From patchwork Mon Nov 6 13:37:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118047 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2776113qgn; Mon, 6 Nov 2017 05:38:30 -0800 (PST) X-Google-Smtp-Source: ABhQp+SyDRx8uUvqyIpze/JvHO+6WpgZsDMYgawcFnxdjbW2JwJ/xxdE5CEX7yRqOLX6EEWnSlfQ X-Received: by 10.99.112.29 with SMTP id l29mr15285804pgc.2.1509975510827; Mon, 06 Nov 2017 05:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975510; cv=none; d=google.com; s=arc-20160816; b=g7unNdetnxJ9zeKc5KX8tYLSJUh7K3MORsT5xRUsZAWVT7GwARK//dryYRHNIz95K+ ZKS6SQkyH9tSqdOG5Kwrg1sBEx0tcN+8VOZCJ28twNobqt8F1/dsYuXfo1C7pLVdFJUn OHtVdebDkU5Axbc13PCT9a3dJdmoaDW9IMju/8+NlsNEB2Mk2daQieN+BYaZcL6cClpo 6ABFn14CoYzZV3xTfirnLWWz20gYax7MKjLpxWfCSx77uNmCoBs0uapX3CYlrjvlJkOV kgk4oAyJV3YNCb29gUJemDGxt4rhYPWjeSa93fJ4cOTcjZbAklUNMKmtbBZroY1fx6Wz gokw== 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:cc: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=s+mUNdra0FcnGNQdgljxcJpOQ++RGvFO3nlG/Gyl8aY=; b=SQ0MhaIUIuM2dKyYykOzoFEW47yLwEVb5J3aaK+FU1+nuW7mP66RSXv1ikADLIA5yO Xyqcy6SOwdVayZSq5h+KClG3BMYuUGwVOvN4eSOyvUuOOjb+uPNBjVSPrW/v7b26zxK9 gUfcdmsZiLBXdB/p4tL3FMuijAqU0sMMyJxoKpe3NvOJNvnY6QcATvwBY5YA7TRzX9dZ GP1pps9cQnlLZy3zDQRcL/Z0ZmxlJU5y+wYdMhM+E3A7e3nVMlvqDUiGiWtBQ874Xqsl 8d4Nri0blzSCgCjiIkfEz7uc1wjEQcueD+Hj2A4j0Ompb6S/yY17ArZha8tPNefuNK24 L9dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=LSTbDgMt; spf=pass (google.com: domain of libc-alpha-return-86797-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86797-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 d5si11592305pgq.280.2017.11.06.05.38.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:38:30 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86797-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=LSTbDgMt; spf=pass (google.com: domain of libc-alpha-return-86797-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86797-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:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=OIvQsntzlR9Gm1ooEQ/2/2BTxLyCfNh riPdKvMCnBr+Ye20779Fett+GKnAg1d5YQjQl/xyIHctZC1anH/ke0XngUERD66K OgXQJAdBle2PzJzAXpvzgZvFPdsdJo0swjEaTsTNS/yF32fbzQ/RhPc0hl3tb1tR NsZhkIB2v0PU= 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:cc:subject:date:message-id:in-reply-to :references; s=default; bh=yzGJN2snHNcij/Etq1YqKh/97iE=; b=LSTbD gMtIZf7qn5+ZLjNtSAyb+9xk0kn6e0YI4znu6oOHw9D7wyayqjbaKvkSBMHNBGGN D0us65kFa7ZLXV109i6jHM023Ssutmy+E9BpygIKxuDb1ZYj7JHYqwVIUcyRsyqm 0YrYUGvKFkopLWvSCMooVP0qsG3gSdNqQqqkK8= Received: (qmail 34193 invoked by alias); 6 Nov 2017 13:37:26 -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 34086 invoked by uid 89); 6 Nov 2017 13:37:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, 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=H*Ad:D*panix.com X-HELO: mail-qt0-f175.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:cc:subject:date:message-id:in-reply-to :references; bh=s+mUNdra0FcnGNQdgljxcJpOQ++RGvFO3nlG/Gyl8aY=; b=OtpfU1d/gElnhN1BT2X3d9Na9k4JTh4Zkt4V1Y7fuhncDb3k6i/V13tYrtg6s6c3F8 9BE+wW+LLjaqhFB2t/2TlJs5OqvqqsurKSfJGkpyHe69F7/+lTu1xNOsxxBAf0yCeSPJ ByE6auxWOGVqt0hiGc1+gzT0LstpMNf4ZgHjzHolLC3mhkA18WjUdt3TpkAurnrLk2e1 tTp6hNfBto2YbdDqO3cVLVh2fHQawlKa0UNsdtHkYP5Fgh1ryilhFtPewmGbgKteC+eq E8lN/wGl6e15FzHssvjPG3tJfTyrj0czABzCaf9/TH4v7mGy5LUUlo69mwLrL49Mfr2K vTkw== X-Gm-Message-State: AMCzsaVWAFHaGEwQzR/fWIR8rCAKf60yb+TN72SDVmqtAHz4k7jJGDNw SxUIsPCuu7pSmWFvDVhOd+Bnmcm8sCg= X-Received: by 10.200.63.156 with SMTP id d28mr23000221qtk.170.1509975436561; Mon, 06 Nov 2017 05:37:16 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Zack Weinberg Subject: [PATCH v2 2/8] Consolidate Linux sigprocmask implementation (BZ #22391) Date: Mon, 6 Nov 2017 11:37:00 -0200 Message-Id: <1509975426-1772-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Rewrite manual/signal.text based on Zack Weinberg suggestion. --- This patch consolidates the sigprocmask Linux syscall implementation on sysdeps/unix/sysv/linux/sigprocmask.c. The changes are: 1. For ia64, s390-64, sparc64, and x86_64 the default semantic for filter out SIGCANCEL and SIGSETXID is used. Also the Linux pthread semantic is documented in the signal chapter. 2. A new internal function to check for NPTL internal signals within a signal set is added (__nptl_has_internal_signal). It is used to simplify the default sigprocmask.c implementation. Checked on x86_64-linux-gnu. [BZ #22391] * manual/signal.texi: Add a note about internal pthread signals on Linux. * sysdeps/unix/sysv/linux/ia64/sigprocmask.c: Remove file. * sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/nptl-signals.h (__nptl_has_internal_signal): New function. * sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask): Use __nptl_has_internal_signal and __nptl_clear_internal_signals function. Signed-off-by: Adhemerval Zanella Signed-off-by: Zack Weinberg Reported-by: Yury Norov --- ChangeLog | 17 +++++++ manual/signal.texi | 37 ++++++++++++++ sysdeps/unix/sysv/linux/alpha/sigprocmask.c | 58 ---------------------- sysdeps/unix/sysv/linux/ia64/sigprocmask.c | 40 --------------- sysdeps/unix/sysv/linux/internal-signals.h | 6 +++ sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c | 38 -------------- sysdeps/unix/sysv/linux/sigprocmask.c | 23 +++------ .../unix/sysv/linux/sparc/sparc64/sigprocmask.c | 34 ------------- sysdeps/unix/sysv/linux/x86_64/sigprocmask.c | 39 --------------- 9 files changed, 66 insertions(+), 226 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/ia64/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sigprocmask.c -- 2.7.4 diff --git a/manual/signal.texi b/manual/signal.texi index 9577ff0..4f0ef59 100644 --- a/manual/signal.texi +++ b/manual/signal.texi @@ -235,6 +235,7 @@ defined. Since the signal numbers are allocated consecutively, * Job Control Signals:: Signals used to support job control. * Operation Error Signals:: Used to report operational system errors. * Miscellaneous Signals:: Miscellaneous Signals. +* Internally-Used Signals:: Signals used internally by the C library. * Signal Messages:: Printing a message describing a signal. @end menu @@ -794,6 +795,26 @@ in @ref{Signaling Another Process}. The default action is to terminate the process. @end deftypevr +@deftypevr Macro int SIGRTMIN +@deftypevrx Macro int SIGRTMAX +@standards{POSIX.1, signal.h} +@cindex real-time signals +The range of signal numbers @code{SIGRTMIN}, @code{SIGRTMIN+1}, +@dots{}, @code{SIGRTMAX} is also set aside for you to use any way you +want. In addition, these signals (and no others) are guaranteed to +support @dfn{real-time} signal semantics, which unfortunately this +manual does not yet document. + +Unlike all of the other signal number macros, @code{SIGRTMIN} and +@code{SIGRTMAX} are not compile-time constants, because some operating +systems make the number of real-time signals tunable on a +per-installation or even per-process basis. However, POSIX guarantees +that there will be at least 8 signal numbers in this range. + +The default action for all signals in this range is to terminate the +process. +@end deftypevr + @deftypevr Macro int SIGWINCH @standards{BSD, signal.h} Window size change. This is generated on some systems (including GNU) @@ -817,6 +838,22 @@ to print some status information about the system and what the process is doing. Otherwise the default is to do nothing. @end deftypevr +@node Internally-Used Signals +@subsection Internally-Used Signals +@cindex internally used signals + +On some operating systems, @theglibc{} needs to use a few signals from +the ``true'' real-time range internally, to implement thread +cancellation, cross-thread effective ID synchronization, POSIX timer +management, etc. @Theglibc{} adjusts @code{SIGRTMIN} and +@code{SIGRTMAX} to exclude these signals, and it also takes steps to +prevent application code from altering their state: @code{sigprocmask} +cannot block them and @code{sigaction} cannot redefine their handlers, +for instance. Therefore, most programs do not need to know or care +about these signals. We mainly document their existence for the sake +of anyone who has ever wondered why there is a gap between the +highest-numbered ``normal'' signal and @code{SIGRTMIN} on Linux. + @node Signal Messages @subsection Signal Messages @cindex signal messages diff --git a/sysdeps/unix/sysv/linux/alpha/sigprocmask.c b/sysdeps/unix/sysv/linux/alpha/sigprocmask.c deleted file mode 100644 index ebec70c..0000000 --- a/sysdeps/unix/sysv/linux/alpha/sigprocmask.c +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 1993-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by David Mosberger (davidm@azstarnet.com). - - 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 - -/* When there is kernel support for more than 64 signals, we'll have to - switch to a new system call convention here. */ - -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - unsigned long int setval; - long result; - - if (set) - setval = set->__val[0]; - else - { - setval = 0; - how = SIG_BLOCK; /* ensure blocked mask doesn't get changed */ - } - - result = INLINE_SYSCALL (osf_sigprocmask, 2, how, setval); - if (result == -1) - /* If there are ever more than 63 signals, we need to recode this - in assembler since we wouldn't be able to distinguish a mask of - all 1s from -1, but for now, we're doing just fine... */ - return result; - - if (oset) - { - oset->__val[0] = result; - result = _SIGSET_NWORDS; - while (--result > 0) - oset->__val[result] = 0; - } - return 0; -} - -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask); diff --git a/sysdeps/unix/sysv/linux/ia64/sigprocmask.c b/sysdeps/unix/sysv/linux/ia64/sigprocmask.c deleted file mode 100644 index 920c5fd..0000000 --- a/sysdeps/unix/sysv/linux/ia64/sigprocmask.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Linux/IA64 specific sigprocmask - Written by Jes Sorensen, , April 1999. - - 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 - . */ - -/* Linux/ia64 only has rt signals, thus we do not even want to try falling - back to the old style signals as the default Linux handler does. */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/internal-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h index 797698b..ad9783b 100644 --- a/sysdeps/unix/sysv/linux/internal-signals.h +++ b/sysdeps/unix/sysv/linux/internal-signals.h @@ -36,6 +36,12 @@ #define SIGSETXID (__SIGRTMIN + 1) +static inline bool +__nptl_has_internal_signal (const sigset_t *set) +{ + return __sigismember (set, SIGCANCEL) || __sigismember (set, SIGSETXID); +} + /* Return is sig is used internally. */ static inline int __is_internal_signal (int sig) diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c b/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c deleted file mode 100644 index a8010e7..0000000 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2001-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 - . */ - -/* 64 bit Linux for S/390 only has rt signals, thus we do not even want to try - falling back to the old style signals as the default Linux handler does. */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c index e776563..d14fc5c 100644 --- a/sysdeps/unix/sysv/linux/sigprocmask.c +++ b/sysdeps/unix/sysv/linux/sigprocmask.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. +/* Get and/or change the set of blocked signals. Linux version. + Copyright (C) 1997-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 @@ -17,34 +18,22 @@ #include #include -#include /* Needed for string function builtin redirection. */ -#include +#include -#include -#include -#include /* SIGCANCEL, SIGSETXID */ - - -/* Get and/or change the set of blocked signals. */ int __sigprocmask (int how, const sigset_t *set, sigset_t *oset) { sigset_t local_newmask; - /* The only thing we have to make sure here is that SIGCANCEL and - SIGSETXID are not blocked. */ - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) + if (set != NULL && __glibc_unlikely (__nptl_has_internal_signal (set))) { local_newmask = *set; - __sigdelset (&local_newmask, SIGCANCEL); - __sigdelset (&local_newmask, SIGSETXID); + __nptl_clear_internal_signals (&local_newmask); set = &local_newmask; } - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); + return INLINE_SYSCALL_CALL (rt_sigprocmask, how, set, oset, _NSIG / 8); } libc_hidden_def (__sigprocmask) weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c b/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c deleted file mode 100644 index ef7d7fe..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 1997-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 -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) diff --git a/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c b/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c deleted file mode 100644 index 1610ddf..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 1997-2017 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Written by Jes Sorensen, , April 1999. - - 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 - . */ - -/* Linux/x86_64 only has rt signals, thus we do not even want to try falling - back to the old style signals as the default Linux handler does. */ - -#include -#include -#include - -#include -#include - -/* Get and/or change the set of blocked signals. */ -int -__sigprocmask (int how, const sigset_t *set, sigset_t *oset) -{ - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8); -} -libc_hidden_def (__sigprocmask) -weak_alias (__sigprocmask, sigprocmask) From patchwork Mon Nov 6 13:37:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118042 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2775386qgn; Mon, 6 Nov 2017 05:37:42 -0800 (PST) X-Google-Smtp-Source: ABhQp+T8ej960ZDPpzOZxo7SYA0iaV3nLB2+3bY4nhxCORI4Fs2M97Zmx5mClU+2SZIOXiDrYd9C X-Received: by 10.159.253.147 with SMTP id q19mr14852527pls.54.1509975462689; Mon, 06 Nov 2017 05:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975462; cv=none; d=google.com; s=arc-20160816; b=x4giYHpnaH1etPKehDtauJ9JEOziApoo2C0oaz4bsD1D8ttj7tBytrkTNxa4zBjALk fD7i+1O1gf9bgACZAFgBUn61WYsZw/zBzDH7snEKhZu5l4/iL7HFcLe5yhWHnQ4r0uwu botdQ4334zjRymk4aswQBYE0djgnXot1zSgHOjmfL68kjMonKCUrW5nDuhR1KZLzgwbZ 61ZSZ59Lkn/xreePxhTwfpgNo18dQWeUu19CWQGtYHz1Wg362Aie3Em79tHiyqmB9r8f kKhDCAUgL+b5FQBLs/pImuZlw7qZKnaIoxy2k9B+zvJABYg45ZgxUnuX81hxXgSBhlGN RJGQ== 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=zntCFwta8FLEpQr0drcV07jW4KbVmA5NoxIK5uqHlC4=; b=DMTAuZ1kCMRk6vhyJtg+26pGAeXhBmq94q3JJHyY8IKMFawciZK5tFGVyahegUucBB +TnzTyTHicXZNstzNZwbh1s/9dnusqPuaTocQGE4iggs4jeZuDcec4zxsy3n4gIyjqJ2 jOqWzapni7aq0IKcNRl8pPziSGckZnnlcqByGz95dyAb8skDr4gEbODocIzHAwxRPxT7 7K+XSTZEoVJpL7L3G3DPjwokCxWtm1dOxSmj2COVk9pcbni9/z/wWYMP0jhruqh42h/O JBfb9d3mPB4EHQ8stD0yL/iqag0pyLmpfGfzBnCepllljKREC7wIcqzb3eVGaDYf5h0A fAqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JDaFF2aQ; spf=pass (google.com: domain of libc-alpha-return-86793-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86793-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 z18si12145171pfl.68.2017.11.06.05.37.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:37:42 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86793-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JDaFF2aQ; spf=pass (google.com: domain of libc-alpha-return-86793-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86793-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=UzI6tISC97Jgxu2TkSmw889YA8ebr8M Ev2WxXkvjXozJ10GALYm2OUbQ7qlpPARsUTNQMmFD5ovIXZdehwRALq7jbqNsLRs LUNbjeofJAH/dB1WhL7ce5kJSgey1KajAizWvMOQPGpLyTaYsCgLLuaEeb0QXDu6 /6fmu9Qk129w= 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=58NokpJTSCwKVVXhOVJKr8VejOE=; b=JDaFF 2aQ6dTYVHtJNCay3Xnf92kRtVoxqWV/zIs92CV7RicyUMokDUm1Cuqmb4gfFSzBM QkdvGbDQQL00jp4MwS3XyV1ihc67MNqH2cbeDntYkfNwZGMS/1lHC+4L46kAT72+ CzSg/ax+3saggl0PEFL0SJdEpX2Cn7PRnMxvRA= Received: (qmail 33749 invoked by alias); 6 Nov 2017 13:37:24 -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 33656 invoked by uid 89); 6 Nov 2017 13:37:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, 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=filters, inadvertently, filtering, VERIFY X-HELO: mail-qt0-f178.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=zntCFwta8FLEpQr0drcV07jW4KbVmA5NoxIK5uqHlC4=; b=J8Grr3wgUTi3t0/PjNSL8Oqb9tA28TMNcZBDefvE9pzAlQCmcglwI6N2WYNxWdmw9q //TVurP+kXHr+LQdTloqMO5cxVAgbgGF70jfN0Zol+EYfNnAOw3fOADhxiThlHU13V89 BAmcTw0IHP/PPiCyKdv+v0crJ4jsnwKd3iyWnCSDTFR9BBq/xm5CuvfAO+3a63In9WYl uDxwVqlV7NVZJCOAGcp35zjDPCc9TxlYimnBLMaLWVSkNhTaK0Ie+iSDB0HhaG2w6Rla 5XgLHD+4aQ241QOzjcb8hnIlbcogtt2wows0USPDHNoMayiRaUnMUq3c6hXE7GgZ9hRN CSrg== X-Gm-Message-State: AMCzsaUjUS7bG4MJvmBrEioHN8tCZ4SrK5zVUSGCGsZaUVYLk0Eynz/Q 8GKSdFdRWT/uLi/9pApUfZ4R2xMyT/U= X-Received: by 10.200.49.178 with SMTP id h47mr21964523qte.0.1509975438173; Mon, 06 Nov 2017 05:37:18 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 3/8] Filter out NPTL internal signals (BZ #22391) Date: Mon, 6 Nov 2017 11:37:01 -0200 Message-Id: <1509975426-1772-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Use the internal-signals.h headers instead of nptl-signals. --- This patch filters out the internal NPTL signals (SIGCANCEL/SIGTIMER and SIGSETXID) from signal functions. GLIBC on Linux requires both signals to proper implement pthread cancellation, posix timers, and set*id posix thread synchronization. And not filtering out the internal signal is troublesome: - A conformant program on a architecture that does not filter out the signals might inadvertently disable pthread asynchronous cancellation, set*id synchronization or posix timers. - It might also to security issues if SIGSETXID is masked and set*id functions are called (some threads might have effective user or group id different from the rest). The changes are basically: - Change __nptl_is_internal_signal to bool and used on all signal function that has a signal number as input. Also for signal function which accepts signals sets (sigset_t) it assumes that canonical function were used to add/remove signals which lead to some input simplification. - Fix tst-sigset.c to avoid check for SIGCANCEL/SIGTIMER and SIGSETXID. It is rewritten to check each signal indidually and to check realtime signals using canonical macros. - Add generic __nptl_clear_internal_signals and __nptl_is_internal_signal version since both symbols are used on generic implementations. - Remove superflous sysdeps/nptl/sigfillset.c. - Remove superflous SIGTIMER handling on Linux __nptl_is_internal_signal since it is the same of SIGCANCEL. - Remove dnagling define and obvious comment on nptl/sigaction.c. Checked on x86_64-linux-gnu. [BZ #22391] * nptl/sigaction.c (__sigaction): Use __nptl_is_internal_signal to check for internal nptl signals. * signal/sigaddset.c (sigaddset): Likewise. * signal/sigdelset.c (sigdelset): Likewise. * sysdeps/posix/signal.c (__bsd_signal): Likewise. * sysdeps/posix/sigset.c (sigset): Call and check sigaddset return value. * signal/sigfillset.c (sigfillset): User __nptl_clear_internal_signals to filter out internal nptl signals. * signal/tst-sigset.c (do_test): Check ech signal indidually and also check realtime signals using standard macros. * sysdeps/nptl/nptl-signals.h (__nptl_clear_internal_signals, __nptl_is_internal_signal): New functions. * sysdeps/nptl/sigfillset.c: Remove file. * sysdeps/unix/sysv/linux/nptl-signals.h (__nptl_is_internal_signal): Change return to bool. (__nptl_clear_internal_signals): Remove SIGTIMER clean since it is equal to SIGCANEL on Linux. * sysdeps/unix/sysv/linux/sigtimedwait.c (__sigtimedwait): Assume signal set was constructed using standard functions. * sysdeps/unix/sysv/linux/sigwait.c (do_sigtwait): Likewise. Signed-off-by: Adhemerval Zanella Reported-by: Yury Norov --- ChangeLog | 25 ++++++++ nptl/sigaction.c | 14 +---- signal/sigaction.c | 2 +- signal/sigaddset.c | 5 +- signal/sigdelset.c | 5 +- signal/sigfillset.c | 10 +--- signal/tst-sigset.c | 92 ++++++++++++++++++++++-------- sysdeps/generic/internal-signals.h | 11 ++++ sysdeps/nptl/sigfillset.c | 20 ------- sysdeps/posix/signal.c | 5 +- sysdeps/posix/sigset.c | 10 +--- sysdeps/unix/sysv/linux/internal-signals.h | 5 +- sysdeps/unix/sysv/linux/sigprocmask.c | 4 +- sysdeps/unix/sysv/linux/sigtimedwait.c | 17 +----- sysdeps/unix/sysv/linux/sigwait.c | 13 ----- 15 files changed, 126 insertions(+), 112 deletions(-) delete mode 100644 sysdeps/nptl/sigfillset.c -- 2.7.4 diff --git a/nptl/sigaction.c b/nptl/sigaction.c index 2994fd5..b2ff674 100644 --- a/nptl/sigaction.c +++ b/nptl/sigaction.c @@ -16,22 +16,12 @@ License along with the GNU C Library; if not, see . */ - -/* This is no complete implementation. The file is meant to be - included in the real implementation to provide the wrapper around - __libc_sigaction. */ - -#include - -/* We use the libc implementation but we tell it to not allow - SIGCANCEL or SIGTIMER to be handled. */ -#define LIBC_SIGACTION 1 - +#include int __sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { - if (__glibc_unlikely (sig == SIGCANCEL || sig == SIGSETXID)) + if (sig <= 0 || sig >= NSIG || __is_internal_signal (sig)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigaction.c b/signal/sigaction.c index 8a6220c..3025aab 100644 --- a/signal/sigaction.c +++ b/signal/sigaction.c @@ -24,7 +24,7 @@ int __sigaction (int sig, const struct sigaction *act, struct sigaction *oact) { - if (sig <= 0 || sig >= NSIG) + if (sig <= 0 || sig >= NSIG || __is_internal_signal (sig)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigaddset.c b/signal/sigaddset.c index 161be7b..a435f61 100644 --- a/signal/sigaddset.c +++ b/signal/sigaddset.c @@ -17,13 +17,14 @@ #include #include -#include +#include /* Add SIGNO to SET. */ int sigaddset (sigset_t *set, int signo) { - if (set == NULL || signo <= 0 || signo >= NSIG) + if (set == NULL || signo <= 0 || signo >= NSIG + || __is_internal_signal (signo)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigdelset.c b/signal/sigdelset.c index 2aaa536..01a50ec 100644 --- a/signal/sigdelset.c +++ b/signal/sigdelset.c @@ -17,13 +17,14 @@ #include #include -#include +#include /* Add SIGNO to SET. */ int sigdelset (sigset_t *set, int signo) { - if (set == NULL || signo <= 0 || signo >= NSIG) + if (set == NULL || signo <= 0 || signo >= NSIG + || __is_internal_signal (signo)) { __set_errno (EINVAL); return -1; diff --git a/signal/sigfillset.c b/signal/sigfillset.c index 0fcc24a..560c66e 100644 --- a/signal/sigfillset.c +++ b/signal/sigfillset.c @@ -18,6 +18,7 @@ #include #include #include +#include /* Set all signals in SET. */ int @@ -31,14 +32,7 @@ sigfillset (sigset_t *set) memset (set, 0xff, sizeof (sigset_t)); - /* If the implementation uses a cancellation signal don't set the bit. */ -#ifdef SIGCANCEL - __sigdelset (set, SIGCANCEL); -#endif - /* Likewise for the signal to implement setxid. */ -#ifdef SIGSETXID - __sigdelset (set, SIGSETXID); -#endif + __clear_internal_signals (set); return 0; } diff --git a/signal/tst-sigset.c b/signal/tst-sigset.c index d47adcc..a2b764d 100644 --- a/signal/tst-sigset.c +++ b/signal/tst-sigset.c @@ -1,43 +1,85 @@ /* Test sig*set functions. */ #include -#include -#define TEST_FUNCTION do_test () +#include + static int do_test (void) { - int result = 0; - int sig = -1; + sigset_t set; + TEST_VERIFY (sigemptyset (&set) == 0); -#define TRY(call) \ - if (call) \ - { \ - printf ("%s (sig = %d): %m\n", #call, sig); \ - result = 1; \ - } \ - else +#define VERIFY(set, sig) \ + TEST_VERIFY (sigismember (&set, sig) == 0); \ + TEST_VERIFY (sigaddset (&set, sig) == 0); \ + TEST_VERIFY (sigismember (&set, sig) != 0); \ + TEST_VERIFY (sigdelset (&set, sig) == 0); \ + TEST_VERIFY (sigismember (&set, sig) == 0) + /* ISO C99 signals. */ + VERIFY (set, SIGINT); + VERIFY (set, SIGILL); + VERIFY (set, SIGABRT); + VERIFY (set, SIGFPE); + VERIFY (set, SIGSEGV); + VERIFY (set, SIGTERM); - sigset_t set; - TRY (sigemptyset (&set) != 0); + /* Historical signals specified by POSIX. */ + VERIFY (set, SIGHUP); + VERIFY (set, SIGQUIT); + VERIFY (set, SIGTRAP); + VERIFY (set, SIGKILL); + VERIFY (set, SIGBUS); + VERIFY (set, SIGSYS); + VERIFY (set, SIGPIPE); + VERIFY (set, SIGALRM); + + /* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */ + VERIFY (set, SIGURG); + VERIFY (set, SIGSTOP); + VERIFY (set, SIGTSTP); + VERIFY (set, SIGCONT); + VERIFY (set, SIGCHLD); + VERIFY (set, SIGTTIN); + VERIFY (set, SIGTTOU); + VERIFY (set, SIGPOLL); + VERIFY (set, SIGXCPU); + VERIFY (set, SIGXFSZ); + VERIFY (set, SIGVTALRM); + VERIFY (set, SIGPROF); + VERIFY (set, SIGUSR1); + VERIFY (set, SIGUSR2); + + /* Nonstandard signals found in all modern POSIX systems + (including both BSD and Linux). */ + VERIFY (set, SIGWINCH); -#ifdef SIGRTMAX - int max_sig = SIGRTMAX; -#else - int max_sig = NSIG - 1; + /* Arch-specific signals. */ +#ifdef SIGEMT + VERIFY (set, SIGEMT); +#endif +#ifdef SIGLOST + VERIFY (set, SIGLOST); +#endif +#ifdef SIGINFO + VERIFY (set, SIGINFO); +#endif +#ifdef SIGSTKFLT + VERIFY (set, SIGSTKFLT); +#endif +#ifdef SIGPWR + VERIFY (set, SIGPWR); #endif - for (sig = 1; sig <= max_sig; ++sig) + /* Read-time signals (POSIX.1b real-time extensions). If they are + supported SIGRTMAX value is greater than SIGRTMIN. */ + for (int rtsig = SIGRTMIN; rtsig <= SIGRTMAX; rtsig++) { - TRY (sigismember (&set, sig) != 0); - TRY (sigaddset (&set, sig) != 0); - TRY (sigismember (&set, sig) == 0); - TRY (sigdelset (&set, sig) != 0); - TRY (sigismember (&set, sig) != 0); + VERIFY (set, rtsig); } - return result; + return 0; } -#include "../test-skeleton.c" +#include diff --git a/sysdeps/generic/internal-signals.h b/sysdeps/generic/internal-signals.h index 55bc07d..8a8854c 100644 --- a/sysdeps/generic/internal-signals.h +++ b/sysdeps/generic/internal-signals.h @@ -15,3 +15,14 @@ You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see . */ + +static inline void +__clear_internal_signals (sigset_t *set) +{ +} + +static inline bool +__is_internal_signal (int sig) +{ + return false; +} diff --git a/sysdeps/nptl/sigfillset.c b/sysdeps/nptl/sigfillset.c deleted file mode 100644 index 50e8512..0000000 --- a/sysdeps/nptl/sigfillset.c +++ /dev/null @@ -1,20 +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 diff --git a/sysdeps/posix/signal.c b/sysdeps/posix/signal.c index 81ba177..87c5d1c 100644 --- a/sysdeps/posix/signal.c +++ b/sysdeps/posix/signal.c @@ -18,8 +18,8 @@ #include #include -#include /* For the real memset prototype. */ #include +#include sigset_t _sigintr attribute_hidden; /* Set by siginterrupt. */ @@ -31,7 +31,8 @@ __bsd_signal (int sig, __sighandler_t handler) struct sigaction act, oact; /* Check signal extents to protect __sigismember. */ - if (handler == SIG_ERR || sig < 1 || sig >= NSIG) + if (handler == SIG_ERR || sig < 1 || sig >= NSIG + || __is_internal_signal (sig)) { __set_errno (EINVAL); return SIG_ERR; diff --git a/sysdeps/posix/sigset.c b/sysdeps/posix/sigset.c index a4dfe0a..6234ecf 100644 --- a/sysdeps/posix/sigset.c +++ b/sysdeps/posix/sigset.c @@ -31,15 +31,9 @@ sigset (int sig, __sighandler_t disp) sigset_t set; sigset_t oset; - /* Check signal extents to protect __sigismember. */ - if (disp == SIG_ERR || sig < 1 || sig >= NSIG) - { - __set_errno (EINVAL); - return SIG_ERR; - } - __sigemptyset (&set); - __sigaddset (&set, sig); + if (sigaddset (&set, sig) < 0) + return SIG_ERR; if (disp == SIG_HOLD) { diff --git a/sysdeps/unix/sysv/linux/internal-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h index ad9783b..219415c 100644 --- a/sysdeps/unix/sysv/linux/internal-signals.h +++ b/sysdeps/unix/sysv/linux/internal-signals.h @@ -21,6 +21,8 @@ #include #include +#include +#include /* The signal used for asynchronous cancelation. */ #define SIGCANCEL __SIGRTMIN @@ -43,7 +45,7 @@ __nptl_has_internal_signal (const sigset_t *set) } /* Return is sig is used internally. */ -static inline int +static inline bool __is_internal_signal (int sig) { return (sig == SIGCANCEL) || (sig == SIGTIMER) || (sig == SIGSETXID); @@ -54,7 +56,6 @@ static inline void __clear_internal_signals (sigset_t *set) { __sigdelset (set, SIGCANCEL); - __sigdelset (set, SIGTIMER); __sigdelset (set, SIGSETXID); } diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c index d14fc5c..004b0b6 100644 --- a/sysdeps/unix/sysv/linux/sigprocmask.c +++ b/sysdeps/unix/sysv/linux/sigprocmask.c @@ -18,7 +18,7 @@ #include #include -#include +#include int @@ -29,7 +29,7 @@ __sigprocmask (int how, const sigset_t *set, sigset_t *oset) if (set != NULL && __glibc_unlikely (__nptl_has_internal_signal (set))) { local_newmask = *set; - __nptl_clear_internal_signals (&local_newmask); + __clear_internal_signals (&local_newmask); set = &local_newmask; } diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index 42afbce..21e9fca 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -29,21 +29,8 @@ int __sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout) { - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); - __sigdelset (&tmpset, SIGSETXID); - set = &tmpset; - } - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ int result = SYSCALL_CANCEL (rt_sigtimedwait, set, info, timeout, _NSIG / 8); /* The kernel generates a SI_TKILL code in si_code in case tkill is diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c index 395bd9f..18a4485 100644 --- a/sysdeps/unix/sysv/linux/sigwait.c +++ b/sysdeps/unix/sysv/linux/sigwait.c @@ -33,19 +33,6 @@ do_sigwait (const sigset_t *set, int *sig) { int ret; - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); - __sigdelset (&tmpset, SIGSETXID); - set = &tmpset; - } - /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */ #ifdef INTERNAL_SYSCALL From patchwork Mon Nov 6 13:37:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118043 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2775545qgn; Mon, 6 Nov 2017 05:37:52 -0800 (PST) X-Google-Smtp-Source: ABhQp+QpTQIkNZbD1tv//id5hnNsvXrVkcOIpcxZ+0W9fOf4Udjy+Xno986YFemD838mb5BH8LFy X-Received: by 10.99.189.18 with SMTP id a18mr15295977pgf.168.1509975472076; Mon, 06 Nov 2017 05:37:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975472; cv=none; d=google.com; s=arc-20160816; b=PBMqlv8qb6qAMFLKm4o5wAFE89d08mAQFZdqHDoRvkcCLkxTn576ZzAwfcAqK0m0j3 F88E98PspeIfIQZg/ZB2GjLd45HG54XmtVyI0EYDOqT2tdCKuHSwdyZF5jbFz11M7dCp Vj7WRFYmvkLe3ABsXfRxpmKr76oV5anaOoH2+Z2Wze6AlQ13W37+LurlhMgFY6U3jq61 SfEStagkLEySmmk4yihUswKwnlWWM0yQ8kyN7c6WN4EbMpZV3eYsR2W4tHv/jdJ3/ern pT6fu4fVVHrJCneHsAbQA/UZX0bC9KSBiAYnKyHdklfu3nHRyKLAzItGtqQVO/gvMC7m fzyA== 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=vOE2kMdpnpEBKmGLTlceF7ohREHR0tG7juh2j0ecqWU=; b=yn+QuybxsHW1sIKQna/OXKZQrDsOGyp/g0MRACRB9JvwUy/UR5ojUza1Bg43/S+FuL tt7xPoO31XYi6lb4auMcwq/pMqOp5C+AbNEZSLZdGpKxIuTUuREY93kUu6pez8VE3Q2J cDM+65lGxzc41vKvaDpCXzjlInrX7uklxeIdWwtqcBcd6gxEQvw1b7hxqERViYKtUd5i KVxSDJ3BSBDP+bWlnXITrMRVmyL4hLM7IMGHCUvmgriYZQC2E8Oz5V23YwCeKX/J584c dDNH2cp+YeP3QIeS8muMOgNBULzTI339mMB8vVGQSq9PfplOIFp1VCJJ4TL8VFAbmLjH /Y2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=G1pClZVK; spf=pass (google.com: domain of libc-alpha-return-86794-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86794-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 v23si11156398plo.539.2017.11.06.05.37.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:37:52 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86794-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=G1pClZVK; spf=pass (google.com: domain of libc-alpha-return-86794-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86794-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=XBqZFLwf10TBxC0PHINKEFi+nBbQl0w jlvvAbJZiy89xVjgHPC4U9aF1wIGKBXYlq9BAq4Wy45Wy3OsZNLtmJEoctodbuAZ zop2YLUuWNrZyjprOuRnkwHsncaEIjwZDlC43dNtDp4fF2/DMQlisBuw0PMgw73i oDONvCQvBp1A= 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=UFNKIQLaCEXLyk9Ksks+KMOfq14=; b=G1pCl ZVKGwG+zK6Ff/ZXXyJZIpTliKdbbup5I49AHfn96m8jQUFN554aBiu0G7CcqR0Im CYZnvZjoPjWYIKvv1y+/QWrbr7/wcm/3HKSZEzyoCEqgxTVfZNCC+WFW6ZZuNhOi 8w6LoV1dZ4/Y5bGv5Pb0gcl1kX+a1RN25TtPX8= Received: (qmail 33799 invoked by alias); 6 Nov 2017 13:37:24 -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 33699 invoked by uid 89); 6 Nov 2017 13:37:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, 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=inclusion X-HELO: mail-qk0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vOE2kMdpnpEBKmGLTlceF7ohREHR0tG7juh2j0ecqWU=; b=pXbUyxYP8IOLfUqziuuUGliWN4KiLxP2NtkbCsW7Rf1hwMVjLZXNBOAhWmOkrdKDJO RjmQA8xz0aTYlEGQ8Ee7NSurIXSs6kcZj8QKvrlKiNd6G6c1SNuFMnCkCN4VS2gsaIVj d6t2V0Jr5o1eksdWbS7synIyM6EI+SEJQkrkwpzffKL0ooK0/08q/I4imKjiVfPcuMDO T3XyNFeox/tQnAayR7Je1fb+z/DvdDdX+1Hls07Jo4MhiteXuTas5dzPr8L6+OD4JxmR on2nT3LgdNkksulPhEiSQ0wDgXS4bh1Iz9NoYwqcXbPdixJmb3VdV6fdpQs5q8JiBB0m CNiQ== X-Gm-Message-State: AJaThX6ovK215zoChYnQrNLPKnoDz3mdwJtZ9AEo5qka02vJJiVtI+kh qvH/AeZdTu0meUcnNmz3zInAudBIk/g= X-Received: by 10.55.214.25 with SMTP id t25mr3185091qki.225.1509975439676; Mon, 06 Nov 2017 05:37:19 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 4/8] Simplify Linux sig{timed}wait{info} implementations Date: Mon, 6 Nov 2017 11:37:02 -0200 Message-Id: <1509975426-1772-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Add a note about __NR_rt_sigtimedwait Linux minimum version support. - Comment about LIBC_CANCEL_HANDLED annotations. - Add a note about __sigtimedwait inclusion on GLIBC_PRIVATE. --- This patch simplifies sig{timed}wait{info} by: - Assuming __NR_rt_sigtimedwait existence on all architectures due minimum kernel version requirement (it pre-dates Linux git inclusion for Linux 2.6.12). - Now that sigwait is based on a internal sigtimedwait call and it is present of both libc.so and libpthread.so we need to add an external private definition of __sigtimedwait for libpthread.so call. - Call __sigtimedwait on both sigwait and sigwaitinfo. Checked on x86_64-linux-gnu. * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add __sigtimedwait. * sysdeps/unix/sysv/linux/sigtimedwait.c: Simplify includes and assume __NR_rt_sigtimedwait. * sysdeps/unix/sysv/linux/sigwait.c (__sigwait): Call __sigtimedwait and add LIBC_CANCEL_HANDLED for cancellation marking. * sysdeps/unix/sysv/linux/sigwaitinfo.c (__sigwaitinfo): Likewise. Signed-off-by: Adhemerval Zanella Reviewed-by: Zack Weinberg --- ChangeLog | 8 ++++ sysdeps/unix/sysv/linux/Versions | 1 + sysdeps/unix/sysv/linux/sigtimedwait.c | 9 ----- sysdeps/unix/sysv/linux/sigwait.c | 68 ++++------------------------------ sysdeps/unix/sysv/linux/sigwaitinfo.c | 41 ++------------------ 5 files changed, 21 insertions(+), 106 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 6c9e06f..d3dbcde 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -172,6 +172,7 @@ libc { __open_nocancel; __read_nocancel; __close_nocancel; + __sigtimedwait; # functions used by nscd __netlink_assert_response; } diff --git a/sysdeps/unix/sysv/linux/sigtimedwait.c b/sysdeps/unix/sysv/linux/sigtimedwait.c index 21e9fca..f74a921 100644 --- a/sysdeps/unix/sysv/linux/sigtimedwait.c +++ b/sysdeps/unix/sysv/linux/sigtimedwait.c @@ -17,13 +17,7 @@ #include #include -#include - -#include #include -#include - -#ifdef __NR_rt_sigtimedwait int __sigtimedwait (const sigset_t *set, siginfo_t *info, @@ -44,6 +38,3 @@ __sigtimedwait (const sigset_t *set, siginfo_t *info, } libc_hidden_def (__sigtimedwait) weak_alias (__sigtimedwait, sigtimedwait) -#else -# include -#endif diff --git a/sysdeps/unix/sysv/linux/sigwait.c b/sysdeps/unix/sysv/linux/sigwait.c index 18a4485..e6fb32a 100644 --- a/sysdeps/unix/sysv/linux/sigwait.c +++ b/sysdeps/unix/sysv/linux/sigwait.c @@ -15,73 +15,21 @@ License along with the GNU C Library; if not, see . */ -#include #include -#define __need_NULL -#include -#include - -#include #include -#include - -#ifdef __NR_rt_sigtimedwait - -/* Return any pending signal or wait for one for the given time. */ -static int -do_sigwait (const sigset_t *set, int *sig) -{ - int ret; - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ -#ifdef INTERNAL_SYSCALL - INTERNAL_SYSCALL_DECL (err); - do - ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set, - NULL, NULL, _NSIG / 8); - while (INTERNAL_SYSCALL_ERROR_P (ret, err) - && INTERNAL_SYSCALL_ERRNO (ret, err) == EINTR); - if (! INTERNAL_SYSCALL_ERROR_P (ret, err)) - { - *sig = ret; - ret = 0; - } - else - ret = INTERNAL_SYSCALL_ERRNO (ret, err); -#else - do - ret = INLINE_SYSCALL (rt_sigtimedwait, 4, set, NULL, NULL, _NSIG / 8); - while (ret == -1 && errno == EINTR); - if (ret != -1) - { - *sig = ret; - ret = 0; - } - else - ret = errno; -#endif - - return ret; -} int __sigwait (const sigset_t *set, int *sig) { - if (SINGLE_THREAD_P) - return do_sigwait (set, sig); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_sigwait (set, sig); - - LIBC_CANCEL_RESET (oldtype); - - return result; + siginfo_t si; + if (__sigtimedwait (set, &si, 0) < 0) + return -1; + *sig = si.si_signo; + return 0; } libc_hidden_def (__sigwait) weak_alias (__sigwait, sigwait) -#else -# include -#endif strong_alias (__sigwait, __libc_sigwait) + +/* __sigtimedwait handles cancellation. */ +LIBC_CANCEL_HANDLED (); diff --git a/sysdeps/unix/sysv/linux/sigwaitinfo.c b/sysdeps/unix/sysv/linux/sigwaitinfo.c index 0062d3e..75ddd52 100644 --- a/sysdeps/unix/sysv/linux/sigwaitinfo.c +++ b/sysdeps/unix/sysv/linux/sigwaitinfo.c @@ -15,52 +15,19 @@ License along with the GNU C Library; if not, see . */ -#include #include -#define __need_NULL -#include -#include - -#include #include -#include - -#ifdef __NR_rt_sigtimedwait /* Return any pending signal or wait for one for the given time. */ int __sigwaitinfo (const sigset_t *set, siginfo_t *info) { - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) - || __builtin_expect (__sigismember (set, SIGSETXID), 0))) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); - __sigdelset (&tmpset, SIGSETXID); - set = &tmpset; - } - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ - int result = SYSCALL_CANCEL (rt_sigtimedwait, set, info, NULL, _NSIG / 8); - - /* The kernel generates a SI_TKILL code in si_code in case tkill is - used. tkill is transparently used in raise(). Since having - SI_TKILL as a code is useful in general we fold the results - here. */ - if (result != -1 && info != NULL && info->si_code == SI_TKILL) - info->si_code = SI_USER; - - return result; + return __sigtimedwait (set, info, 0); } libc_hidden_def (__sigwaitinfo) weak_alias (__sigwaitinfo, sigwaitinfo) -#else -# include -#endif strong_alias (__sigwaitinfo, __libc_sigwaitinfo) + +/* __sigtimedwait handles cancellation. */ +LIBC_CANCEL_HANDLED (); From patchwork Mon Nov 6 13:37:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118045 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2775805qgn; Mon, 6 Nov 2017 05:38:07 -0800 (PST) X-Google-Smtp-Source: ABhQp+RVh+CyLgYiKhA9N80JmuEPrbZwG0AqVCyVg7PZyHV99icer7YImlnp6h/MVK/6GXyRJDVh X-Received: by 10.98.147.23 with SMTP id b23mr16736504pfe.5.1509975487558; Mon, 06 Nov 2017 05:38:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975487; cv=none; d=google.com; s=arc-20160816; b=YaDf5vj75Bu0mxkF8cwztVvA8iO0QceUdQ70hkMW10Io31P7dQrSWi1hEXffcU2c+v rj+2KMiHGEzJvvGXBzcQaD2JJQbdW3V+pHb3LINcIajV7F/kdPdM3D9wkG414M7S9E/J pUGIpHaeK4Wfh6tr/SpQEc9bT3TjYeSeseBN4gGf4cv7pKkf9/ypwnNtzZ75gYxmODXY BF/wtzN66UJfYzUuzpyg11z3520xeKCecQLUlKp7K+oMr17srrajCDE3IGv2ccmLNBCB 7WJfYsja/9iOh4/K9Daq4z431UHcOChF4C5Iq1Qmb+QY4dk3SJ3nilTMg7yi65bkVggh Y9fA== 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=A/pioXaaW1TKWgAMFJOZwG20CPYR+poAnuBnisu24uQ=; b=WLhelx5bdPcKgBvP147u1N7mkPT84CnxQiKd8kjOQGfKC/mgtegzRPx2gHV6GQLFzJ hcdfbJdLJb7YKvilKTZ5HsKCR1vV65pEHZ6tWCIoVOys0FIqW/UtPyBTymOnB5qz9Xlu gpV5W3Sm/nLsHzGfoneCewVUgwYXQ+emXmkiKbT7C3A0lURZ6YswFKyG779N6R0ass8U ostjIjzpaTEGUt84Cu4AVVzwyXq+3OGa7BY0jH3HRDnI8O4FmqjJQxGOZ/EKvaJC6BwR a+Wed/4dSFNFvB55G7nmeEAcz9tM3dktiYxtgjo6MAA6SwEFQg/gV7Xg7GNZmGCCcWvG VTRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Tojt2GS5; spf=pass (google.com: domain of libc-alpha-return-86795-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86795-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 d63si11116876pgc.561.2017.11.06.05.38.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:38:07 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86795-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Tojt2GS5; spf=pass (google.com: domain of libc-alpha-return-86795-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86795-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=Br6XhKLrW+RRozk6d2FOvT2SpsMkR7j wXuq2qqUlDrcwvOrkCwjocc66TWuFCZJLpwMoSAvaHOwHQjaFdn60HSnBXX7cGdS VhvIaNSXYlUw0/QloagNpoJuKsp/ksQkdepehaw5iGG6Y1QjzDbuZRjUNH46ZG7S y5SBAJ6H5KBE= 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=5iuv9Hwit8qJMYTTW1uPF1waF/Q=; b=Tojt2 GS5Hfa2l49uq4VQYtlJmaqemlnM4uHKGERGh7Bwi5ZFFryKLqiMc8IyuRIKzzI92 d3VyptrXbB8986QO4Rr0wkXNpb8yqBeXxwj8DmHwpbQBuhXRc/f9X/VGbNIJh+cA EMMm7O/KVtQdBdDNFQi1vtV3QG9hCKSYfeYkVw= Received: (qmail 33973 invoked by alias); 6 Nov 2017 13:37: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 33760 invoked by uid 89); 6 Nov 2017 13:37:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, 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=inclusion X-HELO: mail-qk0-f194.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=A/pioXaaW1TKWgAMFJOZwG20CPYR+poAnuBnisu24uQ=; b=ojidv+BkSp3xQNhrMVKnO2f1s9Rauv40hbjGfuAIbTLizyuYmJ/uQjIK+Z5R4zCMqG 54S3nSpTAEXTfkkQjIjumEiTzhW+MLxBysvfMoHt6nja54ZYJMUsV+gpf6M7biusJRVU W53qll/MCQWcoXTg3EkAFVlJAMmlrs9PHS0jaRjmCmSStV1LmJFOJYU0MdvEng7E+7UW 7eOR7kvsU4TQfTIdAh6Be2oV97JdBtFX96qwPZeO0BpJIjmQ3qySEQqnj3t9nd51gMF2 eA+yt4o5/NzM8Fl6dB4ZNZ3uNu3hE4stVCGrg7Ullduwx8rPktVa12QDpTx0jMW9m3XW RXkQ== X-Gm-Message-State: AMCzsaU2tRbpyY8LfP/5H7n6mvlPj7iMteZi02lbYkFM4ui+bDwRUP6l cLcOdc8GqwZt3tfYIXdtG1KMO6dH6MY= X-Received: by 10.55.88.132 with SMTP id m126mr20774687qkb.10.1509975441074; Mon, 06 Nov 2017 05:37:21 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 5/8] Cleanup Linux sigqueue implementation Date: Mon, 6 Nov 2017 11:37:03 -0200 Message-Id: <1509975426-1772-5-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> Changes from previous version: - Add a note about __NR_rt_sigqueueinfo Linux minimum version support. --- This patch simplify Linux sigqueue implementation by assuming __NR_rt_sigqueueinfo existence due minimum kernel requirement (tt pre-dates Linux git inclusion for Linux 2.6.12). Checked on x86_64-linux-gnu. * sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Asssume __NR_rt_sigqueueinfo. Signed-off-by: Adhemerval Zanella Reviewed-by: Zack Weinberg --- ChangeLog | 3 +++ sysdeps/unix/sysv/linux/sigqueue.c | 10 ++-------- 2 files changed, 5 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/sigqueue.c b/sysdeps/unix/sysv/linux/sigqueue.c index 059e524..67bb6b2 100644 --- a/sysdeps/unix/sysv/linux/sigqueue.c +++ b/sysdeps/unix/sysv/linux/sigqueue.c @@ -17,13 +17,10 @@ #include #include -#include #include - +#include #include -#include -#ifdef __NR_rt_sigqueueinfo /* Return any pending signal or wait for one for the given time. */ int __sigqueue (pid_t pid, int sig, const union sigval val) @@ -40,9 +37,6 @@ __sigqueue (pid_t pid, int sig, const union sigval val) info.si_uid = __getuid (); info.si_value = val; - return INLINE_SYSCALL (rt_sigqueueinfo, 3, pid, sig, &info); + return INLINE_SYSCALL_CALL (rt_sigqueueinfo, pid, sig, &info); } weak_alias (__sigqueue, sigqueue) -#else -# include -#endif From patchwork Mon Nov 6 13:37:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118046 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2775984qgn; Mon, 6 Nov 2017 05:38:20 -0800 (PST) X-Google-Smtp-Source: ABhQp+SCJWMoPjYs6XKiRj2bKd3q5oFwiv8uY69yGIiO1o3lXEZVtLaqkZxIB2EQTgQ3eiOlzE3t X-Received: by 10.99.96.136 with SMTP id u130mr14975416pgb.255.1509975500269; Mon, 06 Nov 2017 05:38:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975500; cv=none; d=google.com; s=arc-20160816; b=RU1muDcHqqXSdOq3VyVeeKTwdnIQEhL35foiN2df2r29ebbXPaJdYQrI0a89pHraBo bUl7nDDhbk/eGnVh8vsxLXkFvQ/fOJ3nbQGodA3WvITM/Hyw7SdRkibPbqH4SdWbdRJh rYxJaq4S75S3IwbcPrw9lQyBF7qlUp1GLUR/34exlaa9sjVDX9mi4hQHSd17v8wbIcOo VkPGd9eUzQWn1W3Npx5uOL8dPFHYYj2LdWX4N+iZ+h4kAOAmuyRndBgSUQ7fKKGEGzXl 6+u6sdno3cGg+pxGkTyoxylGdTiRWvo34JI7XAYzF5FC4zgUsJLnVZ6E4J0VKAQ2ZzG+ 134Q== 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=EIif7et0sOksqUQMhf7dsygIDxzeRnRKq1PM8bAYsK8=; b=014arcyDlrTIoqYEKAmj+PO5O6c1Eka1EBU7g7UirbOy5tz9asB8zZU4CzjeKkSCkl 7yyuGhceC6etxo4qjoGsnWK6Ul4hhbNfiE8ilEX+70K2tf8agc49pcTnHSVyFS6S4xmO gFPbjDc38hyn9pyJr6PtXysUw4peHuhjvCICPN5kYmHmRV+aFPQ7LOFKapVRc3QIGNuC Y2ow6Nar7vJqIQF961wJfJ4lRvfG/BIc5NFMz+q1VvqmhzLlX+vO/wV1dUS47+NfVenS F84JW+8XUzv7kpeLEY9Jjxm6W7GIa/G1k//QY94e3OX+KyNj/4bAocyOSlVWWJOg8I5S dy2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NP0c9Qz3; spf=pass (google.com: domain of libc-alpha-return-86796-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86796-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 g1si10446829plm.520.2017.11.06.05.38.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:38:20 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86796-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=NP0c9Qz3; spf=pass (google.com: domain of libc-alpha-return-86796-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86796-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=WSHfyY6DckmL+rTqTebHSn55jo58hEO rqohPtcUKCuiQggj4lpnG5x8YHNqPJljLHWvM04lmQCPE+50lF1hYBFZ3AAtiAhu ktC/F0R9n26LOGMyYGC4Dp4bKygrXRa2Kc6lYndhaHSp+uO2TkxN7uB5uL1miqVD OVWfZE4Jefg0= 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=0W9ARnWjESLBrRDhmZl5aDVMpyQ=; b=NP0c9 Qz3BWNbrJ3oLnk5oOOR4tvDwlnaaYUQwWq0I8wde0b/rEWBSSmPqboYh9+1RdHvh Lu85s3EeYneu7HCS8GapM2JEM3GfukK6mReklBDh3f4Qjouvc6oPaMiBP6oCE1lU lSwQzkmo4dAIIL0ziE3gLh/Rtn408+yuBIRVl0= Received: (qmail 34169 invoked by alias); 6 Nov 2017 13:37:26 -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 34035 invoked by uid 89); 6 Nov 2017 13:37:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.6 required=5.0 tests=AWL, 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=Hx-languages-length:1012 X-HELO: mail-qk0-f194.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=EIif7et0sOksqUQMhf7dsygIDxzeRnRKq1PM8bAYsK8=; b=SE6TGFnGj6JV2+6jpQhhvS6P+IOfLplEri6aeoeUHzCuAnAInBvcYbhMXYewxrv5sM aOQesoZ7+WyeBAkjpW9q+VcHvGHbSZC0RBkz71AYXDJ3JLx76j5thxCblt4alwnWoJze 8TPVcICHsl39FVPSr6AicN8icoy4c94MzUMh09wNf7+i9Dn+DGQGIUkY8d7SydWtvcNM J5w3uIcfVbRR6jqA3Yb77/jv0hrJXIc9rXZM8Mx2fsjFruPJCm/EawtXvK675fGr8l3e aBwfSg4+j0kTPfepUJlMF91yY6ZOnZQ2i1N2AC9Iqknyqiyduy0OgmM5xjEE8DkiRgxM R2bg== X-Gm-Message-State: AJaThX4ir29XCsa8ebMSp92Nc+Z4Jkip/eVxDEPeKSfcn1E5Guu+Ho+v NjDfwxBT3mTZr46L0yByj1SRyxAhE9U= X-Received: by 10.55.19.19 with SMTP id d19mr5501283qkh.189.1509975442494; Mon, 06 Nov 2017 05:37:22 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 6/8] Optimize sighold implementation Date: Mon, 6 Nov 2017 11:37:04 -0200 Message-Id: <1509975426-1772-6-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplifies sighold a bit by removing an extra sigprocmask and using SIG_BLOCK (which union of the current set and the set argument). Checked on x86_64-linux-gnu. * signal/sighold.c (sighold): Optimize implementation. Signed-off-by: Adhemerval Zanella Reviewed-by: Zack Weinberg --- ChangeLog | 2 ++ signal/sighold.c | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/signal/sighold.c b/signal/sighold.c index 2e32e47..955ac5b 100644 --- a/signal/sighold.c +++ b/signal/sighold.c @@ -26,14 +26,8 @@ sighold (int sig) { sigset_t set; - /* Retrieve current signal set. */ - if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) - return -1; - - /* Add the specified signal. */ + sigemptyset (&set); if (sigaddset (&set, sig) < 0) return -1; - - /* Set the new mask. */ - return __sigprocmask (SIG_SETMASK, &set, NULL); + return __sigprocmask (SIG_BLOCK, &set, NULL); } From patchwork Mon Nov 6 13:37:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118049 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2776263qgn; Mon, 6 Nov 2017 05:38:41 -0800 (PST) X-Google-Smtp-Source: ABhQp+REHEH2lob4prRp3DyGyf/V9duyajZJH9glVjcfCVp6MJ0ig3Lz1uworToqRlgcQb6lP5I6 X-Received: by 10.98.56.204 with SMTP id f195mr17022843pfa.188.1509975521441; Mon, 06 Nov 2017 05:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975521; cv=none; d=google.com; s=arc-20160816; b=nDa4tFihXRysH5bajVVmlvHsOVwaIYVIyPHAggtBKu5cyFIftK3vASG/FurygDGykt xVAJZO7rSck+ZMbkDlkI6AnKGXBE5XeCiVVSqop+99oJX/YK78droqF/E8un0wL13l26 hOP6t4NxoCqZ74VkqaYn1Mrw8M6hzxGRs4prglJZrujg3yXK+PSc+rYwAFpIZZjmZoBw WAwnLf/N3oT6ckJc6AszukN16evm3bToTO/2VuAuM2UgJoT8f7sri5GvymbuZy1tflFx Y0V8U36/klw3WRHSFLnJAFmkI5BpV794BbN2L0BjQSbc40ovVQn8u4PMKrfkGQ51pIBa ekFA== 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=b7wXfSr7SeNsv9K+Zmic9yzAhi92y+B+49e0AmSLZuc=; b=gnq2/KlrwbIaJhOUL3hnBtRdwB6wzP5ndVSWU3gGlU3QYGEeRLyPLiuftXtYAxKQe1 1niNBsE4iNZFhwCanVx+OPMap834Jdub/qBRjaHNYtgznvSOH+ggk2NprSjVGCqmn5K+ JSTtehoxWvanCyWgEtyfGrvN+R/qmStl1ilunfmbOUJ+i5wKAchE0083LSow89wcBqFu uvTJrbzJuyznLKGZnKSJdwkymSQq6gDxRCFaOo7fB8PkosNMUEt/SGfRTW5TaPff5T7e QoYEVsiANpp8kpRL2aQQiRHxy7/+HoVKEoo65AGRIo4wtMB+5HQD+/ZO22L6jELd5Htj 8shw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PzTSB52P; spf=pass (google.com: domain of libc-alpha-return-86798-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86798-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 w6si11116641pgb.291.2017.11.06.05.38.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86798-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PzTSB52P; spf=pass (google.com: domain of libc-alpha-return-86798-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86798-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=MonwHCa0hxJ2k8MCP++kmttKOs+5+pq DZRrYUl/XMJf4cIPoqgaCz9CKYR19jZ6A+qn/kXFaJxRmgHfBn1fqM2ouF4I88RO m3V4T4CI7qIdWksy8BdKO0CQDZa6seVoJJ0HbUhkOb47hsdS2yDcjpcKQsQpA5Pu lXDjbWWBRKOw= 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=xsuoJKdQzFbZwZ3RgeXmVKfA1ME=; b=PzTSB 52PFKTjFlGxRobSKpYV/+sOU3/TI1UA1+wTXwMvwzYthDUwRWTzGIPnB6u5uWTL8 TVUMTz/oJEi3y4XbgVf45encARS6B07ZiBCCo5WJ/upKTB4s269QYCOYY5xYgYc2 m+6ow0BjbEO9AI8NFCJeika5/XcmlMEHrRCel8= Received: (qmail 34467 invoked by alias); 6 Nov 2017 13:37:28 -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 34351 invoked by uid 89); 6 Nov 2017 13:37:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, 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=arrive X-HELO: mail-qk0-f196.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=b7wXfSr7SeNsv9K+Zmic9yzAhi92y+B+49e0AmSLZuc=; b=unc8ftWEPx3CjVnVpoyo5L/2GRpU5nqqMOtvV/1ILSjobVDrE0A9mVqUjFrLL382rp GQHgJrYQCiDLDmHeVoz7CQQbWyfL9/5aOejv9gbYTaEVVm5XwhsUr9oiVDd39PimXgZE okRIhdoYls8QQMtBZvG2OOV8HflZV0v7tLA0DUqrElwd0P37EaPp1nRR4Q7B+IFT9f1T MdabqFNzytPxU1/71B5OZQk+DHlIsiQSJrtKfok+7ChPFVNBxgf1yccES4h6W51Ubqca /pRNxa6Pz7XxN2XcpdRIvF99rcGirMpd3em5L8PqWOjedv9eMDRUuIbS5k+JveJPAkZn zP+g== X-Gm-Message-State: AJaThX5IZlCm+LJ2gKkRdQJRGWRnwIoC6CyxhS7HwneHdGpJhs5SA5e+ QOGRXHXsgJIwnQcbnHugKM5RXtpgf4I= X-Received: by 10.55.5.139 with SMTP id 133mr915685qkf.220.1509975443929; Mon, 06 Nov 2017 05:37:23 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 7/8] Cleanup sigpause implementation Date: Mon, 6 Nov 2017 11:37:05 -0200 Message-Id: <1509975426-1772-7-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplify sigpause by remobing the single thread optimization since it will be handled already by the __sigsuspend call. Checked on x86_64-linux-gnu. * sysdeps/posix/sigpause.c (do_sigpause): Remove. (__sigpause): Rely on __sigsuspend to implement single thread optimization. Add LIBC_CANCEL_HANDLED for cancellation marking. Signed-off-by: Adhemerval Zanella Reviewed-by: Zack Weinberg --- ChangeLog | 4 ++++ sysdeps/posix/sigpause.c | 26 ++++++-------------------- 2 files changed, 10 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c index 9038ed3..a61e056 100644 --- a/sysdeps/posix/sigpause.c +++ b/sysdeps/posix/sigpause.c @@ -19,15 +19,13 @@ #include #include #include /* For NULL. */ -#include #undef sigpause #include +#include -/* Set the mask of blocked signals to MASK, - wait for a signal to arrive, and then restore the mask. */ -static int -do_sigpause (int sig_or_mask, int is_sig) +int +__sigpause (int sig_or_mask, int is_sig) { sigset_t set; @@ -46,21 +44,6 @@ do_sigpause (int sig_or_mask, int is_sig) to do anything here. */ return __sigsuspend (&set); } - -int -__sigpause (int sig_or_mask, int is_sig) -{ - if (SINGLE_THREAD_P) - return do_sigpause (sig_or_mask, is_sig); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_sigpause (sig_or_mask, is_sig); - - LIBC_CANCEL_RESET (oldtype); - - return result; -} libc_hidden_def (__sigpause) /* We have to provide a default version of this function since the @@ -87,3 +70,6 @@ __xpg_sigpause (int sig) return __sigpause (sig, 1); } strong_alias (__xpg_sigpause, __libc___xpg_sigpause) + +/* __sigsuspend handles cancellation. */ +LIBC_CANCEL_HANDLED (); From patchwork Mon Nov 6 13:37:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 118050 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2776391qgn; Mon, 6 Nov 2017 05:38:51 -0800 (PST) X-Google-Smtp-Source: ABhQp+QdwHNzQ/2wboKdM9AAM+DqzAbRNMRpGb9Bx+GkkvLx9jtX3rZRbCJ3F3gwMHtrgio+7/mD X-Received: by 10.99.117.29 with SMTP id q29mr15541732pgc.61.1509975531734; Mon, 06 Nov 2017 05:38:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509975531; cv=none; d=google.com; s=arc-20160816; b=g8Vo9WUlvS49vmDl2gBTozsYUDPLF/W+L38T8zJWCNAWYAXuR5vWHnBcMrLsgG3B95 9CoC7ApElztfy6VoHx3E99RzhUCuJZ9CnOQAIUuuyZnXr6B9rW92RrXUr3Gdvi7ZIAXf D2zI8fbV2QAj6a0Uuu2/BnBXHVvcijjytwijwuxzDorIK12anIAmHVo8X2oB6e0W1aXL lwg/WyF+9+ane7QQtzEgSg4XdAkUjgCXOYqjwjzsFQtSVS2ATZg8XykhHCvGey0ticqe Cw2XHh7ACaDLe2uRwrHa4dtzRO6Xku4aSSpf8xhxo/Yey2VrkxuCc5QLCAg/ObM0B1xj 74yg== 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=33EK0PEZRpn5cnTeYV6UfjtzyU0oM/Hx806B8FL3c84=; b=BTdA94L4f5PWtGzRRqGrSOPa1w5KyGy/rKweNmk718WkMUptHyeIzc2cC1K9tA2IXU vmFj/1TWdYaF+BrHYZ2Qgu8D8kg0sG0MK9nLMQ7abZwj4912pPBXUjl0tJ/5QvyuNrFS dDmG1dCmbJMW+ma0OV70/a06tI6FLflni354kcpD0VR8kSaP0G39e6Mx3PwAWh3cT79+ QqNpKoWx4zn/v3h25TLO8PcLSJnlHzOe2XWgvxNPBZK7tMntk+rJCfvFikTHgRjYwx4L 0qH9+8z6il/p9EpIFStmh7FvXm5NPWeHiOGOkp0AvQq9YZKbSxCJ6PtePwrtMPd54hOl rK5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=r9J0eqcN; spf=pass (google.com: domain of libc-alpha-return-86799-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86799-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 r7si9782902plo.348.2017.11.06.05.38.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 05:38:51 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-86799-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=r9J0eqcN; spf=pass (google.com: domain of libc-alpha-return-86799-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-86799-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=noo5K+LarLhWSV63EobKlOn0JVE5CDJ 9+l9lEL1tGbvdX/ZCCqeRJVwke2f1CAfrqIlrg04xRSZL9hD+fH72+JobGXjvPZ8 cLqHgLU6zteLH1n5tFtcMf/VKRIexO/amSIzLYfyeLKrnWD5oPo8jd8frKM3dlaW vO6D2WDitX1A= 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=GD1g3H4JCFDV2f2cIMoq4g26Hgc=; b=r9J0e qcNpzyQrQ1Fvrdz9mjrcy0JpIfXlnaUCJ3ntaf/ooOwyvHNVsQQj0+BKSzkJB4Gx FsrI42CrsrJh/AQRuxMK6CdAAPhQP1Hl1UlE/Y4y6uvS18myBVy2apJBZkKVpRam Xhj/lredlHNpG7tU+sHAr6HapwrPt9MPKPOVC0= Received: (qmail 34627 invoked by alias); 6 Nov 2017 13:37:29 -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 34557 invoked by uid 89); 6 Nov 2017 13:37:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, 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= X-HELO: mail-qk0-f196.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=33EK0PEZRpn5cnTeYV6UfjtzyU0oM/Hx806B8FL3c84=; b=QljWSewNQb4vnwWBkqxKWequih9FzANg6LEmDPqIrC+SOwsBjF3pKukctNw3M/+75U 30a+fqQR5TAwlNA4RzbFPFvjgNidTwTyKUt+BJfS3mYzpwMH07buvmdcOQV9EEjTFxT7 YBEsZwwOfhuP6d3pmNWHhizthbZDwHeqT74x29CesUnih9l9MSrMJ6++4mrGGOHXbDy0 zQEHqj3XMRvMXcERnD2/hBelbsvpUeDKMibXMQNIYKQBvkpWNL0u5MbcpToLELyaPGm+ sM36m6YCc6abam71PPiBm5E51uvKMt0h2ZM2Mn3ZCizArV4gzHb9ecPJOdOArVI4bQDk /FMA== X-Gm-Message-State: AJaThX5lM/mVpswHByQUEJN1Tc8tEKtPjVaGN/BInXo9QoE82ODbR+i7 0AdoCkYPdGEgr33/rWPTabFdtPKwkGw= X-Received: by 10.55.21.135 with SMTP id 7mr9966090qkv.216.1509975445293; Mon, 06 Nov 2017 05:37:25 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 8/8] Optimize sigrelse implementation Date: Mon, 6 Nov 2017 11:37:06 -0200 Message-Id: <1509975426-1772-8-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> References: <1509975426-1772-1-git-send-email-adhemerval.zanella@linaro.org> This patch simplifies sighold a bit by removing an extra sigprocmask and using SIG_BLOCK (which union of the current set and the set argument). Checked on x86_64-linux-gnu. * signal/sighold.c (sighold): Optimize implementation. Signed-off-by: Adhemerval Zanella --- ChangeLog | 2 ++ signal/sigrelse.c | 12 +++--------- 2 files changed, 5 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/signal/sigrelse.c b/signal/sigrelse.c index e41c2bd..61f240b 100644 --- a/signal/sigrelse.c +++ b/signal/sigrelse.c @@ -26,14 +26,8 @@ sigrelse (int sig) { sigset_t set; - /* Retrieve current signal set. */ - if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0) + sigemptyset (&set); + if (sigaddset (&set, sig) < 0) return -1; - - /* Remove the specified signal. */ - if (sigdelset (&set, sig) < 0) - return -1; - - /* Set the new mask. */ - return __sigprocmask (SIG_SETMASK, &set, NULL); + return __sigprocmask (SIG_UNBLOCK, &set, NULL); }