Message ID | 20200324131821.22048-4-lukma@denx.de |
---|---|
State | Committed |
Commit | e008836c4afeeb81abe548b898fdf2db7d70eaff |
Headers |
Return-Path: <lukma@denx.de> 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 [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 6E6AC385B834 for <libc-alpha@sourceware.org>; Tue, 24 Mar 2020 13:18:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E6AC385B834 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 48msJl2wCRz1rrKd; Tue, 24 Mar 2020 14:18:47 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 48msJl2dgWz1r0bv; Tue, 24 Mar 2020 14:18:47 +0100 (CET) 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 nOts3F9gNSE9; Tue, 24 Mar 2020 14:18:46 +0100 (CET) X-Auth-Info: 0YKtHvBzadzqLMv/qge0zzFZAC3UKKo4yAce6rptBSU= 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; Tue, 24 Mar 2020 14:18:46 +0100 (CET) From: Lukasz Majewski <lukma@denx.de> To: Joseph Myers <joseph@codesourcery.com>, Adhemerval Zanella <adhemerval.zanella@linaro.org> Cc: Alistair Francis <alistair23@gmail.com>, Alistair Francis <alistair.francis@wdc.com>, GNU C Library <libc-alpha@sourceware.org>, Florian Weimer <fweimer@redhat.com>, Andreas Schwab <schwab@suse.de>, Lukasz Majewski <lukma@denx.de> Subject: [PATCH 3/5] y2038: inet: Convert inet deadline to support 64 bit time Date: Tue, 24 Mar 2020 14:18:19 +0100 Message-Id: <20200324131821.22048-4-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200324131821.22048-1-lukma@denx.de> References: <20200324131821.22048-1-lukma@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-30.9 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, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, 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 <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <http://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> X-List-Received-Date: Tue, 24 Mar 2020 13:18:49 -0000 |
Series |
y2038: Replace __clock_gettime with __clock_gettime64
|
|
Commit Message
Lukasz Majewski
March 24, 2020, 1:18 p.m. UTC
This change brings 64 bit time support to inet deadline related code for architectures with __WORDSIZE == 32 && __TIMESIZE != 64. It is also safe to replace struct timespec with struct __timespec64 in deadline related structures as: - The __deadline_to_ms () returns the number of miliseconds to deadline to be used with __poll (and hence it is a relative value). - To calculate the deadline from timeval (which will be converted latter) the uintmax_t type is used (unsinged long long int). --- inet/deadline.c | 4 ++-- inet/net-internal.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
Comments
On 24/03/2020 10:18, Lukasz Majewski wrote: > This change brings 64 bit time support to inet deadline related code for > architectures with __WORDSIZE == 32 && __TIMESIZE != 64. > > It is also safe to replace struct timespec with struct __timespec64 in > deadline related structures as: > > - The __deadline_to_ms () returns the number of miliseconds to deadline to > be used with __poll (and hence it is a relative value). > - To calculate the deadline from timeval (which will be converted latter) > the uintmax_t type is used (unsinged long long int). > --- > inet/deadline.c | 4 ++-- > inet/net-internal.h | 5 +++-- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/inet/deadline.c b/inet/deadline.c > index ebf9a4f52c..eac7afd1a8 100644 > --- a/inet/deadline.c > +++ b/inet/deadline.c > @@ -28,8 +28,8 @@ struct deadline_current_time > __deadline_current_time (void) > { > struct deadline_current_time result; > - if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0) > - __clock_gettime (CLOCK_REALTIME, &result.current); > + if (__clock_gettime64 (CLOCK_MONOTONIC, &result.current) != 0) > + __clock_gettime64 (CLOCK_REALTIME, &result.current); > assert (result.current.tv_sec >= 0); > return result; > } > diff --git a/inet/net-internal.h b/inet/net-internal.h > index 3ca301a9be..50c7e1c482 100644 > --- a/inet/net-internal.h > +++ b/inet/net-internal.h > @@ -24,6 +24,7 @@ > #include <stdint.h> > #include <sys/time.h> > #include <libc-diag.h> > +#include <struct___timespec64.h> Why time.h is not providing the __timespec64 in this case? > > int __inet6_scopeid_pton (const struct in6_addr *address, > const char *scope, uint32_t *result); > @@ -76,7 +77,7 @@ enum idna_name_classification __idna_name_classify (const char *name) > timeouts and vice versa. */ > struct deadline_current_time > { > - struct timespec current; > + struct __timespec64 current; > }; > > /* Return the current time. Terminates the process if the current > @@ -86,7 +87,7 @@ struct deadline_current_time __deadline_current_time (void) attribute_hidden; > /* Computed absolute deadline. */ > struct deadline > { > - struct timespec absolute; > + struct __timespec64 absolute; > }; > > >
Hi Adhemerval, > On 24/03/2020 10:18, Lukasz Majewski wrote: > > This change brings 64 bit time support to inet deadline related > > code for architectures with __WORDSIZE == 32 && __TIMESIZE != 64. > > > > It is also safe to replace struct timespec with struct __timespec64 > > in deadline related structures as: > > > > - The __deadline_to_ms () returns the number of miliseconds to > > deadline to be used with __poll (and hence it is a relative value). > > - To calculate the deadline from timeval (which will be converted > > latter) the uintmax_t type is used (unsinged long long int). > > --- > > inet/deadline.c | 4 ++-- > > inet/net-internal.h | 5 +++-- > > 2 files changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/inet/deadline.c b/inet/deadline.c > > index ebf9a4f52c..eac7afd1a8 100644 > > --- a/inet/deadline.c > > +++ b/inet/deadline.c > > @@ -28,8 +28,8 @@ struct deadline_current_time > > __deadline_current_time (void) > > { > > struct deadline_current_time result; > > - if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0) > > - __clock_gettime (CLOCK_REALTIME, &result.current); > > + if (__clock_gettime64 (CLOCK_MONOTONIC, &result.current) != 0) > > + __clock_gettime64 (CLOCK_REALTIME, &result.current); > > assert (result.current.tv_sec >= 0); > > return result; > > } > > diff --git a/inet/net-internal.h b/inet/net-internal.h > > index 3ca301a9be..50c7e1c482 100644 > > --- a/inet/net-internal.h > > +++ b/inet/net-internal.h > > @@ -24,6 +24,7 @@ > > #include <stdint.h> > > #include <sys/time.h> > > #include <libc-diag.h> > > +#include <struct___timespec64.h> > > Why time.h is not providing the __timespec64 in this case? There is quite long queue for Y2038 patches - as in [1]. The struct __timespec64 has gained its own include file - namely ./include/struct___timespec.h [2] - when I do prepared conversion of mq_timed{send|receive} Links: [1] - https://github.com/lmajewski/y2038_glibc/commits/y2038_edge [2] - https://github.com/lmajewski/y2038_glibc/commit/6c7250ef4bf7ea87479489a825f05bb0de8d7684 > > > > > int __inet6_scopeid_pton (const struct in6_addr *address, > > const char *scope, uint32_t *result); > > @@ -76,7 +77,7 @@ enum idna_name_classification > > __idna_name_classify (const char *name) timeouts and vice versa. */ > > struct deadline_current_time > > { > > - struct timespec current; > > + struct __timespec64 current; > > }; > > > > /* Return the current time. Terminates the process if the current > > @@ -86,7 +87,7 @@ struct deadline_current_time > > __deadline_current_time (void) attribute_hidden; /* Computed > > absolute deadline. */ struct deadline > > { > > - struct timespec absolute; > > + struct __timespec64 absolute; > > }; > > > > > > Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
On 24/03/2020 14:52, Lukasz Majewski wrote: > Hi Adhemerval, > >> On 24/03/2020 10:18, Lukasz Majewski wrote: >>> This change brings 64 bit time support to inet deadline related >>> code for architectures with __WORDSIZE == 32 && __TIMESIZE != 64. >>> >>> It is also safe to replace struct timespec with struct __timespec64 >>> in deadline related structures as: >>> >>> - The __deadline_to_ms () returns the number of miliseconds to >>> deadline to be used with __poll (and hence it is a relative value). >>> - To calculate the deadline from timeval (which will be converted >>> latter) the uintmax_t type is used (unsinged long long int). >>> --- >>> inet/deadline.c | 4 ++-- >>> inet/net-internal.h | 5 +++-- >>> 2 files changed, 5 insertions(+), 4 deletions(-) >>> >>> diff --git a/inet/deadline.c b/inet/deadline.c >>> index ebf9a4f52c..eac7afd1a8 100644 >>> --- a/inet/deadline.c >>> +++ b/inet/deadline.c >>> @@ -28,8 +28,8 @@ struct deadline_current_time >>> __deadline_current_time (void) >>> { >>> struct deadline_current_time result; >>> - if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0) >>> - __clock_gettime (CLOCK_REALTIME, &result.current); >>> + if (__clock_gettime64 (CLOCK_MONOTONIC, &result.current) != 0) >>> + __clock_gettime64 (CLOCK_REALTIME, &result.current); >>> assert (result.current.tv_sec >= 0); >>> return result; >>> } >>> diff --git a/inet/net-internal.h b/inet/net-internal.h >>> index 3ca301a9be..50c7e1c482 100644 >>> --- a/inet/net-internal.h >>> +++ b/inet/net-internal.h >>> @@ -24,6 +24,7 @@ >>> #include <stdint.h> >>> #include <sys/time.h> >>> #include <libc-diag.h> >>> +#include <struct___timespec64.h> >> >> Why time.h is not providing the __timespec64 in this case? > > There is quite long queue for Y2038 patches - as in [1]. > > The struct __timespec64 has gained its own include file - namely > ./include/struct___timespec.h [2] - when I do prepared conversion of > mq_timed{send|receive} > > > Links: > > [1] - https://github.com/lmajewski/y2038_glibc/commits/y2038_edge > [2] - > https://github.com/lmajewski/y2038_glibc/commit/6c7250ef4bf7ea87479489a825f05bb0de8d7684 Yes, I am aware. I still think that include <time.h> would be better here. The struct*.h installed files are meant to be used on installed headers to avoid naming pollution, I don't see a good way to used them directly.
Hi Adhemerval, > On 24/03/2020 14:52, Lukasz Majewski wrote: > > Hi Adhemerval, > > > >> On 24/03/2020 10:18, Lukasz Majewski wrote: > >>> This change brings 64 bit time support to inet deadline related > >>> code for architectures with __WORDSIZE == 32 && __TIMESIZE != 64. > >>> > >>> It is also safe to replace struct timespec with struct > >>> __timespec64 in deadline related structures as: > >>> > >>> - The __deadline_to_ms () returns the number of miliseconds to > >>> deadline to be used with __poll (and hence it is a relative > >>> value). > >>> - To calculate the deadline from timeval (which will be converted > >>> latter) the uintmax_t type is used (unsinged long long int). > >>> --- > >>> inet/deadline.c | 4 ++-- > >>> inet/net-internal.h | 5 +++-- > >>> 2 files changed, 5 insertions(+), 4 deletions(-) > >>> > >>> diff --git a/inet/deadline.c b/inet/deadline.c > >>> index ebf9a4f52c..eac7afd1a8 100644 > >>> --- a/inet/deadline.c > >>> +++ b/inet/deadline.c > >>> @@ -28,8 +28,8 @@ struct deadline_current_time > >>> __deadline_current_time (void) > >>> { > >>> struct deadline_current_time result; > >>> - if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0) > >>> - __clock_gettime (CLOCK_REALTIME, &result.current); > >>> + if (__clock_gettime64 (CLOCK_MONOTONIC, &result.current) != 0) > >>> + __clock_gettime64 (CLOCK_REALTIME, &result.current); > >>> assert (result.current.tv_sec >= 0); > >>> return result; > >>> } > >>> diff --git a/inet/net-internal.h b/inet/net-internal.h > >>> index 3ca301a9be..50c7e1c482 100644 > >>> --- a/inet/net-internal.h > >>> +++ b/inet/net-internal.h > >>> @@ -24,6 +24,7 @@ > >>> #include <stdint.h> > >>> #include <sys/time.h> > >>> #include <libc-diag.h> > >>> +#include <struct___timespec64.h> > >> > >> Why time.h is not providing the __timespec64 in this case? > > > > There is quite long queue for Y2038 patches - as in [1]. > > > > The struct __timespec64 has gained its own include file - namely > > ./include/struct___timespec.h [2] - when I do prepared conversion of > > mq_timed{send|receive} > > > > > > Links: > > > > [1] - https://github.com/lmajewski/y2038_glibc/commits/y2038_edge > > [2] - > > https://github.com/lmajewski/y2038_glibc/commit/6c7250ef4bf7ea87479489a825f05bb0de8d7684 > > > > Yes, I am aware. I still think that include <time.h> would be better > here. Andreas has opposed for polluting more and more internal glibc headers with #include <time.h> to only get struct __timespec64 available (include/mqueue.h is a good example here). Also Joseph has suggested to add struct __timespec64 to ./include/struct___timespec64.h > The struct*.h installed files are meant to be used on installed > headers to avoid naming pollution, I don't see a good way to used them > directly. Please be aware that this is an internal glibc definition - this is not exported. > Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
diff --git a/inet/deadline.c b/inet/deadline.c index ebf9a4f52c..eac7afd1a8 100644 --- a/inet/deadline.c +++ b/inet/deadline.c @@ -28,8 +28,8 @@ struct deadline_current_time __deadline_current_time (void) { struct deadline_current_time result; - if (__clock_gettime (CLOCK_MONOTONIC, &result.current) != 0) - __clock_gettime (CLOCK_REALTIME, &result.current); + if (__clock_gettime64 (CLOCK_MONOTONIC, &result.current) != 0) + __clock_gettime64 (CLOCK_REALTIME, &result.current); assert (result.current.tv_sec >= 0); return result; } diff --git a/inet/net-internal.h b/inet/net-internal.h index 3ca301a9be..50c7e1c482 100644 --- a/inet/net-internal.h +++ b/inet/net-internal.h @@ -24,6 +24,7 @@ #include <stdint.h> #include <sys/time.h> #include <libc-diag.h> +#include <struct___timespec64.h> int __inet6_scopeid_pton (const struct in6_addr *address, const char *scope, uint32_t *result); @@ -76,7 +77,7 @@ enum idna_name_classification __idna_name_classify (const char *name) timeouts and vice versa. */ struct deadline_current_time { - struct timespec current; + struct __timespec64 current; }; /* Return the current time. Terminates the process if the current @@ -86,7 +87,7 @@ struct deadline_current_time __deadline_current_time (void) attribute_hidden; /* Computed absolute deadline. */ struct deadline { - struct timespec absolute; + struct __timespec64 absolute; };