From patchwork Sun Apr 26 13:31:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1277062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4998355c3vz9sPF for ; Sun, 26 Apr 2020 23:32:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1E58B397201F; Sun, 26 Apr 2020 13:31:47 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 1227C397201F for ; Sun, 26 Apr 2020 13:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1227C397201F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 49982R0xGWz1rqrS; Sun, 26 Apr 2020 15:31:43 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 49982R0jfwz1qrhs; Sun, 26 Apr 2020 15:31:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 7P7j1FdwPQzA; Sun, 26 Apr 2020 15:31:41 +0200 (CEST) X-Auth-Info: 3YulLq+YaP/5Xko1KoYgDDhVleOgar6XO/HB/0dqvyE= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 26 Apr 2020 15:31:41 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Adhemerval Zanella Subject: [PATCH 10/10] y2038: linux: Provide __ntp_gettimex64 implementation Date: Sun, 26 Apr 2020 15:31:10 +0200 Message-Id: <20200426133110.5312-11-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200426133110.5312-1-lukma@denx.de> References: <20200426133110.5312-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-31.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Cc: GNU C Library , Andreas Schwab , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch provides new __ntp_gettimex64 explicit 64 bit function for getting time parameters via NTP interface. The call to __adjtimex in __ntp_gettime64 function has been replaced with direct call to __clock_adjtime64 syscall, to simplify the code. Moreover, a 32 bit version - __ntp_gettimex has been refactored to internally use __ntp_gettimex64. The __ntp_gettimex is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversions between struct ntptimeval and 64 bit struct __ntptimeval64. Build tests: ./src/scripts/build-many-glibcs.py glibcs Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master Above tests were performed with Y2038 redirection applied as well as without to test the proper usage of both __ntp_gettimex64 and __ntp_gettimex. --- sysdeps/unix/sysv/linux/include/sys/timex.h | 3 +++ sysdeps/unix/sysv/linux/ntp_gettimex.c | 24 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h index a00ce7138f..2e4ed6053c 100644 --- a/sysdeps/unix/sysv/linux/include/sys/timex.h +++ b/sysdeps/unix/sysv/linux/include/sys/timex.h @@ -34,6 +34,7 @@ libc_hidden_proto (__adjtimex) # define ___adjtimex64 ___adjtimex # define __ntptimeval64 ntptimeval # define __ntp_gettime64 __ntp_gettime +# define __ntp_gettimex64 __ntp_gettimex # else struct __timex64 @@ -86,6 +87,8 @@ struct __ntptimeval64 }; extern int __ntp_gettime64 (struct __ntptimeval64 *ntv); libc_hidden_proto (__ntp_gettime64) +extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv); +libc_hidden_proto (__ntp_gettimex64) # endif diff --git a/sysdeps/unix/sysv/linux/ntp_gettimex.c b/sysdeps/unix/sysv/linux/ntp_gettimex.c index 0f26d4806e..7d0328c6ca 100644 --- a/sysdeps/unix/sysv/linux/ntp_gettimex.c +++ b/sysdeps/unix/sysv/linux/ntp_gettimex.c @@ -15,6 +15,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #ifndef MOD_OFFSET @@ -23,13 +24,13 @@ int -ntp_gettimex (struct ntptimeval *ntv) +__ntp_gettimex64 (struct __ntptimeval64 *ntv) { - struct timex tntx; + struct __timex64 tntx; int result; tntx.modes = 0; - result = __adjtimex (&tntx); + result = __clock_adjtime64 (CLOCK_REALTIME, &tntx); ntv->time = tntx.time; ntv->maxerror = tntx.maxerror; ntv->esterror = tntx.esterror; @@ -40,3 +41,20 @@ ntp_gettimex (struct ntptimeval *ntv) ntv->__glibc_reserved4 = 0; return result; } + +#if __TIMESIZE != 64 +libc_hidden_def (__ntp_gettimex64) + +int +__ntp_gettimex (struct ntptimeval *ntv) +{ + struct __ntptimeval64 ntv64; + int result; + + result = __ntp_gettimex64 (&ntv64); + *ntv = valid_ntptimeval64_to_ntptimeval (ntv64); + + return result; +} +#endif +strong_alias (__ntp_gettimex, ntp_gettimex)