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 B57141F461 for ; Wed, 17 Jul 2019 12:37:34 +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=C7yVm 6nOtNf187L2agRHpRjsTuhL+Khgnw0Aaz3As7bgT3gZ7J2kPaop4Wu3WVngTowWh CRU+c13bKScF04gqDnT3XEXnmIrTiGzdA/w/yioz14sYZvOwQHZWTrEM2l94FrOD XQrbrOboYqoUSCO9DBzb++s51ITBIh9jtgX7Q4= 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=hOBDTI+Z1PB iRcr5MiD1ANsifLE=; b=xN+uAuDMqCwHWK/nQMzRnDVldflU2YOikVT7eBLInOT vdLDhbjeh5ApwAVLzucJh66dKArkvwhbgnFZsCwb4jEZSKqdW0bBh43RytBCFqWV pXHdrsd89Js3r3XRwj1dbHojKluhw1Dm17UBH7wcrMIHKrlVo5+pSjBwjxLiPDeY = Received: (qmail 62819 invoked by alias); 17 Jul 2019 12:37:32 -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 62811 invoked by uid 89); 17 Jul 2019 12:37:32 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-out.m-online.net Date: Wed, 17 Jul 2019 14:37:20 +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 , Joseph Myers Subject: Re: [RFC v3 04/23] sysdeps/clock_gettime: Use clock_gettime64 if avaliable Message-ID: <20190717143720.179fcb2f@jawa> In-Reply-To: <1f589e5a3fcaa4c103bc83169fffcdea9e1a6b2d.1563321715.git.alistair.francis@wdc.com> References: <1f589e5a3fcaa4c103bc83169fffcdea9e1a6b2d.1563321715.git.alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/r/hElK7kB9seuLkxrHhZ4hP"; protocol="application/pgp-signature" --Sig_/r/hElK7kB9seuLkxrHhZ4hP Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Alistair, > Signed-off-by: Alistair Francis > --- > nptl/pthread_mutex_timedlock.c | 7 ++++++ > sysdeps/unix/sysv/linux/clock_gettime.c | 30 > +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) >=20 > diff --git a/nptl/pthread_mutex_timedlock.c > b/nptl/pthread_mutex_timedlock.c index 52c258e33d..8d9cae7d87 100644 > --- a/nptl/pthread_mutex_timedlock.c > +++ b/nptl/pthread_mutex_timedlock.c > @@ -402,10 +402,17 @@ __pthread_mutex_clocklock_common > (pthread_mutex_t *mutex, /* Delay the thread until the timeout is > reached. Then return ETIMEDOUT. */ > struct timespec reltime; > +#ifdef __NR_clock_gettime64 > + struct __timespec64 now; > + > + INTERNAL_SYSCALL (clock_gettime64, __err, 2, > CLOCK_REALTIME, > + &now); > +#else > struct timespec now; > =20 > INTERNAL_SYSCALL (clock_gettime, __err, 2, > clockid, &now); > +#endif > reltime.tv_sec =3D abstime->tv_sec - now.tv_sec; > reltime.tv_nsec =3D abstime->tv_nsec - now.tv_nsec; > if (reltime.tv_nsec < 0) > diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c > b/sysdeps/unix/sysv/linux/clock_gettime.c index > 5fc47fb7dc..4832069c34 100644 --- > a/sysdeps/unix/sysv/linux/clock_gettime.c +++ > b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -27,10 +27,40 @@ > #include > =20 > /* Get current value of CLOCK and store it in TP. */ > + > +#if __WORDSIZE =3D=3D 32 > +int > +__clock_gettime (clockid_t clock_id, struct timespec *tp) > +{ > + int ret; > + > +#ifdef __NR_clock_gettime64 > + struct __timespec64 tp64; > + ret =3D INLINE_VSYSCALL (clock_gettime64, 2, clock_id, &tp64); > + > + tp->tv_sec =3D tp64.tv_sec; > + tp->tv_nsec =3D tp64.tv_nsec; > + > + if (! in_time_t_range (tp->tv_sec)) > + { > + __set_errno (EOVERFLOW); > + return -1; > + } > +#endif > + > +#ifndef __ASSUME_TIME64_SYSCALLS I think that the context of using the __ASSUME_TIME64_SYSCALLS doesn't comply with the semantics which was proposed in its introduction patch [1]. In short: This define means that the system is supporting 64 bit time, not that it has (can use) introduced in Linux 5.1 64 bit time related syscalls (i.e. clock_gettime64, clock_settime64, clock_nanosleep64). Maybe you could consider using the "conversion" approach as proposed for __clock_settime64 conversion [2]? The version in [2] is more "developer/validator" friendly (as suggested by Arnd) as it uses for __TIMESIZE !=3D 64 archs the 32 bit clock_settime. The version from [3] is the one recommended by Joseph (which does the 32 to 64 bit conversion and calls clock_settime64). The full code for a reference with clock_settime conversion and Y2038 support [4]. > + ret =3D INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); > +#endif > + > + return ret; > +} > +#else > int > __clock_gettime (clockid_t clock_id, struct timespec *tp) > { > return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); > } > +#endif > + > weak_alias (__clock_gettime, clock_gettime) > libc_hidden_def (__clock_gettime) Note: [1] - https://github.com/lmajewski/y2038_glibc/commit/1fdbc6002101a78a8a6a076bbb6= 42b3082c2225d [2] - https://github.com/lmajewski/y2038_glibc/commit/69f842a8519ca13ed11fab0ff1b= cc6fa1a524192 [3] - https://github.com/lmajewski/y2038_glibc/commit/fa0f5ff6c942beca383daeff3d4= 8829829ace5b1 [4] - https://github.com/lmajewski/y2038_glibc/commits/Y2038-2.29-glibc-__clock-i= nternal-struct-timespec-v6 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_/r/hElK7kB9seuLkxrHhZ4hP Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl0vFoAACgkQAR8vZIA0 zr1kUgf6A8NdUfRkwyykVQtelf4dSjThXd+m/9S4z6cvS1bRPZ+ePPWp1TV7hGmL L8qQYFAIu152d95Kzu7pHVR+Jqe9Hn38s44exSHAo22ehQX8Pkonf6PzEq8FtDpo Vvh5PVi5e7+QI4eytByS0UkEs5HFl4PRlaHUujDSKsgwLxa16QRYbIhepgZdAcUm 8+AQBsDkPirkxuqL1T/rXnlnkbSK6o8ip5AO/8cQPLmWnY/+CWrLBfQ3V1yvhs7I Ex7JgZX6Omi0MVbSYBSyW3/Q2piB0JHLHSK/b4TRKBmrQYZKMeucENRnTCFLt2xU 4TBAYg5bTmrcE68eQ0nHo1me1SIiVQ== =k6mZ -----END PGP SIGNATURE----- --Sig_/r/hElK7kB9seuLkxrHhZ4hP--