From patchwork Mon Jul 13 17:10:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 40068 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61097388CC3C; Mon, 13 Jul 2020 17:10:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61097388CC3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660237; bh=z8NEIFxUwS25r4yH8lI+5a0DMPmwGbFo9LRU8xmg0bs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GWujNm02u1gQdrzOYE9tJgXwtCbxly7vU6nb85FqNqRhJxjSr76jLYeRksOP/bYtQ XbAJegldGl1dSKSMy7NJ3Jpu/VbDbVi9eOt9NT3Th3pxiozm+HjQTo4mNAkrqNudU9 BmJi4b0ZM7uZRRrgGdL20Il2uUdeCg9Ko0+aj+WE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by sourceware.org (Postfix) with ESMTPS id E58D3388CC03 for ; Mon, 13 Jul 2020 17:10:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E58D3388CC03 Received: by mail-qv1-xf44.google.com with SMTP id h18so6120710qvl.3 for ; Mon, 13 Jul 2020 10:10:33 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=z8NEIFxUwS25r4yH8lI+5a0DMPmwGbFo9LRU8xmg0bs=; b=sOcMKyPYBYE/vSooSYdozu3609nL/B+WF4C8gVeiOWIUbX3BCSb4CL8EPCQvwuf6bB AVNa2PZ/2fJUv460ePseioXlWG0s63lw26g2nNVyivH+YN8ByYqnRYB447sniYoK6sw5 IYoGeKIZl5lxNM8ZzkOxvkMSpTFWmEDsxjQWmLQqS9mnzXO1uXIwnl5N95fUk3ddky0f Kw6HPQPaCGJaR8FNCDJH0h5SPa7k9MtZNLEsNFXrqAZR2ZTUk0lF8/MZjN/xaCq1OnZQ RdHGVD2otxXR7KA29wL+JV81y6mpZ+zqqFRUIwlyW2dHhk3XsTdG1eoXryQjpk09ABNI ngiA== X-Gm-Message-State: AOAM5321AjYlRSwW6mosnnzZWaIxk+aeUis1Apktr27Zc/CXJ99UmF25 lZsFX/ebW6CPhiL2u8z31D/wLyyhUyY= X-Google-Smtp-Source: ABdhPJz5Q3mgBXzkQurbruYk64hsnU6/PlUwAayOQdR5xy1+EWExIvXjANheFTiq4dmbYBgu7TcyEg== X-Received: by 2002:ad4:5511:: with SMTP id az17mr413280qvb.159.1594660233282; Mon, 13 Jul 2020 10:10:33 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:32 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 03/23] linux: Simplify clock_nanosleep Date: Mon, 13 Jul 2020 14:10:05 -0300 Message-Id: <20200713171025.3661832-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> References: <20200713171025.3661832-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" With arch-syscall.h it can now assumes the existance of either __NR_clock_nanosleep or __NR_clock_nanosleep_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). Reviewed-by: Lukasz Majewski --- sysdeps/unix/sysv/linux/clock_nanosleep.c | 33 ++++++++--------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c index cc7a09569d..6ad3321435 100644 --- a/sysdeps/unix/sysv/linux/clock_nanosleep.c +++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c @@ -30,8 +30,6 @@ int __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req, struct __timespec64 *rem) { - int r; - if (clock_id == CLOCK_THREAD_CPUTIME_ID) return EINVAL; if (clock_id == CLOCK_PROCESS_CPUTIME_ID) @@ -39,22 +37,15 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec /* If the call is interrupted by a signal handler or encounters an error, it returns a positive value similar to errno. */ -#ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_clock_nanosleep_time64 -# define __NR_clock_nanosleep_time64 __NR_clock_nanosleep -# endif - r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id, - flags, req, rem); -#else -# ifdef __NR_clock_nanosleep_time64 - r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id, - flags, req, rem); - - if (! INTERNAL_SYSCALL_ERROR_P (r)) - return 0; - if (INTERNAL_SYSCALL_ERRNO (r) != ENOSYS) - return INTERNAL_SYSCALL_ERRNO (r); -# endif /* __NR_clock_nanosleep_time64 */ +#ifndef __NR_clock_nanosleep_time64 +# define __NR_clock_nanosleep_time64 __NR_clock_nanosleep +#endif + int r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, clock_id, + flags, req, rem); + +#ifndef __ASSUME_TIME64_SYSCALLS + if (r == 0 || r != -ENOSYS) + return -r; if (! in_time_t_range (req->tv_sec)) { @@ -68,14 +59,12 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec &ts32, &tr32); if (INTERNAL_SYSCALL_ERROR_P (r)) { - if (INTERNAL_SYSCALL_ERRNO (r) == EINTR && rem != NULL - && (flags & TIMER_ABSTIME) == 0) + if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0) *rem = valid_timespec_to_timespec64 (tr32); } #endif /* __ASSUME_TIME64_SYSCALLS */ - return (INTERNAL_SYSCALL_ERROR_P (r) - ? INTERNAL_SYSCALL_ERRNO (r) : 0); + return -r; } #if __TIMESIZE != 64