From patchwork Thu Jan 16 13:27:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1224223 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=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108722-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=yKZM9Ka2; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47z4l52lrXz9sRd for ; Fri, 17 Jan 2020 00:28:17 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=mYl Wc2j/VDtPyCD64nL/talxv0zFf5SvjrR+HQLVp4UVTTzLH2DDkltXnSVUrAjIFnW nhX9drrklmLetrpSurruBDFep7ygNTXgp5PFytGhSvUrpVddxBiiE5TJWrkyAYmt aWZXpmPQliMWru03EXragO3I4i9CqrhUEMq7zbDc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=NFIVWm3XE Dk7fdRdQ4fX2sl/0Mg=; b=yKZM9Ka2KxXjUc6V3B1eZbHhcXECQ+OExddqKuNxM 0uriPMuJqPM3SFTVGMKh6G+4+V2Dd7BOytj3AFULN7TCGXH5jcWWXQYUStHDuP3n +iS+H++AUUgo883Q5H7RiZFRCfh6Z/l57TtAPJAPfkPn4JhOTAeDXhBySahkbr5K YM= Received: (qmail 47863 invoked by alias); 16 Jan 2020 13:28:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 47756 invoked by uid 89); 16 Jan 2020 13:28:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=H*Ad:U*zackw, H*Ad:D*panix.com, HContent-Transfer-Encoding:8bit X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella , Andreas Schwab , Samuel Thibault Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Lukasz Majewski Subject: [PATCH 1/2] y2038: hurd: Provide __clock_gettime64 function Date: Thu, 16 Jan 2020 14:27:27 +0100 Message-Id: <20200116132728.11646-1-lukma@denx.de> MIME-Version: 1.0 For Linux glibc ports the __TIMESIZE == 64 ensures proper aliasing for __clock_gettime64 (to __clock_gettime). When __TIMESIZE != 64 (like ARM32, PPC) the glibc expects separate definition of the __clock_gettime64. The HURD port only provides __clock_gettime, so this patch adds __clock_gettime64 as a tiny wrapper on it. Acked-by: Samuel Thibault --- sysdeps/mach/clock_gettime.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sysdeps/mach/clock_gettime.c b/sysdeps/mach/clock_gettime.c index ac3547df3c..fbd80536d5 100644 --- a/sysdeps/mach/clock_gettime.c +++ b/sysdeps/mach/clock_gettime.c @@ -49,3 +49,17 @@ versioned_symbol (libc, __clock_gettime, clock_gettime, GLIBC_2_17); strong_alias (__clock_gettime, __clock_gettime_2); compat_symbol (libc, __clock_gettime_2, clock_gettime, GLIBC_2_2); #endif + +int +__clock_gettime64 (clockid_t clock_id, struct __timespec64 *ts64) +{ + struct timespec ts; + int ret; + + ret = __clock_gettime (clock_id, &ts); + if (ret == 0) + *ts64 = valid_timespec_to_timespec64 (ts); + + return ret; +} +libc_hidden_def (__clock_gettime64) From patchwork Thu Jan 16 13:27:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1224222 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=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108721-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=kZWEacBJ; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47z4kw6KBKz9sSL for ; Fri, 17 Jan 2020 00:28:08 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=G+41WBK66DUubSqj6uxWHpIXhzf/gtszvu/Ujx69BMP/E+1MPytlL G4lpvCLWzwLf1CTWrniV+Q+hRdF/fhVUMBe1l4OZ9e7HR/nbi6VK5vX5EVheUjgn XIeELfgtbWL0AHcX9w8DLIITzGSK9080DfIQJBiFxKR6HdZB2Rn2jY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=pQkl5RFQKVbNiOmE3YZEEIEPPuI=; b=kZWEacBJbpt+h5ED5PyMrQagp0Ce Lyi4maCJI2AjW2vrW2EJLlU00xvUVMBPdCSB+nJXoJvjKRhD2+qBKfCq3rhPgVd6 38chvkEupT7hppAZFUYTKNQAg+lm8O1ANVuqEqlGhXtFRxB0iaovkSGnuIraKQh6 5QBBsUPvyk+JWgE= Received: (qmail 47755 invoked by alias); 16 Jan 2020 13:28:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 47740 invoked by uid 89); 16 Jan 2020 13:28:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=calendar, H*Ad:U*zackw, H*Ad:D*panix.com X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella , Andreas Schwab , Samuel Thibault Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Lukasz Majewski Subject: [PATCH 2/2] y2038: linux: Provide __timespec_get64 implementation Date: Thu, 16 Jan 2020 14:27:28 +0100 Message-Id: <20200116132728.11646-2-lukma@denx.de> In-Reply-To: <20200116132728.11646-1-lukma@denx.de> References: <20200116132728.11646-1-lukma@denx.de> MIME-Version: 1.0 This patch provides new __timespec_get64 explicit 64 bit function for getting 64 bit time in the struct __timespec64 (for compilation supporting C11). Moreover, a 32 bit version - __timespec_get has been refactored to internally use __timespec_get64. The __timespec_get is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 32 bit struct timespec. Internally the timespec_get uses __clock_gettime64. This patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe. 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 proper usage of both __timespec_get64 and __timespec_get. --- include/time.h | 3 +++ time/timespec_get.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/include/time.h b/include/time.h index 558923274a..047f431a1a 100644 --- a/include/time.h +++ b/include/time.h @@ -254,6 +254,7 @@ extern double __difftime (time_t time1, time_t time0); #if __TIMESIZE == 64 # define __clock_nanosleep_time64 __clock_nanosleep # define __clock_gettime64 __clock_gettime +# define __timespec_get64 __timespec_get #else extern int __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req, @@ -261,6 +262,8 @@ extern int __clock_nanosleep_time64 (clockid_t clock_id, libc_hidden_proto (__clock_nanosleep_time64) extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp); libc_hidden_proto (__clock_gettime64) +extern int __timespec_get64 (struct __timespec64 *ts, int base); +libc_hidden_proto (__timespec_get64) #endif /* Use in the clock_* functions. Size of the field representing the diff --git a/time/timespec_get.c b/time/timespec_get.c index a1ec4167da..98f0aaf700 100644 --- a/time/timespec_get.c +++ b/time/timespec_get.c @@ -16,16 +16,43 @@ . */ #include - +#include /* Set TS to calendar time based in time base BASE. */ int -timespec_get (struct timespec *ts, int base) +__timespec_get64 (struct __timespec64 *ts, int base) { if (base == TIME_UTC) { - __clock_gettime (CLOCK_REALTIME, ts); + __clock_gettime64 (CLOCK_REALTIME, ts); return base; } return 0; } + +#if __TIMESIZE != 64 +libc_hidden_def (__timespec_get64) + +int +__timespec_get (struct timespec *ts, int base) +{ + int ret; + struct __timespec64 tp64; + + ret = __timespec_get64 (&tp64, base); + + if (ret == TIME_UTC) + { + if (! in_time_t_range (tp64.tv_sec)) + { + __set_errno (EOVERFLOW); + return 0; + } + + *ts = valid_timespec64_to_timespec (tp64); + } + + return ret; +} +#endif +strong_alias (__timespec_get, timespec_get);