From patchwork Tue Sep 8 14:57:25 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: 40368 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 4C26E395184B; Tue, 8 Sep 2020 14:57:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C26E395184B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1599577066; bh=kLx7TJqsatko9nnFeILPzHs+9ztpadEfqfDu4Em9o/w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=AU1gcM5xrAZq4+1Sl2Efsf+TC6/uUzN10hxzLMgnzmWvHxlFXpX2ecpgxfuLQiEqi ca21cTQ3tgdUpn6U2fH6Sb+5+qWiEtNVH664W+IUW4ZnKjRdFzPHx5izTxuHYXDiFV MDFeKevGd/QcOQHWY7b91ak5B7d6m/6isoal9ka4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by sourceware.org (Postfix) with ESMTPS id 81EB1386103E for ; Tue, 8 Sep 2020 14:57:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 81EB1386103E Received: by mail-qk1-x741.google.com with SMTP id w12so15537053qki.6 for ; Tue, 08 Sep 2020 07:57:43 -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:subject:date:message-id:mime-version :content-transfer-encoding; bh=kLx7TJqsatko9nnFeILPzHs+9ztpadEfqfDu4Em9o/w=; b=MIA6vTk2HSO00uoC1+xowGuMcaJiLNCAfOEwJqvVaWnidpczSzbkJqWcVR345Fq3hi CJe8Kz+S/OHNNbjeH68BU9AamoEqTCnMPDK3DcnWWy7zAkQTq3N7tEeYo05eZ3Xv2P+f AtUduLqgXwml/cRQ/vnCzBTtbmxU1ip2Tcn6u48kz9Vep6bwNmb85jw8yxuTUl9jezQb r6zLefH8pVG/N81p5b/9rKjmxHN5X51zvh81WRFhK7qdDEXFisge6kG1/LJ5zIJkmY7n Ag6Nx1jdfqH/WeiH3Sd/FYUsyJbTfWjCpbYUwHyJgAuni7Bwwcv3fUNYl1q4LCjQDWZI yAdw== X-Gm-Message-State: AOAM533NhM/YUPOnrMwIAlB/yqlGUgqrXjP+TSAzB8kYFxU0LeB/ooFY jzqsiMCM6nreYAc54CIKVkq/Jn2oRcQhqw== X-Google-Smtp-Source: ABdhPJyfofDOH60Oz/H7CjIvHJs4r2pH+LVItz4h/KQCgUm21Cv2Q1gRM9BTClXS3pq2Q3QQW6rb5A== X-Received: by 2002:a05:620a:148:: with SMTP id e8mr486174qkn.186.1599577062712; Tue, 08 Sep 2020 07:57:42 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id e188sm10800748qkd.55.2020.09.08.07.57.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 07:57:42 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2 01/14] linux: Simplify clock_getres Date: Tue, 8 Sep 2020 11:57:25 -0300 Message-Id: <20200908145738.640039-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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). Reviewed-by: Alistair Francis --- 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