From patchwork Mon Jul 13 17:10:04 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: 40067 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 D3475388CC37; Mon, 13 Jul 2020 17:10:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3475388CC37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594660234; bh=ICAiV+dqyq3gTknQrhjggCRAmuHNSIwXEDBIjWTI6PI=; 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=AIBfSBZ1eGG00dY+koiGC0Hqq/mOsvrZLswqK1LI7Cy7N/bpEuJDnFeQHGV9mIQk4 KGUzJacmXcxAcvdsxwsWww0VCaUzQdYvoYEVPfUgJBCyAPtwW8BLju0BOLk5UQJIt8 SnIG8aRMJbjYvPXSSU/Frk2oRbU46aSiq/PchjvY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by sourceware.org (Postfix) with ESMTPS id 55414384607B for ; Mon, 13 Jul 2020 17:10:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 55414384607B Received: by mail-qk1-x742.google.com with SMTP id b185so12949550qkg.1 for ; Mon, 13 Jul 2020 10:10:32 -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=ICAiV+dqyq3gTknQrhjggCRAmuHNSIwXEDBIjWTI6PI=; b=JKElMreIv52+Kp0Pw1eQbWvuBBZZjQ2DuDcfRbwrx3jq0O5gX4n/o9M1bhL/OFC0q7 9SdytnPBEe6HmKWioH5+8uCbFVNWJaLrp4DsU+ciyWhct6Gd48oWydiyoeoMaakloR29 biiB5fry7il+XEMKMWu6ToSyloYtK3ga9odszNL5ZYSvl7Orwha9dUPMbX4hVxtjWKbf YDW7nsLqFt7nr0QE+DQt2PM45ddxw1oSWDknzx+g6QVbb3YanXdCcfP+VO0nnD1EfE4O yr8oZVfJUyg4ZgREweWzd6qIaFo3AdjSu2CEcmRcdGSBfURw7U0ennuY4ELDqEkigaqO /hwg== X-Gm-Message-State: AOAM533IkEwCQiAyzjD55Gg2cITezF9XRoDoAPJB/WmQMtzZURgkP++a 6GyROajUVx8ejrvq56HGKkO+KzFECsc= X-Google-Smtp-Source: ABdhPJxLild2JJ9TGjxybTS+kgQfvJ1z/ejYNf73VxS/ZkFShGtaDXw31SBu/uSXtbCL22zEzYuWuQ== X-Received: by 2002:a05:620a:24c9:: with SMTP id m9mr554917qkn.375.1594660231720; Mon, 13 Jul 2020 10:10:31 -0700 (PDT) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id v10sm19767919qtk.14.2020.07.13.10.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:10:31 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 02/23] linux: Simplify clock_gettime Date: Mon, 13 Jul 2020 14:10:04 -0300 Message-Id: <20200713171025.3661832-2-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_gettime or __NR_clock_gettime_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_gettime.c | 42 ++++++++++--------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index bfe3823b68..5a65113a1d 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -22,43 +22,34 @@ #include #include "kernel-posix-cpu-timers.h" #include - +#include #include /* Get current value of CLOCK and store it in TP. */ int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) { -#ifdef __ASSUME_TIME64_SYSCALLS - /* 64 bit ABIs or newer 32-bit ABIs that only support 64-bit time_t. */ -# ifndef __NR_clock_gettime64 -# define __NR_clock_gettime64 __NR_clock_gettime -# endif -# ifdef HAVE_CLOCK_GETTIME64_VSYSCALL - return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); -# else - return INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp); -# endif -#else int r; - /* Old 32-bit ABI with possible 64-bit time_t support. */ -# ifdef __NR_clock_gettime64 - /* Avoid issue a __NR_clock_gettime64 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_gettime64 +# define __NR_clock_gettime64 __NR_clock_gettime +#endif + + if (supports_time64 ()) { -# ifdef HAVE_CLOCK_GETTIME64_VSYSCALL +#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL r = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); -# else +#else r = INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp); -# endif +#endif + if (r == 0 || errno != ENOSYS) return r; - atomic_store_relaxed (&time64_support, 0); - } -# endif + mark_time64_unsupported (); + } + +#ifndef __ASSUME_TIME64_SYSCALLS /* Fallback code that uses 32-bit support. */ struct timespec tp32; # ifdef HAVE_CLOCK_GETTIME_VSYSCALL @@ -68,8 +59,9 @@ __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) # endif if (r == 0) *tp = valid_timespec_to_timespec64 (tp32); - return r; #endif + + return r; } #if __TIMESIZE != 64