From patchwork Wed Jan 29 12:59:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1230878 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-109016-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=sPagHanw; 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 4873VC2RDbz9sPK for ; Wed, 29 Jan 2020 23:59:46 +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=Wcj g9r7W52+0Li2fYbJkOrE/LQhgesXvIDLUgaCZGm7sVBLmW5HECyJh1mexCC8o5Wr C7A5hAyah8aZc/h/slB9UXlwOV9ntEt11mqyiLo40aBkuy7v1rC2KatgLwFV5VvY bZJ9nU3pCAe+DdKHPXi2L2ZSEj4iCk09e84MIO+I= 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=ZGO27ZNTW T6PIif1DdJ9fu0Q+k0=; b=sPagHanwxj9byGdtMxPA/QDLPb5Twh96FgT2wWQd3 5JuILRP8TR8VEtNUyOlMtYOzGL+zPUtgecScRIyTH9uQT2kBdlD+lkoMRYBuor4E pGuBTgzJv+UPqV/QCisshcV14LlhJxfJSNXJSLvaIryXW/cqs7jTtWrTb3kAmMXd /Y= Received: (qmail 30514 invoked by alias); 29 Jan 2020 12:59:41 -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 30504 invoked by uid 89); 29 Jan 2020 12:59:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=indentation, HContent-Transfer-Encoding:8bit X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Andreas Schwab , Lukasz Majewski Subject: [PATCH v3 1/7] y2038: Define __suseconds64_t type to be used with struct __timeval64 Date: Wed, 29 Jan 2020 13:59:08 +0100 Message-Id: <20200129125914.11221-1-lukma@denx.de> MIME-Version: 1.0 The __suseconds64_t type is supposed to be the 64 bit type across all architectures. It would be mostly used internally in the glibc - however, when passed to Linux kernel (very unlikely), if necessary, it shall be converted to 32 bit type (i.e. __suseconds_t) Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis Reviewed-by: Adhemerval Zanella --- Changes for v3: - Fix indentation (from spaces to tab) for #define __SUSECONDS64_T_TYPE __SQUAD_TYPE Changes for v2: - New patch --- bits/typesizes.h | 1 + posix/bits/types.h | 1 + sysdeps/mach/hurd/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 1 + 8 files changed, 8 insertions(+) diff --git a/bits/typesizes.h b/bits/typesizes.h index 014c9aab21..599408973e 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -50,6 +50,7 @@ #define __TIME_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/posix/bits/types.h b/posix/bits/types.h index adba926b45..a26cd383e4 100644 --- a/posix/bits/types.h +++ b/posix/bits/types.h @@ -160,6 +160,7 @@ __STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */ __STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */ __STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */ __STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */ +__STD_TYPE __SUSECONDS64_T_TYPE __suseconds64_t; __STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */ __STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */ diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h index b429379d7d..10f3ac231a 100644 --- a/sysdeps/mach/hurd/bits/typesizes.h +++ b/sysdeps/mach/hurd/bits/typesizes.h @@ -50,6 +50,7 @@ #define __TIME_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h index 30356ba6d6..489e5d12e2 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h @@ -49,6 +49,7 @@ #define __TIME_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __S64_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h index a916dea047..7c963e523e 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h @@ -51,6 +51,7 @@ #define __TIME_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h index 45f70184ea..e775e460bb 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h @@ -50,6 +50,7 @@ #define __TIME_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h index 1f3bbc8002..ac48c23e37 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h @@ -50,6 +50,7 @@ #define __TIME_T_TYPE __SLONGWORD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __S32_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h index d084145597..87c50a4f32 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h @@ -64,6 +64,7 @@ #define __TIME_T_TYPE __SYSCALL_SLONG_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SYSCALL_SLONG_TYPE +#define __SUSECONDS64_T_TYPE __SQUAD_TYPE #define __DADDR_T_TYPE __S32_TYPE #define __KEY_T_TYPE __S32_TYPE #define __CLOCKID_T_TYPE __S32_TYPE From patchwork Wed Jan 29 12:59:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1230879 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-109017-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=XEf9YJKu; 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 4873VT5r3Rz9sPK for ; Thu, 30 Jan 2020 00:00:01 +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=YaIcYegxgBgkCtnyOljOY00/ahXjxnELFsnFNVajPUg8ynY2Wle+W i1ZCBBR6dAQKX4VaeXPCmncgCqg6TkcbXXb3ak7sjEFck1azTP5NCbTREMwilEPd F06urvNmnNNT99dI8ikdGExciJ99QOpaLFO/BRkIKWAQ23+0stJNiY= 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=uw4ZdN+Me0qjgEk760jw8nPqBqk=; b=XEf9YJKubc5NY4xsD26KNsimFuka LHJ2swgJ1OkZNrdwowJWxp6QQqqmdoPJP6O3iqqbsb6QVEGitzn6A2W+tAKrom2C nPTi+X4p7HTq+jZ2dZUc/d3hEtogJZG2MAoExX9fwq5YcJ0LBhspuYdkYxkiKAyl i254z+xKo8ZubnU= Received: (qmail 30753 invoked by alias); 29 Jan 2020 12:59:42 -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 30663 invoked by uid 89); 29 Jan 2020 12:59:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 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=HContent-Transfer-Encoding:8bit X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Andreas Schwab , Lukasz Majewski Subject: [PATCH v3 2/7] y2038: Introduce struct __timeval64 - new internal glibc type Date: Wed, 29 Jan 2020 13:59:09 +0100 Message-Id: <20200129125914.11221-2-lukma@denx.de> In-Reply-To: <20200129125914.11221-1-lukma@denx.de> References: <20200129125914.11221-1-lukma@denx.de> MIME-Version: 1.0 This type is a glibc's "internal" type similar to struct timeval but whose tv_sec field is a __time64_t rather than a time_t, which makes it Y2038-proof. This struct is NOT supposed to be passed to the kernel - instead it shall be converted to struct __timespec64 and clock_[sg]ettime syscalls shall be used (which are now Y2038 safe). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis Reviewed-by: Adhemerval Zanella --- Changes for v3: - None Changes for v2: - Replace __suseconds_t with __suseconds64_t --- include/time.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/time.h b/include/time.h index 047f431a1a..99492a1577 100644 --- a/include/time.h +++ b/include/time.h @@ -93,6 +93,20 @@ struct __itimerspec64 }; #endif +#if __TIMESIZE == 64 +# define __timeval64 timeval +#else +/* The glibc Y2038-proof struct __timeval64 structure for a time value. + This structure is NOT supposed to be passed to the Linux kernel. + Instead, it shall be converted to struct __timespec64 and time shall + be [sg]et via clock_[sg]ettime (which are now Y2038 safe). */ +struct __timeval64 +{ + __time64_t tv_sec; /* Seconds */ + __suseconds64_t tv_usec; /* Microseconds */ +}; +#endif + #if __TIMESIZE == 64 # define __ctime64 ctime #else From patchwork Wed Jan 29 12:59: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: 1230880 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-109018-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=d+bD7ov7; 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 4873Vg36tVz9sPW for ; Thu, 30 Jan 2020 00:00:11 +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=WaLwXQVuvMEI4vUMxh7fhQvg/o/z12Cbxv0dQAPloKwOH4ZIECOWL xZMm9kxqX3htGs9jGxZJ4l5uWrzfTRzlcursMzmHyHnR3zrrp/vthTDPlKSKBLH1 nMSiTiP0XgOdvtpo8mknyYHDAoUH/3VR40A8feE5aSyYvrw9hdoDfg= 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=+nEOUF98Brsc0gFtD4c3dtbAUVU=; b=d+bD7ov7ZVMyyQZJ4wBqnkFafNN4 b35/1wFx7JrAtNMsfbMAnGS8OEHT3reLnu55x8W4OAkymnemLYHY+SDfLjh9DORo EjZxo7DgcehuVdjHV4OCFyFM07fkhgmLp5uhteGTVBMzp4xVgtU5YlJxOMoQgdQ/ 07EVdhvD/xpAZNE= Received: (qmail 30871 invoked by alias); 29 Jan 2020 12:59:43 -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 30755 invoked by uid 89); 29 Jan 2020 12:59:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.2 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= X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Andreas Schwab , Lukasz Majewski Subject: [PATCH v3 3/7] y2038: alpha: Rename valid_timeval_to_timeval64 to valid_timeval32_to_timeval Date: Wed, 29 Jan 2020 13:59:10 +0100 Message-Id: <20200129125914.11221-3-lukma@denx.de> In-Reply-To: <20200129125914.11221-1-lukma@denx.de> References: <20200129125914.11221-1-lukma@denx.de> MIME-Version: 1.0 Without this patch the naming convention for functions to convert struct timeval32 to struct timeval (which supports 64 bit time on Alpha) was a bit misleading. The name 'valid_timeval_to_timeval64' suggest conversion of struct timeval to struct __timeval64 (as in ./include/time.h). As on alpha the struct timeval supports 64 bit time it seems more readable to emphasis struct timeval32 in the conversion function name. Hence the helper function naming change to 'valid_timeval32_to_timeval'. Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis Reviewed-by: Adhemerval Zanella --- Changes for v3: - None Changes for v2: - None --- sysdeps/unix/sysv/linux/alpha/osf_adjtime.c | 4 ++-- sysdeps/unix/sysv/linux/alpha/osf_setitimer.c | 4 ++-- sysdeps/unix/sysv/linux/alpha/osf_utimes.c | 4 ++-- sysdeps/unix/sysv/linux/alpha/tv32-compat.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c index cd864686f6..5ac72e252f 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c @@ -57,7 +57,7 @@ int attribute_compat_text_section __adjtime_tv32 (const struct timeval32 *itv, struct timeval32 *otv) { - struct timeval itv64 = valid_timeval_to_timeval64 (*itv); + struct timeval itv64 = valid_timeval32_to_timeval (*itv); struct timeval otv64; if (__adjtime (&itv64, &otv64) == -1) @@ -91,7 +91,7 @@ __adjtimex_tv32 (struct timex32 *tx) tx64.calcnt = tx->calcnt; tx64.errcnt = tx->errcnt; tx64.stbcnt = tx->stbcnt; - tx64.time = valid_timeval_to_timeval64 (tx->time); + tx64.time = valid_timeval32_to_timeval (tx->time); int status = __adjtimex (&tx64); if (status < 0) diff --git a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c index 418efbf546..3935d1cfb5 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c @@ -30,9 +30,9 @@ __setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, { struct itimerval new_value_64; new_value_64.it_interval - = valid_timeval_to_timeval64 (new_value->it_interval); + = valid_timeval32_to_timeval (new_value->it_interval); new_value_64.it_value - = valid_timeval_to_timeval64 (new_value->it_value); + = valid_timeval32_to_timeval (new_value->it_value); if (old_value == NULL) return __setitimer (which, &new_value_64, NULL); diff --git a/sysdeps/unix/sysv/linux/alpha/osf_utimes.c b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c index 423c2a8ef2..6c3fad0132 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_utimes.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c @@ -28,8 +28,8 @@ attribute_compat_text_section __utimes_tv32 (const char *filename, const struct timeval32 times32[2]) { struct timeval times[2]; - times[0] = valid_timeval_to_timeval64 (times32[0]); - times[1] = valid_timeval_to_timeval64 (times32[1]); + times[0] = valid_timeval32_to_timeval (times32[0]); + times[1] = valid_timeval32_to_timeval (times32[1]); return __utimes (filename, times); } diff --git a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h index 6076d2ec05..7169909259 100644 --- a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h +++ b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h @@ -70,7 +70,7 @@ struct rusage32 overflow, they write { INT32_MAX, TV_USEC_MAX } to the output. */ static inline struct timeval -valid_timeval_to_timeval64 (const struct timeval32 tv) +valid_timeval32_to_timeval (const struct timeval32 tv) { return (struct timeval) { tv.tv_sec, tv.tv_usec }; } From patchwork Wed Jan 29 12:59:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1230881 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-109019-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=wnYNLwkN; 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 4873W44jgDz9sPK for ; Thu, 30 Jan 2020 00:00:32 +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=ju8FDGCdgWApESo5QoExoiorIE0fwPQoDEDVo/y+WWayD1/yIo85E 7ERnKOG2igaa9TVRDLjtxfNVhchxL49+H0G+P4J3FY9YqW/TqJli/nQrHiuSTtBS QmzA3nweb7BjpN/csejWMQO6t7j3Fv1Vd1+CuI06/InCt0dOSS39C0= 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=gqJVA4x2xeEoJoUH/MK/0CeydVs=; b=wnYNLwkNanJl1qHdsx+TB1fpScqQ S6e+w5I57cvd0SDfoVM6bw0JLxSYmsMb3RkzvL2LxOXzYOG+7H+J+NqvLGn30zBr OHEaDW7jVY/Vfwcg8tWckj1bn6ZzmwhXcHjLruVmWT37ixyUnOrZfVLdV9Rr/6j0 lO5DnyJpwfxHlMo= Received: (qmail 31286 invoked by alias); 29 Jan 2020 12:59:46 -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 31199 invoked by uid 89); 29 Jan 2020 12:59:45 -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_NUMSUBJECT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy= X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Andreas Schwab , Lukasz Majewski Subject: [PATCH v3 4/7] y2038: alpha: Rename valid_timeval64_to_timeval to valid_timeval_to_timeval32 Date: Wed, 29 Jan 2020 13:59:11 +0100 Message-Id: <20200129125914.11221-4-lukma@denx.de> In-Reply-To: <20200129125914.11221-1-lukma@denx.de> References: <20200129125914.11221-1-lukma@denx.de> MIME-Version: 1.0 The name 'valid_timeval64_to_timeval' suggest conversion of struct __timeval64 to struct timeval (as in ./include/time.h). As on the alpha the struct timeval supports 64 bit time, it seems more feasible to emphasis struct timeval32 in the conversion function name. Hence the helper function naming change to 'valid_timeval_to_timeval32'. Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis Reviewed-by: Adhemerval Zanella --- Changes for v3: - New patch --- sysdeps/unix/sysv/linux/alpha/osf_adjtime.c | 4 ++-- sysdeps/unix/sysv/linux/alpha/osf_getitimer.c | 4 ++-- sysdeps/unix/sysv/linux/alpha/osf_setitimer.c | 4 ++-- sysdeps/unix/sysv/linux/alpha/tv32-compat.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c index 5ac72e252f..9825a4734d 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c @@ -63,7 +63,7 @@ __adjtime_tv32 (const struct timeval32 *itv, struct timeval32 *otv) if (__adjtime (&itv64, &otv64) == -1) return -1; - *otv = valid_timeval64_to_timeval (otv64); + *otv = valid_timeval_to_timeval32 (otv64); return 0; } @@ -116,7 +116,7 @@ __adjtimex_tv32 (struct timex32 *tx) tx->calcnt = tx64.calcnt; tx->errcnt = tx64.errcnt; tx->stbcnt = tx64.stbcnt; - tx->time = valid_timeval64_to_timeval (tx64.time); + tx->time = valid_timeval_to_timeval32 (tx64.time); return status; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c index 1da3d72411..e9de2b287b 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c @@ -33,9 +33,9 @@ __getitimer_tv32 (int which, struct itimerval32 *curr_value) /* Write all fields of 'curr_value' regardless of overflow. */ curr_value->it_interval - = valid_timeval64_to_timeval (curr_value_64.it_interval); + = valid_timeval_to_timeval32 (curr_value_64.it_interval); curr_value->it_value - = valid_timeval64_to_timeval (curr_value_64.it_value); + = valid_timeval_to_timeval32 (curr_value_64.it_value); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c index 3935d1cfb5..7df2d1b71c 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c @@ -43,9 +43,9 @@ __setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, /* Write all fields of 'old_value' regardless of overflow. */ old_value->it_interval - = valid_timeval64_to_timeval (old_value_64.it_interval); + = valid_timeval_to_timeval32 (old_value_64.it_interval); old_value->it_value - = valid_timeval64_to_timeval (old_value_64.it_value); + = valid_timeval_to_timeval32 (old_value_64.it_value); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h index 7169909259..8e34ed1c1b 100644 --- a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h +++ b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h @@ -76,7 +76,7 @@ valid_timeval32_to_timeval (const struct timeval32 tv) } static inline struct timeval32 -valid_timeval64_to_timeval (const struct timeval tv64) +valid_timeval_to_timeval32 (const struct timeval tv64) { if (__glibc_unlikely (tv64.tv_sec > (time_t) INT32_MAX)) return (struct timeval32) { INT32_MAX, TV_USEC_MAX}; @@ -103,8 +103,8 @@ rusage64_to_rusage32 (struct rusage32 *restrict r32, padding and reserved fields. */ memset (r32, 0, sizeof *r32); - r32->ru_utime = valid_timeval64_to_timeval (r64->ru_utime); - r32->ru_stime = valid_timeval64_to_timeval (r64->ru_stime); + r32->ru_utime = valid_timeval_to_timeval32 (r64->ru_utime); + r32->ru_stime = valid_timeval_to_timeval32 (r64->ru_stime); r32->ru_maxrss = r64->ru_maxrss; r32->ru_ixrss = r64->ru_ixrss; r32->ru_idrss = r64->ru_idrss; From patchwork Wed Jan 29 12:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1230882 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-109020-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=XgP3LbD5; 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 4873WF1tqLz9sPK for ; Thu, 30 Jan 2020 00:00:41 +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=BxD20c/ZKDKq9/MCz7akiUfyJL0WufAtEkFjeEd8kYgRV1/7IY14v +VOgzyWL80P4pRja2lM9R4X8YQjtri8p/LA9yLgTLMW1F5t/o5YNt0OW7pwrmmWm ys8C3kQHRSjnI500zm5idoaTfUrq/KeWPR0WSJ/sRyX/AFrQy7/BiM= 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=53uOtq7sikQpimdnlTlt8CwPm94=; b=XgP3LbD50latTmNFiymQnnfNIWqN nP2zO4kqe5aHacCtuc7WbbuqYrGFgp2R8Hj9iwDLybuuRl2mD7GsldhNUlbr/MTv I2DreBwkCr44fMwx64PI73yiFXpscbzZsAWruhtIV3vSpC+UnW7K8x8XnWY6H+vJ RJG2fBTS/5x/Y+Q= Received: (qmail 31513 invoked by alias); 29 Jan 2020 12:59:47 -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 31453 invoked by uid 89); 29 Jan 2020 12:59:47 -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_NUMSUBJECT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy= X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Andreas Schwab , Lukasz Majewski Subject: [PATCH v3 5/7] y2038: Provide conversion helpers for struct __timeval64 Date: Wed, 29 Jan 2020 13:59:12 +0100 Message-Id: <20200129125914.11221-5-lukma@denx.de> In-Reply-To: <20200129125914.11221-1-lukma@denx.de> References: <20200129125914.11221-1-lukma@denx.de> MIME-Version: 1.0 Those functions allow easy conversion between Y2038 safe, glibc internal struct __timeval64 and other time related data structures (like struct timeval or struct __timespec64). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis Reviewed-by: Adhemerval Zanella --- Chanes for v3: - Provide new helper function - valid_timeval64_to_timeval Changes for v2: - None --- include/time.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/include/time.h b/include/time.h index 99492a1577..8617114052 100644 --- a/include/time.h +++ b/include/time.h @@ -304,6 +304,43 @@ valid_timeval_to_timespec64 (const struct timeval tv) return ts64; } +/* Convert a known valid struct timeval into a struct __timeval64. */ +static inline struct __timeval64 +valid_timeval_to_timeval64 (const struct timeval tv) +{ + struct __timeval64 tv64; + + tv64.tv_sec = tv.tv_sec; + tv64.tv_usec = tv.tv_usec; + + return tv64; +} + +/* Convert a valid and within range of struct timeval, struct + __timeval64 into a struct timeval. */ +static inline struct timeval +valid_timeval64_to_timeval (const struct __timeval64 tv64) +{ + struct timeval tv; + + tv.tv_sec = (time_t) tv64.tv_sec; + tv.tv_usec = (suseconds_t) tv64.tv_usec; + + return tv; +} + +/* Convert a struct __timeval64 into a struct __timespec64. */ +static inline struct __timespec64 +timeval64_to_timespec64 (const struct __timeval64 tv64) +{ + struct __timespec64 ts64; + + ts64.tv_sec = tv64.tv_sec; + ts64.tv_nsec = tv64.tv_usec * 1000; + + return ts64; +} + /* Convert a known valid struct timespec into a struct __timespec64. */ static inline struct __timespec64 valid_timespec_to_timespec64 (const struct timespec ts) @@ -342,6 +379,18 @@ valid_timespec64_to_timeval (const struct __timespec64 ts64) return tv; } +/* Convert a struct __timespec64 into a struct __timeval64. */ +static inline struct __timeval64 +timespec64_to_timeval64 (const struct __timespec64 ts64) +{ + struct __timeval64 tv64; + + tv64.tv_sec = ts64.tv_sec; + tv64.tv_usec = ts64.tv_nsec / 1000; + + return tv64; +} + /* Check if a value is in the valid nanoseconds range. Return true if it is, false otherwise. */ static inline bool From patchwork Wed Jan 29 12:59:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1230883 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-109021-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=pxVtrR2n; 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 4873WR0ZJ9z9sPK for ; Thu, 30 Jan 2020 00:00:50 +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=yCJCgSMW0PqQ07z0f2HU6Ywd367kb2TinMJvfNkOSfr9MLXMKE0q2 zGL2uCMUoOs4NGCBZCZr1qSZWLVBhcn9Ok6sLwgeeCwzYkVIEALnazHdznDog72E OfEhy1qJq7BwrIgbsYvm1lxOvkY568JfgJkr6FTKYbNKmPXQDtteRk= 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=xgchBqGQukuFOjN0DpDz88LAOZI=; b=pxVtrR2nCqwZ/QSU5Ne2Ch6hjba9 f9aTm15ChGCFcizQ5MSPXNQRqVoEDgKrcTnfIEMJ9hPgUFtt/UlfhGjN0qv88Upw /UeUGUWuIJTe6bJQqlnwfgU8kvAhJLdhAe/ywhVx2ROey541KhcqFBhZfS+xLlvd E/6uVN3MHjyFqBQ= Received: (qmail 31983 invoked by alias); 29 Jan 2020 12:59:51 -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 31846 invoked by uid 89); 29 Jan 2020 12:59:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 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=hour, east X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Cc: Alistair Francis , Alistair Francis , GNU C Library , Siddhesh Poyarekar , Florian Weimer , Florian Weimer , Zack Weinberg , Carlos O'Donell , Andreas Schwab , Lukasz Majewski Subject: [PATCH v3 6/7] y2038: linux: Provide __settimeofday64 implementation Date: Wed, 29 Jan 2020 13:59:13 +0100 Message-Id: <20200129125914.11221-6-lukma@denx.de> In-Reply-To: <20200129125914.11221-1-lukma@denx.de> References: <20200129125914.11221-1-lukma@denx.de> MIME-Version: 1.0 This patch provides new __settimeofday64 explicit 64 bit function for setting 64 bit time in the kernel (by internally calling __clock_settime64). Moreover, a 32 bit version - __settimeofday has been refactored to internally use __settimeofday64. The __settimeofday is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion of struct timeval to 64 bit struct __timespec64. Internally the settimeofday uses __settimeofday64. 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 __settimeofday64 and __settimeofday. Reviewed-by: Adhemerval Zanella --- Changes for v3: - None Changes for v2: - The conversion to support 64 bit time for settimeofday() has been moved from ./time/settimeofday.c to sysdeps/unix/sysv/linux/settimeofday.c (as suggested by Adhemerval) to avoid the need to create __clock_settime64() method for HURD (as 64 bit time support for machines with __WORDSIZE=32 and __TIMESIZE=32 is now developed solely for Linux). --- include/time.h | 9 +++++ sysdeps/unix/sysv/linux/settimeofday.c | 53 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/settimeofday.c diff --git a/include/time.h b/include/time.h index 8617114052..0345803db2 100644 --- a/include/time.h +++ b/include/time.h @@ -8,6 +8,7 @@ # include