From patchwork Sat Jan 18 07:20:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1225113 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-108792-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=Gl2fUWIB; 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 4808WK3Yc7z9sP3 for ; Sat, 18 Jan 2020 18:21:49 +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=gCJqqFwrt27r48HJlJx5pZ2I3mxRQlx12VO/MFRWg04k714NwqU5v AA25f32CZanXytdAIL4P8ynSgwrjtyGEnApqpC6sCsvPoRHp6F36Qygf0WCbKnCa vq4ebGQICBBZXZnCW2B1lKKAyZqbfql7x3KY4si+6z8Cw6oz0cys9s= 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=N6KXKQ1MdwOQSDU9EKZ7QcuuLA0=; b=Gl2fUWIBLvPfVnq2l1coRzcRsy+D 9RfnDoJ9ErKvrBPyEGy81ytk2BOwh/DCkRn2sOSeVGN73r9LOTEqFPnozrDByJga Iyq5H3CDGAOp+DDptV+N8MHUaNpjVmihyimiQScA1ASz94efElSPTk+ihdz8greW b2Q9J560/EE5lRM= Received: (qmail 59117 invoked by alias); 18 Jan 2020 07:21:21 -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 59034 invoked by uid 89); 18 Jan 2020 07:21:21 -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= X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella , Samuel Thibault 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 1/6] y2038: Use __clock_settime64 in deprecated stime function Date: Sat, 18 Jan 2020 08:20:42 +0100 Message-Id: <20200118072047.23071-2-lukma@denx.de> In-Reply-To: <20200118072047.23071-1-lukma@denx.de> References: <20200118072047.23071-1-lukma@denx.de> MIME-Version: 1.0 Now, internally the deprecated stime uses __clock_settime64. This patch is necessary for having architectures with __WORDSIZE == 32 && __TIMESIZE == 32 (like e.g. ARM32) Y2038 safe. Build tests: ./src/scripts/build-many-glibcs.py glibcs --- time/stime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/time/stime.c b/time/stime.c index 576fa9c0c9..963902126b 100644 --- a/time/stime.c +++ b/time/stime.c @@ -27,11 +27,11 @@ int attribute_compat_text_section __stime (const time_t *when) { - struct timespec ts; + struct __timespec64 ts; ts.tv_sec = *when; ts.tv_nsec = 0; - return __clock_settime (CLOCK_REALTIME, &ts); + return __clock_settime64 (CLOCK_REALTIME, &ts); } compat_symbol (libc, __stime, stime, GLIBC_2_0); From patchwork Sat Jan 18 07:20:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1225110 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-108789-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=D2UTeBYX; 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 4808Vt2X1xz9sP3 for ; Sat, 18 Jan 2020 18:21:25 +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=w7GYqCgN+3Gp10m1Xn2gZAHdXXuL8eWaAzUwrbVMEgTzlXZI2NGT1 TT35MwUchrYbIJH+2lME+xTYeRq+9bhtSW5PIlwBTQCpCcdNuMaZWFG1FouIWUNY wJhBtyWahwDIIwdPlt7bQBdH4fGRMBEzmhps8stI25Kz4Z664LzQFI= 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=2LXMx8BU4a6v2cpdibbIJmapar0=; b=D2UTeBYX0uNaz7siMJhCqjf2dnI1 sLp1fFdVE5nKdgrU/iAi92ovPu6/Ew1Lh79HE9mo6wo+0piq+SxGwhMuylIuYkzP ipN90qt+6nbIb+E0guNetO7sChzP2Q5K97mmIz1BGccjoJrHb30VmgQbtBD8ou2b 8wu7aTCypp3c3lM= Received: (qmail 58621 invoked by alias); 18 Jan 2020 07:21:18 -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 58607 invoked by uid 89); 18 Jan 2020 07:21:18 -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, 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 , Samuel Thibault 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 2/6] y2038: hurd: Provide __clock_settime64 function Date: Sat, 18 Jan 2020 08:20:43 +0100 Message-Id: <20200118072047.23071-3-lukma@denx.de> In-Reply-To: <20200118072047.23071-1-lukma@denx.de> References: <20200118072047.23071-1-lukma@denx.de> MIME-Version: 1.0 For Linux glibc ports the __TIMESIZE == 64 ensures proper aliasing for __clock_settime64 (to __clock_settime). When __TIMESIZE != 64 (like ARM32, PPC) the glibc expects separate definition of the __clock_settime64. The HURD port only provides __clock_settime, so this patch adds __clock_settime64 as a tiny wrapper on it. --- sysdeps/mach/hurd/clock_settime.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sysdeps/mach/hurd/clock_settime.c b/sysdeps/mach/hurd/clock_settime.c index 2c77bad71a..db1ba860dc 100644 --- a/sysdeps/mach/hurd/clock_settime.c +++ b/sysdeps/mach/hurd/clock_settime.c @@ -53,3 +53,12 @@ versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17); strong_alias (__clock_settime, __clock_settime_2); compat_symbol (libc, __clock_settime_2, clock_settime, GLIBC_2_2); #endif + +int +__clock_settime64 (clockid_t clock_id, const struct __timespec64 *ts64) +{ + struct timespec ts = valid_timespec64_to_timespec (*ts64); + + return __clock_settime (clock_id, &ts); +} +libc_hidden_def (__clock_settime64) From patchwork Sat Jan 18 07:20:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1225112 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-108791-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=fz2i9GNj; 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 4808W91twDz9sP3 for ; Sat, 18 Jan 2020 18:21: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=rh3fY1uzK10zBY1HIxIjSu+YtYP7IRxpaiZ7KHwbkblmdOMpRXnIo xntQp/OfIz7ZG9GNhjmawTKXeiGcY7doTymZpCYDQOoOW1WKDADx3eW3BEGMccNT n7S7891U/th/BsbEM5MA4TmmX3fGs9Yn6gB8zrBVCAqfQndZ2yzkdw= 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=/sjaoGgqF/rRP/G27lZ5Jicfkno=; b=fz2i9GNjioKGAt5yEFzFD4nJnqkp PZzIfxOL9cg5YGFxOMLe1MAwJYfu/0mnIChw8wV6YTpUFs9svF1yR61O+VUKF3TN 8wSF+0LKtjQJCxzDldWo/jIEbgnSiekoyweI4ThpDo8RFgasdltbfiEYjKuI+8z0 a+HKpPrkemz3X3A= Received: (qmail 58945 invoked by alias); 18 Jan 2020 07:21:20 -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 58889 invoked by uid 89); 18 Jan 2020 07:21:20 -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= X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella , Samuel Thibault 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 3/6] y2038: Introduce struct __timeval64 - new internal glibc type Date: Sat, 18 Jan 2020 08:20:44 +0100 Message-Id: <20200118072047.23071-4-lukma@denx.de> In-Reply-To: <20200118072047.23071-1-lukma@denx.de> References: <20200118072047.23071-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 --- include/time.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/time.h b/include/time.h index 047f431a1a..22ecacd0d8 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 */ + __suseconds_t tv_usec; /* Microseconds */ +}; +#endif + #if __TIMESIZE == 64 # define __ctime64 ctime #else From patchwork Sat Jan 18 07:20:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1225114 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-108793-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=ZnoEQ3bf; 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 4808WT6mltz9sP3 for ; Sat, 18 Jan 2020 18:21:57 +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=y44hs1UXRUhSi4gjAvoOaSgTVH7YvtNmwgqmqayvXh7U039G1zmxF XH2S5j+1W1eHYq3/pN1eyBw32tEMt7nW6tpp6oXq8d4NripV9lEh9Lg5P6n85MBZ zyAGwXR/T46bje77QaU0/WN3L2VJA4/tgRci6lN4UnufxdOLAWVKyM= 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=NaWHI4PNPkoqgqnHahtT5Mq6vzE=; b=ZnoEQ3bfU48bA90cSHHnR8ABCWJp aUbD0jRdLV6RnxSDGVwqGBuZCFIRnw+NldT8lyRlKrTy0c6B+79YJyhIhqxsjnZB ubIcW5qiU5x9brhWd30OFX1pk5V75B0Ast7RRIfJKn0zythBkwk5xkpOfvTVQWtf WkiMaeB8Vq+kTfM= Received: (qmail 59290 invoked by alias); 18 Jan 2020 07:21:22 -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 59238 invoked by uid 89); 18 Jan 2020 07:21:22 -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=emphasis X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella , Samuel Thibault 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 4/6] y2038: alpha: Rename valid_timeval_to_timeval64 to valid_timeval32_to_timeval Date: Sat, 18 Jan 2020 08:20:45 +0100 Message-Id: <20200118072047.23071-5-lukma@denx.de> In-Reply-To: <20200118072047.23071-1-lukma@denx.de> References: <20200118072047.23071-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'. Reviewed-by: Alistair Francis --- 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 Sat Jan 18 07:20:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1225115 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-108794-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=KrQP1ene; 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 4808Wf1jCwz9sP3 for ; Sat, 18 Jan 2020 18:22:05 +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=Kv6WBMidliz3e29pif4lFHgSqnSLUPYolA0xVKosnNk3+Rskrkm1m DzC9vdSV55WJAPQWm2Xv3nQCwltLO9FsJPQg71Xlyolgwa9aqEufy/AuBDrpcTZP LVT01y+OAkD8TB2tHNm8kZUVfyZJnA6xi4f0SgKiGbh7J7hmZKuQjI= 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=95TgJ6+oTmicHgnpXJoz5D98hIw=; b=KrQP1ene31reyZFmk/6ZqLDQbmCX 6rmPQNaCqqgCtVeYF1Sx43hxTVA6PtPcuUoovby5+hEVrRvVfiEuhkgGjv7gvEI8 MmfXEISlo3TQeFleXEw2YEBs1grv0rKurhPJYBhVZqjwH2p02sB0vBqQARDqZSPB G+CbZLwoYfEhJtc= Received: (qmail 59484 invoked by alias); 18 Jan 2020 07:21:24 -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 59412 invoked by uid 89); 18 Jan 2020 07:21:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.8 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 , Samuel Thibault 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 5/6] y2038: Provide conversion helpers for struct __timeval64 Date: Sat, 18 Jan 2020 08:20:46 +0100 Message-Id: <20200118072047.23071-6-lukma@denx.de> In-Reply-To: <20200118072047.23071-1-lukma@denx.de> References: <20200118072047.23071-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 --- include/time.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/time.h b/include/time.h index 22ecacd0d8..b40214c006 100644 --- a/include/time.h +++ b/include/time.h @@ -304,6 +304,30 @@ 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 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 +366,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 Sat Jan 18 07:20:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1225116 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-108795-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=Yg4YYtO2; 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 4808Wq1l9hz9sP3 for ; Sat, 18 Jan 2020 18:22:15 +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=Fp+3IsxxI69QGjfHnvFhCWrLFVevhUqJZSh6eSRSZeyVuY4goKNiU q+cbWPwI7SnFq0Y4pILSjsVqJnoQ7b1vim6VRiOLpl+eULaLuVPvTmIAnicAdKhT leDOzdHDw1zU6+1Y3hc6hxDF8sKuj0HWh/JrQNOWm6Lmh0pDjFV3Ts= 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=zq0t5TV4WyHaBPGGt2ffsFjcqQE=; b=Yg4YYtO2Y81EdQ8/bPR+f1vXOXjl 9EJgLGQtkxvIRrQqKMGlQHO2UDj97EbB7Pu/DnW3PFZzvX1qYDcPL4PugaG4T0eD Z3qoRfxZXgD83kxunsXdOdr5gb30Gd53QQIQBuSvOJvHNqUFlzRqGN2tZBzJQD/2 i/SUQ9E6yQeM4Cs= Received: (qmail 59700 invoked by alias); 18 Jan 2020 07:21:25 -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 59607 invoked by uid 89); 18 Jan 2020 07:21:25 -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=east, Moreover, qemu, HX-Languages-Length:3180 X-HELO: mail-out.m-online.net From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella , Samuel Thibault 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 6/6] y2038: linux: Provide __settimeofday64 implementation Date: Sat, 18 Jan 2020 08:20:47 +0100 Message-Id: <20200118072047.23071-7-lukma@denx.de> In-Reply-To: <20200118072047.23071-1-lukma@denx.de> References: <20200118072047.23071-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: Alistair Francis --- include/time.h | 9 +++++++++ time/settimeofday.c | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/time.h b/include/time.h index b40214c006..b76ffea225 100644 --- a/include/time.h +++ b/include/time.h @@ -8,6 +8,7 @@ # include