From patchwork Mon Jul 13 17:10:15 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: 40078 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 57655389043D; Mon, 13 Jul 2020 17:10:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57655389043D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660251; bh=kLx7TJqsatko9nnFeILPzHs+9ztpadEfqfDu4Em9o/w=; 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=ZqR3lNC3VFDKZUes6ftL75QEzZc9M9fsPSTIAhLy9hXjvvHL2JvNNoxPcRzVkd2/N ADEh2jLYI5q0OywA/OixMG4Xd5WHlHWNibcLimV4bBlCloyt+hqb+fDWPywYIOxJCL dh+OEFWyyV/9MOBVr9kTQ81D9qfOj9ESHVwRMCXM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by sourceware.org (Postfix) with ESMTPS id 64ECF389041C for ; Mon, 13 Jul 2020 17:10:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 64ECF389041C Received: by mail-qv1-xf43.google.com with SMTP id u8so6097282qvj.12 for ; Mon, 13 Jul 2020 10:10:49 -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=kLx7TJqsatko9nnFeILPzHs+9ztpadEfqfDu4Em9o/w=; b=TQJRS+ZvLdzAuSaNQ6nWev77+ZB0Sg5nbZhJGIvziSUH0asDpHRqOkhrnEYT9rvNuY 7PNGA896xEOn1+hoPWmTybWYVXYFWI4MP/98z8Gt1oGdc9iGsY1DaYhz5Fc+QN9X/RGG CCYdyjm8lJ4eSHdWa+Q1BTyED1XmnjT7yT2lnvDT9EwwVxbT+F3LLnW1nGX9rgP/MZO5 y1PjzULJOikzg0EspJUYy3kqlnq4xuCUZbIBbbOOdNp2VivYDIOUbfwVfSX8wcy0Hal6 oCsDKTl9iCOQcvVi3LWQtVgIX/6oYDwIABZF1s6i9HBY3uZBfVs4oPiuI7tuo9eRFs80 87RQ== X-Gm-Message-State: AOAM532hIKpQqG3tCIMCjtFgmjbHpownZwvMMLmDx/GANAtmHR/USM5V NCS1b53XOGYSaKGgFrarseu5cYoiq8U= X-Google-Smtp-Source: ABdhPJxJruePdDlr50o7h0EA40AIYtRc9lomV1Ym/QL0HtRsUD9jy4/jfB3cZNZEuINsnU59dXB4Cw== X-Received: by 2002:a05:6214:8f4:: with SMTP id dr20mr424532qvb.228.1594660248743; Mon, 13 Jul 2020 10:10:48 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 13/23] linux: Simplify clock_getres Date: Mon, 13 Jul 2020 14:10:15 -0300 Message-Id: <20200713171025.3661832-13-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_getres or __NR_clock_getres_time64. The 32-bit time_t support is now only build for !__ASSUME_TIME64_SYSCALLS. It also uses the time64-support functions to simplify it further. Checked on x86_64-linux-gnu and i686-linux-gnu (on 5.4 and on 4.15 kernel). --- sysdeps/unix/sysv/linux/clock_getres.c | 38 ++++++++++---------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index 5f6955ab10..6be73c94de 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -28,36 +29,26 @@ int __clock_getres64 (clockid_t clock_id, struct __timespec64 *res) { -#ifdef __ASSUME_TIME64_SYSCALLS - /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t. */ -# ifndef __NR_clock_getres_time64 -# define __NR_clock_getres_time64 __NR_clock_getres -# endif -# ifdef HAVE_CLOCK_GETRES64_VSYSCALL - return INLINE_VSYSCALL (clock_getres_time64, 2, clock_id, res); -# else - return INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res); -# endif -#else int r; - /* Old 32-bit ABI with possible 64-bit time_t support. */ -# ifdef __NR_clock_getres_time64 - /* Avoid issue a __NR_clock_getres_time64 syscall on kernels that do not - support 64-bit time_t. */ - static int time64_support = 1; - if (atomic_load_relaxed (&time64_support) != 0) + +#ifndef __NR_clock_getres_time64 +# define __NR_clock_getres_time64 __NR_clock_getres +#endif + if (supports_time64 ()) { -# ifdef HAVE_CLOCK_GETRES64_VSYSCALL +#ifdef HAVE_CLOCK_GETRES64_VSYSCALL r = INLINE_VSYSCALL (clock_getres_time64, 2, clock_id, res); -# else +#else r = INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res); -# endif +#endif + if (r == 0 || errno != ENOSYS) return r; - atomic_store_relaxed (&time64_support, 0); + mark_time64_unsupported (); } -# endif + +#ifndef __ASSUME_TIME64_SYSCALLS /* Fallback code that uses 32-bit support. */ struct timespec ts32; # ifdef HAVE_CLOCK_GETRES_VSYSCALL @@ -67,8 +58,9 @@ __clock_getres64 (clockid_t clock_id, struct __timespec64 *res) # endif if (r == 0) *res = valid_timespec_to_timespec64 (ts32); - return r; #endif + + return r; } #if __TIMESIZE != 64