From patchwork Tue Jul 4 19:53:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 21417 Received: (qmail 74764 invoked by alias); 4 Jul 2017 19:54: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 74288 invoked by uid 89); 4 Jul 2017 19:54: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= 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:in-reply-to :references; bh=pJZC9Kc/3cOtXC3tgxv5TKdLW28mHJrKi5uU5XSkm0I=; b=j8hy+ix2LCxr7qTCuy9YppwRIVbQuS1Yuz97YzZWbMYikQSQaSiidZeoe1riQj1S92 7yTx6diAfGfHnvBlLc/vezM46P5TJj45lr8tFP84MXToz2vXdR2jCZC/DTWpfYoLzHZO IepjvNpnUQcTCWEnQSijv0xCXyqdRPqgoo5qWNZtWlW1XIpclixyjWSlM1D7G4Zk2Odt /nOKisaiZQ0IsW27zc6yyqznWEDylvNpuAx61kzvYONIVf2u1iEFNNFIh6c4Oqu3qTMx ZyA5s1K+Svd8q+fBKQKGxAPJ24glvAcmeEnm6nSIg0ib40o/whON1PTZNCDIBy5VAd3F EuBA== X-Gm-Message-State: AKS2vOx2UARezvMClVEdXIX1JtDL4GbwHtSS5tpuJeGBnADy4QUFaVT2 fXN5quvByrkBmobLz0+QQw== X-Received: by 10.55.27.136 with SMTP id m8mr46721573qkh.196.1499198056341; Tue, 04 Jul 2017 12:54:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 10/14] Consolidate non cancellable nanosleep call Date: Tue, 4 Jul 2017 16:53:50 -0300 Message-Id: <1499198034-5837-11-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> References: <1499198034-5837-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates all the non cancellable nanosleep calls to use the __nanosleep_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_timedlock.c (__pthread_mutex_timedlock): Replace nanosleep_not_cancel with __nanosleep_nocancel. * sysdeps/generic/not-cancel.h (nanosleep_not_cancel): Remove macro. (__nanosleep_nocancel): New macro. * sysdeps/unix/sysv/linux/nanosleep.c (__nanosleep_nocancel): New function. * sysdeps/unix/sysv/linux/not-cancel.h (nanosleep_not_cancel): Remove macro. (__nanosleep_nocancel): New prototype. --- ChangeLog | 10 ++++++++++ nptl/pthread_mutex_timedlock.c | 2 +- sysdeps/generic/not-cancel.h | 2 +- sysdeps/unix/sysv/linux/nanosleep.c | 9 +++++++++ sysdeps/unix/sysv/linux/not-cancel.h | 5 +++-- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index be53381..c522abe 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -429,7 +429,7 @@ __pthread_mutex_timedlock (pthread_mutex_t *mutex, --reltime.tv_sec; } if (reltime.tv_sec >= 0) - while (nanosleep_not_cancel (&reltime, &reltime) != 0) + while (__nanosleep_nocancel (&reltime, &reltime) != 0) continue; return ETIMEDOUT; diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index e80b89a..8eb2995 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -40,7 +40,7 @@ __waitpid (pid, stat_loc, options) #define __pause_nocancel() \ __pause () -#define nanosleep_not_cancel(requested_time, remaining) \ +#define __nanosleep_nocancel(requested_time, remaining) \ __nanosleep (requested_time, remaining) #define sigsuspend_not_cancel(set) \ __sigsuspend (set) diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c index 2d15328..e7ac2c0 100644 --- a/sysdeps/unix/sysv/linux/nanosleep.c +++ b/sysdeps/unix/sysv/linux/nanosleep.c @@ -18,6 +18,7 @@ #include #include +#include /* Pause execution for a number of nanoseconds. */ int @@ -28,3 +29,11 @@ __nanosleep (const struct timespec *requested_time, } hidden_def (__nanosleep) weak_alias (__nanosleep, nanosleep) + +int +__nanosleep_nocancel (const struct timespec *requested_time, + struct timespec *remaining) +{ + return INLINE_SYSCALL_CALL (nanosleep, requested_time, remaining); +} +hidden_def (__nanosleep_nocancel) diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 00070fd..9aaa781 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -26,6 +26,7 @@ #include #include #include +#include /* Non cancellable open syscall. */ __typeof (open) __open_nocancel; @@ -82,8 +83,8 @@ __typeof (pause) __pause_nocancel; libc_hidden_proto (__pause_nocancel) /* Uncancelable nanosleep. */ -#define nanosleep_not_cancel(requested_time, remaining) \ - INLINE_SYSCALL (nanosleep, 2, requested_time, remaining) +__typeof (__nanosleep) __nanosleep_nocancel; +hidden_proto (__nanosleep_nocancel) /* Uncancelable sigsuspend. */ #define sigsuspend_not_cancel(set) \