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-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,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 (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 dcvr.yhbt.net (Postfix) with ESMTPS id 2E9BF1F461 for ; Wed, 17 Jul 2019 12:23:03 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=FiXNO ySSpfEYOaTeebYj0OIU5iBL4jD6DIpfxxuTrbkDhdWN3rXCmh67PTQlyUUKJFnKs ssPqHZzUTPuMddceZnlt2CmQUXQtyAaOXF+BZEfQc3RI9BHVmB9rwXLspxnEQXap aOHOSn4KKbOk27aANabUzjZKbdTK63bgFiOWeM= 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:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=p1vy89rfN3s YAEyEpFe0zQ2CjEM=; b=QWQH+OFwlYA1IegkkSr23NPa/3QdjjboO4HjjYQOey4 co3tjuDj206cy7gicLZy4oaQ2sC0jsYapT3PaysGvC704D5GbrYR4E4gd/gLOLbt oUZH97RCmqlLkfjMDwszVrrzEWupwj3C6ibKMSs/RaidoBbyRtkzCT4lOvF3t1fY = Received: (qmail 34285 invoked by alias); 17 Jul 2019 12:23:01 -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 Received: (qmail 34276 invoked by uid 89); 17 Jul 2019 12:23:00 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-out.m-online.net Date: Wed, 17 Jul 2019 14:22:47 +0200 From: Lukasz Majewski To: Alistair Francis Cc: libc-alpha@sourceware.org, arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, alistair23@gmail.com, Wolfgang Denk Subject: Re: [RFC v3 05/23] sysdeps/timespec_get: Use clock_gettime64 if avaliable Message-ID: <20190717142247.7d9deb9c@jawa> In-Reply-To: <0d116a8faab58db1952a256c6cb75e7b0f9af444.1563321715.git.alistair.francis@wdc.com> References: <0d116a8faab58db1952a256c6cb75e7b0f9af444.1563321715.git.alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/ko+akPaQTQ2xcru=A2aBAaR"; protocol="application/pgp-signature" --Sig_/ko+akPaQTQ2xcru=A2aBAaR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Alistair, > This will break other 32-bit targets >=20 > Signed-off-by: Alistair Francis > --- > sysdeps/unix/sysv/linux/timespec_get.c | 37 > +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 > deletion(-) >=20 > diff --git a/sysdeps/unix/sysv/linux/timespec_get.c > b/sysdeps/unix/sysv/linux/timespec_get.c index 52080ddf08..78fa2aba1b > 100644 --- a/sysdeps/unix/sysv/linux/timespec_get.c > +++ b/sysdeps/unix/sysv/linux/timespec_get.c > @@ -24,6 +24,36 @@ > #endif > #include > =20 > + > +#if __WORDSIZE =3D=3D 32 > +int > +__timespec_get (struct timespec *ts, int base) > +{ > + int ret; > + > +#ifdef __NR_clock_gettime64 > + struct __timespec64 ts64; > + ret =3D INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, > &ts64); + > + ts->tv_sec =3D ts64.tv_sec; > + ts->tv_nsec =3D ts64.tv_nsec; > + You may consider using following helper functions (which are the part of Y2038 support): [1] > + if (! in_time_t_range (ts->tv_sec)) > + { > + __set_errno (EOVERFLOW); > + return -1; > + } > +#endif > + > +#ifndef __ASSUME_TIME64_SYSCALLS > + ret =3D INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, > ts); +#endif > + > + return ret; > +} > + > +#else > + > /* Set TS to calendar time based in time base BASE. */ > int > timespec_get (struct timespec *ts, int base) > @@ -33,9 +63,13 @@ timespec_get (struct timespec *ts, int base) > int res; > INTERNAL_SYSCALL_DECL (err); > case TIME_UTC: > +#if __WORDSIZE =3D=3D 32 > + res =3D __timespec_get (*ts, base); > +#else > res =3D INTERNAL_VSYSCALL (clock_gettime, err, 2, > CLOCK_REALTIME, ts); +#endif > if (INTERNAL_SYSCALL_ERROR_P (res, err)) > - return 0; > + return 0; > break; > =20 > default: > @@ -44,3 +78,4 @@ timespec_get (struct timespec *ts, int base) > =20 > return base; > } > +#endif Note: [1] - https://github.com/lmajewski/y2038_glibc/commit/12ac380db090219aac4ed= 8b0ef179b9fcc4c296e 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_/ko+akPaQTQ2xcru=A2aBAaR Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl0vExcACgkQAR8vZIA0 zr0rNwf/Tm/LlEvaWvUYYO7BsXMiWksmYCah/AQ/BXoT8wtIyI9g1qCwMUvA8fXg vESkPbj55ullI2Fwf9+hT7a/27rWy9Vwa5vfjNynBcUu3IqYNMlk/U5o+jwzaWMn MRh+jRLXwopaar/5fUBG1YvwlNuhCuSsE+iyTU/LROfnQ0aTG74XqY3Rm6Y9SLUP KasfUOiCHHgrHI1cnZQKhAwQqhquNwgJCBHxSzEw8oBlpROVgGPHZbZkJxKliVMc 2lTUEL2YWesQB5M0NgPlDw3uFu/HEG4kn1JQ0ervFfzdZnQ2lhbg9NvuxLCuZ0lZ VA99udbqniZRsRIE7zgl8UgWEqzuhw== =NaOZ -----END PGP SIGNATURE----- --Sig_/ko+akPaQTQ2xcru=A2aBAaR--