From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 920BA1F9FD for ; Mon, 8 Mar 2021 21:27:19 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7756C3850434; Mon, 8 Mar 2021 21:27:18 +0000 (GMT) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id 2AF8B3857C7B for ; Mon, 8 Mar 2021 21:27:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2AF8B3857C7B 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 4DvWdG0dJPz1qs0m; Mon, 8 Mar 2021 22:27:14 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4DvWdG0Mn7z1qqkQ; Mon, 8 Mar 2021 22:27:14 +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 W9qYStzvbh27; Mon, 8 Mar 2021 22:27:12 +0100 (CET) X-Auth-Info: aFJt+P5WAhOs7+vhb64Hwk5fS1kvWyYgIjV63iWv5RY= Received: from jawa (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; Mon, 8 Mar 2021 22:27:12 +0100 (CET) Date: Mon, 8 Mar 2021 22:27:05 +0100 From: Lukasz Majewski To: Adhemerval Zanella via Libc-alpha Subject: Re: [PATCH 37/52] time: Add 64 bit time support for getdate Message-ID: <20210308222705.593685bd@jawa> In-Reply-To: <20210305201518.798584-38-adhemerval.zanella@linaro.org> References: <20210305201518.798584-1-adhemerval.zanella@linaro.org> <20210305201518.798584-38-adhemerval.zanella@linaro.org> Organization: denx.de X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/Y9EBDIQK=ST28l=SvLz0ygz"; protocol="application/pgp-signature" X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --Sig_/Y9EBDIQK=ST28l=SvLz0ygz Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 5 Mar 2021 17:15:03 -0300 Adhemerval Zanella via Libc-alpha wrote: > The getdate is basically a wrapper localtime and mktime. The 64 bit > time support is done calling the 64 bit internal functions, there is > no need to add a new symbol version. >=20 > Checked on x86_64-linux-gnu and i686-linux-gnu. > --- > include/time.h | 12 ++++++++++-- > time/getdate.c | 22 ++++++++++------------ > time/tst-getdate.c | 14 ++++---------- > 3 files changed, 24 insertions(+), 24 deletions(-) >=20 > diff --git a/include/time.h b/include/time.h > index caf2af5e74..36754695c9 100644 > --- a/include/time.h > +++ b/include/time.h > @@ -280,8 +280,8 @@ hidden_proto (__nanosleep64) > #endif > =20 > =20 > -extern int __getdate_r (const char *__string, struct tm *__resbufp) > - attribute_hidden; > +extern int __getdate_r (const char *__string, struct tm *__resbufp); > +libc_hidden_proto (__getdate_r); > =20 > =20 > /* Determine CLK_TCK value. */ > @@ -502,6 +502,14 @@ time_now (void) > __clock_gettime (TIME_CLOCK_GETTIME_CLOCKID, &ts); > return ts.tv_sec; > } > + > +static inline __time64_t > +time64_now (void) > +{ > + struct __timespec64 ts; > + __clock_gettime64 (TIME_CLOCK_GETTIME_CLOCKID, &ts); > + return ts.tv_sec; > +} > #endif > =20 > #endif > diff --git a/time/getdate.c b/time/getdate.c > index 6e2f75566b..cdcc898517 100644 > --- a/time/getdate.c > +++ b/time/getdate.c > @@ -112,16 +112,16 @@ __getdate_r (const char *string, struct tm *tp) > size_t len; > char *datemsk; > char *result =3D NULL; > - time_t timer; > + __time64_t timer; > struct tm tm; > - struct stat64 st; > - int mday_ok =3D 0; > + struct __stat64_t64 st; > + bool mday_ok =3D false; > =20 > datemsk =3D getenv ("DATEMSK"); > if (datemsk =3D=3D NULL || *datemsk =3D=3D '\0') > return 1; > =20 > - if (__stat64 (datemsk, &st) < 0) > + if (__stat64_time64 (datemsk, &st) < 0) > return 3; > =20 > if (!S_ISREG (st.st_mode)) > @@ -219,8 +219,8 @@ __getdate_r (const char *string, struct tm *tp) > return 7; > =20 > /* Get current time. */ > - timer =3D time_now (); > - __localtime_r (&timer, &tm); > + timer =3D time64_now (); > + __localtime64_r (&timer, &tm); > =20 > /* If only the weekday is given, today is assumed if the given day > is equal to the current day and next week if it is less. */ > @@ -230,7 +230,7 @@ __getdate_r (const char *string, struct tm *tp) > tp->tm_year =3D tm.tm_year; > tp->tm_mon =3D tm.tm_mon; > tp->tm_mday =3D tm.tm_mday + (tp->tm_wday - tm.tm_wday + 7) % 7; > - mday_ok =3D 1; > + mday_ok =3D true; > } > =20 > /* If only the month is given, the current month is assumed if the > @@ -242,7 +242,7 @@ __getdate_r (const char *string, struct tm *tp) > if (tp->tm_year =3D=3D INT_MIN) > tp->tm_year =3D tm.tm_year + (((tp->tm_mon - tm.tm_mon) < 0) ? > 1 : 0); tp->tm_mday =3D first_wday (tp->tm_year, tp->tm_mon, > tp->tm_wday); > - mday_ok =3D 1; > + mday_ok =3D true; > } > =20 > /* If no hour, minute and second are given the current hour, minute > @@ -285,15 +285,13 @@ __getdate_r (const char *string, struct tm *tp) > call normalizes the struct tm. */ > if ((!mday_ok && !check_mday (TM_YEAR_BASE + tp->tm_year, > tp->tm_mon, tp->tm_mday)) > - || mktime (tp) =3D=3D (time_t) -1) > + || __mktime64 (tp) =3D=3D (time_t) -1) > return 8; > =20 > return 0; > } > -#ifdef weak_alias > weak_alias (__getdate_r, getdate_r) > -#endif > - > +libc_hidden_def (__getdate_r) > =20 > struct tm * > getdate (const char *string) > diff --git a/time/tst-getdate.c b/time/tst-getdate.c > index c37ba3083a..3bb0e96707 100644 > --- a/time/tst-getdate.c > +++ b/time/tst-getdate.c > @@ -115,20 +115,14 @@ do_test (void) > { > setenv ("TZ", tests[i].tz, 1); > =20 > - int expected_err; > - if (sizeof (time_t) =3D=3D 4 && tests[i].time64) > - expected_err =3D 8; > - else > - expected_err =3D 0; > - > tm =3D getdate (tests[i].str); > - TEST_COMPARE (getdate_err, expected_err); > - if (getdate_err !=3D expected_err) > + TEST_COMPARE (getdate_err, 0); > + if (getdate_err !=3D 0) > { > support_record_failure (); > printf ("%s\n", report_date_error ()); > } > - else if (getdate_err =3D=3D 0) > + else > { > TEST_COMPARE (tests[i].tm.tm_mon, tm->tm_mon); > TEST_COMPARE (tests[i].tm.tm_year, tm->tm_year); > @@ -139,7 +133,7 @@ do_test (void) > } > =20 > struct tm tms; > - TEST_COMPARE (getdate_r (tests[i].str, &tms), expected_err); > + TEST_COMPARE (getdate_r (tests[i].str, &tms), 0); > if (getdate_err =3D=3D 0) > { > TEST_COMPARE (tests[i].tm.tm_mon, tms.tm_mon); Reviewed-by: Lukasz Majewski 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 --Sig_/Y9EBDIQK=ST28l=SvLz0ygz Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmBGlqkACgkQAR8vZIA0 zr3gWwgArvBwbM6G9FHN+wctTofsWqI2pX0tb+NhTRGbFbB5RMwcL32KdS6Ety8q WwHELJuzQ/n2zd1QxJuZpFPjxAPSDsjJ+DqwkBbh07txBlIPIUGzPr8hy4ZNhzaQ AMQgYLY4b3zorZ83fBYE5O2yBpG2v1rBC2nkWIeB/aE1J0zOuy2wgUWAsuj2B4FO BepX2oj2wPHl/Ab6Ji6OcY8njBhTU/FA6oOk4CsPi71KZ/zGw3rphPj8mJqc4sUu Tcsy56jEbNmH5JUbC0YLY7TPLz2Ao5mNgTpuTIXq9dJELbgmeeFWs4fSecCGcFxd BwonfBmcudFaLzYGW9kn79a5YqVt4Q== =Gr+k -----END PGP SIGNATURE----- --Sig_/Y9EBDIQK=ST28l=SvLz0ygz--