From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by sourceware.org (Postfix) with ESMTPS id CB2CB389245F for ; Wed, 19 May 2021 09:15:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CB2CB389245F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lukma@denx.de Received: from ktm (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id B1D6282CCD; Wed, 19 May 2021 11:15:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1621415711; bh=1s83RGFGRZNCa4myt08x9e16+3Cftl5TXcRYE3rfdKE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IbOElnsEbPW3iJyiDO0EenObJ4/6yvc+yphOIx7AdJ3SnTDPNDlvSL0INckaZAkox ab0b1HKtCm7Gc+gwdBuOSjO0m33MCZDbA3MukHH1XeglivxYmA10SXFeSW3wbDEezu HwVU+yFAGVvL7wR7G4Le5WQXM9GD3kHoX2uGWM2HuFbbk/dAxDQRBT/6FKI4OAUSg+ qtylRH2XdIxKi/3aAWUte/TeDpo6icwQgiqBTw02QlXELl4YGg5rD60UCkGvkn1xa6 xaD1XIuAmMQwQVWlW7Ei4Q6szQp/EAAAafa+V4nLpiY17UiaDgh8h0U0JZ7EDvFu7J Hx/+immqz1kmA== Date: Wed, 19 May 2021 11:15:10 +0200 From: Lukasz Majewski To: Adhemerval Zanella Cc: libc-alpha@sourceware.org, Carlos O'Donell Subject: Re: [PATCH v2 18/25] time: Add 64 bit time support for getdate Message-ID: <20210519111510.24a37a6d@ktm> In-Reply-To: <20210518205613.1487824-19-adhemerval.zanella@linaro.org> References: <20210518205613.1487824-1-adhemerval.zanella@linaro.org> <20210518205613.1487824-19-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_/AeIDvq._Y.M67ujiGNVOdcn"; protocol="application/pgp-signature" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 09:15:14 -0000 --Sig_/AeIDvq._Y.M67ujiGNVOdcn Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 18 May 2021 17:56:06 -0300 Adhemerval Zanella 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. Reviewed-by: Lukasz Majewski > --- > include/sys/stat.h | 2 +- > include/time.h | 12 ++++++++++-- > time/getdate.c | 22 ++++++++++------------ > time/tst-getdate.c | 14 ++++---------- > 4 files changed, 25 insertions(+), 25 deletions(-) >=20 > diff --git a/include/sys/stat.h b/include/sys/stat.h > index b4c9344628..13e777b3c7 100644 > --- a/include/sys/stat.h > +++ b/include/sys/stat.h > @@ -46,7 +46,7 @@ hidden_proto (__lstat64) > hidden_proto (__fstatat64) > # endif > =20 > -# if __TIMESIZE =3D=3D 64 > +# if __TIMESIZE =3D=3D 64 || defined NO_RTLD_HIDDEN > # define __stat64_time64 __stat64 > # define __fstat64_time64 __fstat64 > # define __lstat64_time64 __lstat64 > diff --git a/include/time.h b/include/time.h > index 4372bfbd96..980c6bd924 100644 > --- a/include/time.h > +++ b/include/time.h > @@ -283,8 +283,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. */ > @@ -509,6 +509,14 @@ time_now (void) > return ts.tv_sec; > } > =20 > +static inline __time64_t > +time64_now (void) > +{ > + struct __timespec64 ts; > + __clock_gettime64 (TIME_CLOCK_GETTIME_CLOCKID, &ts); > + return ts.tv_sec; > +} > + > #define NSEC_PER_SEC 1000000000L /* Nanoseconds per second. */ > #define USEC_PER_SEC 1000000L /* Microseconds per second. */ > #define NSEC_PER_USEC 1000L /* Nanoseconds per microsecond. > */ 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); 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_/AeIDvq._Y.M67ujiGNVOdcn Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmCk1x4ACgkQAR8vZIA0 zr3GDQgAxEi49q/k1nKotdxdQlKvw6NK2tktHiS6BvjE+7GjyHHS6QqwDx8cXGkh bdgQa5XHrd4pd92LkrI207iy3tULtHlCNbqZ0WiU22zNxl5pHaunxmeQ2N0LldzB 1R99r1a3Y99vDIZDJPTzrEsUq+ZEy8nhrFZLSHOeIRqXFAOhoEtBFQFKBkqKpun8 82l3amGJrMFMmXwc92NIyOdLAby0jv0rBwsm8rdExzFD2aEBdRbq/7XfrhI+YUtv dKx8CTX3a4MeTi2RGHHb7usgxvd5fF3OhQu84YIkx5p4Gx46mJOBtUELpM5PZg79 i6J4zkFI3+sZ31LIGF5mzHto+AKC1w== =p5F9 -----END PGP SIGNATURE----- --Sig_/AeIDvq._Y.M67ujiGNVOdcn--