From patchwork Fri May 12 17:58: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: 99712 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp430882qge; Fri, 12 May 2017 10:58:40 -0700 (PDT) X-Received: by 10.84.131.129 with SMTP id d1mr7521565pld.16.1494611920009; Fri, 12 May 2017 10:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494611920; cv=none; d=google.com; s=arc-20160816; b=0CBA9KyXq/dRF/0TE2KH2zBo2phlgJsQlC1fN1whD2va2VRjKFE87Q222oJJAJMKFC 7dmbRR+SUF/dvZaw7+YtMqnW8aJLO/+aDZWdD6OhhTh/iWhlcOmbwWt2yAnuSprPu6Ji l/roeuwGbkUGEplyneJZryCf0KbiS6jPZaRxVWnnD+ZnUBEc+NGpbHWTVtc1hMO79Cq9 /7IHa5nFC4FIBeOs337dRZf6ksnkz9+/s3J77mdV5yPo4RsDmCUKlLxsqEk+KrJVCV5Y O6B7+yoJJbNbXOGxX/lRCrRD8zynAFWGc6Mp7UPzXWWfhCF0+cPHfPINXB1upDv2ye5Q LzQQ== 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=aQfMVMX8oLNHSzWWgc3Pn/SpPA3cph7IVFFUq5TwGfM=; b=ome3uM0RXJcuovLhOZTzwFOj3MHENvdHlfxFnelTLCvD9CqBRyX+4L5K5vmZMIshze vUOR7or2miktc+Vbh9FywRMW26t5HEABzKwjKYgOUo2xsX7m5NTISCXP+0M6Q4H3cLYN otbBv7wllBaCdS41Vm6Sgpxx6T+2j03aLq1wwowUOIGo/Zn8cmA1HZyzVTYJz4TE8HYO q1nxRHn05B5mAnsLCD/b6fcvQ2GKF47NieVqqbJUpIdyvzno66R33crhjcKPsGR8r0qK CPM1/I+uEfJO50wx1cHceys0DnKhiM0+W2TLJu4mTkJbjr2CLe2pgMZagQvcfWiWM8su UOhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-79375-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-79375-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 y12si3934354pge.207.2017.05.12.10.58.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 10:58:39 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-79375-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; spf=pass (google.com: domain of libc-alpha-return-79375-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-79375-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=o8pOH7K4Kd39JYIyco0DgVbOSdMkkn0WimKmL+rkikYnafdzgHzz3 USlWvfVZtYPyiJ7p0O3digAUjhuwIuiTP03fslgMzxz/4+Fr6ZxP3ddVdm3he0ne QV4PGPp4a0gJrVuT3XOVgFqJcUpkqSmD0mMFGjI9M5d9tX8b+ZgzWU= 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=/s1GlJbO2KjL1HdJv1bmmsoy7V0=; b=xU3l71X+3z5TRGWmrZWcpjf+L2fv 9uBecmXDPIiWTLVXrGduETuTpY74YcOJ++Q8Ew/7TK8skMK9+6QlQuNQ6u9ZmXqE /myC0NTQfK8vyFD9S3cN27eKUyMkYdPVC/Zix0NvDLZad+IXvXcEH81mYrmC5k0C XzsDoBn/DDJLxek= Received: (qmail 38500 invoked by alias); 12 May 2017 17:58: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 32275 invoked by uid 89); 12 May 2017 17:58:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 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=interrupted, EXTRA, Hx-languages-length:4216 X-HELO: mail-qk0-f169.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=aQfMVMX8oLNHSzWWgc3Pn/SpPA3cph7IVFFUq5TwGfM=; b=rd1fV7GZutXLNnRzYwWuH6hZj4LDcZfjH1Y/VHk5c4a80js6anhxrl5U+qTDT878J4 l0Yu3dqZHecIRiTmkI1+nwkstcZ9fWwlRQhwJca8UNBykAHRIggW4FKO8LuY/BD1KJPk +POSqQ9BRZhiKlIWm9uM0546r4VfcPNQD9CPyo3mvsCdklg1pIKOP6x0dtMfaTexCcIY 1ViSJZ8S3Y9OEsfQ9vogtqmR2pVH+IXOPPTZ4L+24v7XzoeUyXwbRqQgVQWKmqrlyl7q /B36rgcR/KNDQ33h8G+pvesPz1uVfZPnInjXIxhZcb8PSwrCvF8svsmDQavsNevoGJHE Fyng== X-Gm-Message-State: AODbwcDt/97pJXBu/4dvP4kmyz1mZv3QMhM9KoaXSZOAjnvzQZXQ0QZj qOhZsneO4tT0apGBRhBcwQ== X-Received: by 10.55.114.2 with SMTP id n2mr5466616qkc.157.1494611901077; Fri, 12 May 2017 10:58:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 01/13] posix: Consolidate Linux pause syscall Date: Fri, 12 May 2017 14:58:02 -0300 Message-Id: <1494611894-9282-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the pause Linux implementation on sysdeps/unix/sysv/linux/pause.c. If defined the pause syscall (__NR_pause) will be used, other ppoll with 0 arguments will be used instead. It has the small advantage of generic pause implementation with uses rt_sigprocmask plus rt_sigsuspend because it requires only one syscall and the pause is done atomically regarding signal handling (for instance, pause may not be interrupted if the signal arrives between the rt_sigprocmask and rt_sigsuspend syscall). Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32, arch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. * sysdeps/unix/sysv/linux/generic/pause.c: Remove file. * sysdeps/unix/sysv/linux/sparc/sparc64/pause.c: Likewise. * sysdeps/unix/sysv/linux/sparc/kernel-features.h [__arch64__] (__NR_pause): Undefine. * sysdeps/unix/sysv/linux/pause.c: New file. * sysdeps/unix/sysv/linux/syscalls.list: Remove pause from auto-generation list. --- ChangeLog | 10 ++++++++++ sysdeps/unix/sysv/linux/{generic => }/pause.c | 18 +++++++----------- sysdeps/unix/sysv/linux/sparc/kernel-features.h | 6 ++++++ sysdeps/unix/sysv/linux/sparc/sparc64/pause.c | 9 --------- sysdeps/unix/sysv/linux/syscalls.list | 1 - 5 files changed, 23 insertions(+), 21 deletions(-) rename sysdeps/unix/sysv/linux/{generic => }/pause.c (75%) delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/pause.c -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/generic/pause.c b/sysdeps/unix/sysv/linux/pause.c similarity index 75% rename from sysdeps/unix/sysv/linux/generic/pause.c rename to sysdeps/unix/sysv/linux/pause.c index a8b3e33..c6b252a 100644 --- a/sysdeps/unix/sysv/linux/generic/pause.c +++ b/sysdeps/unix/sysv/linux/pause.c @@ -1,6 +1,6 @@ -/* Copyright (C) 2011-2017 Free Software Foundation, Inc. +/* Linux pause syscall implementation. + Copyright (C) 2017 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -26,14 +26,10 @@ int __libc_pause (void) { - sigset_t set; - - int rc = - SYSCALL_CANCEL (rt_sigprocmask, SIG_BLOCK, NULL, &set, _NSIG / 8); - if (rc == 0) - rc = SYSCALL_CANCEL (rt_sigsuspend, &set, _NSIG / 8); - - return rc; +#ifdef __NR_pause + return SYSCALL_CANCEL (pause); +#else + return SYSCALL_CANCEL (ppoll, 0, 0, 0, 0, 0); +#endif } - weak_alias (__libc_pause, pause) diff --git a/sysdeps/unix/sysv/linux/sparc/kernel-features.h b/sysdeps/unix/sysv/linux/sparc/kernel-features.h index 72065a0..dd9108b 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel-features.h +++ b/sysdeps/unix/sysv/linux/sparc/kernel-features.h @@ -32,6 +32,12 @@ # undef __ASSUME_ACCEPT_SYSCALL # undef __ASSUME_CONNECT_SYSCALL # undef __ASSUME_RECVFROM_SYSCALL +#else +/* sparc64 defines __NR_pause, however it is not supported (ENOSYS). + Undefine so pause.c can use a correct alternative. */ +# ifdef __NR_pause +# undef __NR_pause +# endif #endif /* sparc only supports ipc syscall. */ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pause.c b/sysdeps/unix/sysv/linux/sparc/sparc64/pause.c deleted file mode 100644 index e399e7c..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/pause.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include -#include -#include - -#define __sigprocmask(how, set, oset) \ - INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8) - -#include diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index f4abf3e..eab30dd 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -44,7 +44,6 @@ munlock - munlock i:ai munlock munlockall - munlockall i: munlockall nanosleep - nanosleep Ci:pp __nanosleep nanosleep nfsservctl EXTRA nfsservctl i:ipp nfsservctl -pause - pause Ci: __libc_pause pause pipe - pipe i:f __pipe pipe pipe2 - pipe2 i:fi __pipe2 pipe2 pivot_root EXTRA pivot_root i:ss pivot_root