From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83487 invoked by alias); 22 Aug 2017 13:07:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 83468 invoked by uid 89); 22 Aug 2017 13:07:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=arrives, suspend, Delay X-HELO: mail-qt0-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:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OJkQUWYCg3950KudhvIkwxyhuPWc5reLd9n8akZerjs=; b=Tepiid1JQ+lTcnAWQHEmPgiIZQ7dopjgjnbNbWkALOFsqLjol/VMddCw5k+mO8Jl+t M/8Ip0Eo05ktuGlcMGrD2ByYgcGZ8NuDzILJbtV9gMhM2/fHErkqFGRe1WILsrIQYzQO LX5eedJey7SLCSqsIc4BeyGCgfZkOSC4wj7pMQ8MbwAofWApk7tXhOgAjk1v9bcyEoYZ Qxigdy4ilzKzGbhW7KydclJD7FD7GlAmoFM4zNnVFpgNzy/3WoV0rGOjkAYX5KST8+nD +nAcOMp8tYaY08WfMIzNKJvUUwM4xyr5albH069QqK3gAOyLllIzBL0lroiI0pHPw0fZ PN6Q== X-Gm-Message-State: AHYfb5i8xGuXzGz/Oqv2ENerz80H9FPFSXoem/ZSKzffjZuuadH1T4r7 xy8HfLemib0E9LF+GMBU5Q== X-Received: by 10.237.34.47 with SMTP id n44mr765858qtc.263.1503407236785; Tue, 22 Aug 2017 06:07:16 -0700 (PDT) Subject: Re: [PATCH 09/14] Consolidate non cancellable pause call From: Adhemerval Zanella To: libc-alpha@sourceware.org References: <1501765874-6201-1-git-send-email-adhemerval.zanella@linaro.org> <1501765874-6201-10-git-send-email-adhemerval.zanella@linaro.org> Message-ID: Date: Tue, 22 Aug 2017 13:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1501765874-6201-10-git-send-email-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-08/txt/msg01053.txt.bz2 Since this is a refactor, if no one opposes I will commit it shortly. On 03/08/2017 10:11, Adhemerval Zanella wrote: > This patch consolidates all the non cancellable pause calls to use > the __pause_nocancel identifier. For non cancellable targets it will > be just a macro to call the default respective symbol while on Linux > will be a internal one. > > Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu. > > * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace > pause_not_cancel with __pause_nocancel. > * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro. > (__pause_nocancel): New macro. > * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove > macro. > (__pause_nocancel): New prototype. > * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function. > --- > ChangeLog | 9 +++++++++ > include/unistd.h | 2 -- > nptl/pthread_mutex_lock.c | 2 +- > sysdeps/generic/not-cancel.h | 2 +- > sysdeps/posix/pause.c | 15 --------------- > sysdeps/unix/sysv/linux/not-cancel.h | 10 ++-------- > sysdeps/unix/sysv/linux/pause.c | 14 +++++++++++++- > 7 files changed, 26 insertions(+), 28 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index e1df1c1..877c5d9 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,5 +1,14 @@ > 2017-08-02 Adhemerval Zanella > > + * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace > + pause_not_cancel with __pause_nocancel. > + * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro. > + (__pause_nocancel): New macro. > + * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove > + macro. > + (__pause_nocancel): New prototype. > + * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function. > + > * login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with > __fcntl_nocancel. > * sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro. > diff --git a/include/unistd.h b/include/unistd.h > index 7f1c2cc..a5625ed 100644 > --- a/include/unistd.h > +++ b/include/unistd.h > @@ -172,8 +172,6 @@ extern __pid_t __libc_fork (void); > /* Suspend the process until a signal arrives. > This always returns -1 and sets `errno' to EINTR. */ > extern int __libc_pause (void); > -/* Not cancelable variant. */ > -extern int __pause_nocancel (void) attribute_hidden; > > extern int __getlogin_r_loginuid (char *name, size_t namesize) > attribute_hidden; > diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c > index 8c48503..b158607 100644 > --- a/nptl/pthread_mutex_lock.c > +++ b/nptl/pthread_mutex_lock.c > @@ -428,7 +428,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex) > > /* Delay the thread indefinitely. */ > while (1) > - pause_not_cancel (); > + __pause_nocancel (); > } > > oldval = mutex->__data.__lock; > diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h > index 3f924c8..f2140c2 100644 > --- a/sysdeps/generic/not-cancel.h > +++ b/sysdeps/generic/not-cancel.h > @@ -38,7 +38,7 @@ > (void) __writev (fd, iov, n) > # define __waitpid_nocancel(pid, stat_loc, options) \ > __waitpid (pid, stat_loc, options) > -#define pause_not_cancel() \ > +#define __pause_nocancel() \ > __pause () > #define nanosleep_not_cancel(requested_time, remaining) \ > __nanosleep (requested_time, remaining) > diff --git a/sysdeps/posix/pause.c b/sysdeps/posix/pause.c > index 7996cd6..53e143d 100644 > --- a/sysdeps/posix/pause.c > +++ b/sysdeps/posix/pause.c > @@ -39,18 +39,3 @@ __libc_pause (void) > weak_alias (__libc_pause, pause) > > LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */ > - > -#ifndef NO_CANCELLATION > -# include > - > -int > -__pause_nocancel (void) > -{ > - sigset_t set; > - > - __sigemptyset (&set); > - __sigprocmask (SIG_BLOCK, NULL, &set); > - > - return sigsuspend_not_cancel (&set); > -} > -#endif > diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h > index ad46d62..89c1f46 100644 > --- a/sysdeps/unix/sysv/linux/not-cancel.h > +++ b/sysdeps/unix/sysv/linux/not-cancel.h > @@ -78,14 +78,8 @@ __typeof (waitpid) __waitpid_nocancel; > libc_hidden_proto (__waitpid_nocancel) > > /* Uncancelable pause. */ > -#define pause_not_cancel() \ > - ({ sigset_t set; \ > - int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set, \ > - _NSIG / 8); \ > - if (__rc == 0) \ > - __rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8); \ > - __rc; \ > - }) > +__typeof (pause) __pause_nocancel; > +libc_hidden_proto (__pause_nocancel) > > /* Uncancelable nanosleep. */ > #define nanosleep_not_cancel(requested_time, remaining) \ > diff --git a/sysdeps/unix/sysv/linux/pause.c b/sysdeps/unix/sysv/linux/pause.c > index 4ccce9e..ad105d9 100644 > --- a/sysdeps/unix/sysv/linux/pause.c > +++ b/sysdeps/unix/sysv/linux/pause.c > @@ -18,11 +18,12 @@ > > #include > #include > + > #include > +#include > > /* Suspend the process until a signal arrives. > This always returns -1 and sets errno to EINTR. */ > - > int > __libc_pause (void) > { > @@ -33,3 +34,14 @@ __libc_pause (void) > #endif > } > weak_alias (__libc_pause, pause) > + > +int > +__pause_nocancel (void) > +{ > +#ifdef __NR_pause > + return INLINE_SYSCALL_CALL (pause); > +#else > + return INLINE_SYSCALL_CALL (ppoll, NULL, 0, NULL, NULL); > +#endif > +} > +libc_hidden_def (__pause_nocancel) >