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 2386B1F4C0 for ; Tue, 29 Oct 2019 12:01:21 +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=TnK3D PWYzg2h/yKiqEb36jvbfB71if9s9mTzi/zO/AmDfraXyzpbNDZZmOqM2dbkxqNwL 88rlY8tPYSiNwO6ZfoPSXBflu4KffjvIQ6efKBbpBbinSvgaoQcpcY+SOFQw2+FK F2zK6BofvnljvD5L+J9VI0yG/3jum7CGcDsmJQ= 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=f0M25G/Vscu 6NxyllsJoHhBqJcE=; b=ARO8CksxcIb22KWAO3qnUFsIbAQLZ4bQFAEdIgOclkd vu/UkynYZBoptwmy71FC1BwAQkiqNjz216NPVmdDsx+GC/PEJ6Edqwr2sZ7W0XGk y/+yZQ6k7lXnXFnrePMAadXn0ZTMk3wla69wSotwlWw7zE3FH2CZl2bgH4KkEEWE = Received: (qmail 73052 invoked by alias); 29 Oct 2019 12:01:18 -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 72260 invoked by uid 89); 29 Oct 2019 12:01:17 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-out.m-online.net Date: Tue, 29 Oct 2019 13:00:57 +0100 From: Lukasz Majewski To: Alistair Francis , alistair23@gmail.com Cc: libc-alpha@sourceware.org, arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, Zack Weinberg , Joseph Myers Subject: Re: [RFC v5 05/21] sysdeps/clock_gettime: Use clock_gettime64 if avaliable Message-ID: <20191029130057.495d754d@jawa> In-Reply-To: <513e8d86c5d7a44fcf269f9c38883222fbbc168d.1567097252.git.alistair.francis@wdc.com> References: <513e8d86c5d7a44fcf269f9c38883222fbbc168d.1567097252.git.alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/fXCGTgV8k.aZhgpqLuW9307"; protocol="application/pgp-signature" --Sig_/fXCGTgV8k.aZhgpqLuW9307 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Alistair, > Signed-off-by: Alistair Francis >=20 > * sysdeps/unix/sysv/linux/clock_gettime.c: Use > clock_gettime64 if avaliable. --- > include/time.h | 1 + > sysdeps/unix/sysv/linux/clock_gettime.c | 48 > ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 > deletion(-) >=20 > diff --git a/include/time.h b/include/time.h > index 6d81f91384b..1e33f34e1f6 100644 > --- a/include/time.h > +++ b/include/time.h > @@ -177,6 +177,7 @@ extern double __difftime (time_t time1, time_t > time0); #define __clock_nanosleep_time64 __clock_nanosleep > #define __nanosleep_time64 __nanosleep > #define __nanosleep_nocancel_time64 __nanosleep_nocancel > +#define __clock_gettime64 __clock_gettime > #endif > =20 > /* Use in the clock_* functions. Size of the field representing the > diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c > b/sysdeps/unix/sysv/linux/clock_gettime.c index > 5fc47fb7dc7..ea98af9bf1a 100644 --- > a/sysdeps/unix/sysv/linux/clock_gettime.c +++ > b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -28,9 +28,55 @@ > =20 > /* Get current value of CLOCK and store it in TP. */ > int > +__clock_gettime64 (clockid_t clock_id, struct timespec *tp) > +{ > +#ifdef __ASSUME_TIME64_SYSCALLS > +# ifndef __NR_clock_gettime64 > +# define __NR_clock_gettime64 __NR_clock_gettime > +# endif > + return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); > +#else > + int ret; > +# ifdef __NR_clock_gettime64 > + ret =3D INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); > + > + if (ret =3D=3D 0 || errno !=3D ENOSYS) > + return ret; > +# endif /* __NR_clock_gettime64 */ > + struct timespec tp32; > + > + ret =3D INLINE_VSYSCALL (clock_gettime, 2, clock_id, &tp32); > + > + if (ret =3D=3D 0 || errno !=3D ENOSYS) > + valid_timespec_to_timespec64(tp32, tp); > + > + return ret; > +#endif /* __ASSUME_TIME64_SYSCALLS */ > +} > + > +#if __TIMESIZE !=3D 64 > +int > __clock_gettime (clockid_t clock_id, struct timespec *tp) > { > - return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); > + int ret; > + struct __timespec64 tp64; > + > + ret =3D __clock_gettime64 (clock_id, &tp64); > + > + if (ret =3D=3D 0 || errno !=3D ENOSYS) > + { > + if (! in_time_t_range (tp64.tv_sec)) > + { > + __set_errno (EOVERFLOW); > + return -1; > + } > + > + valid_timespec64_to_timespec(&tp64, tp); > + > + return ret; > + } > } > +#endif > + > weak_alias (__clock_gettime, clock_gettime) > libc_hidden_def (__clock_gettime) In your github repository - I've noticed the updated version of patch providing __clock_gettime64 [1] conversion. Do you plan to re-send this patch soon? Please find some comments regarding this particular patch: 1. Please add following code instead the line 182 [2] (@include/time.h): +#if __TIMESIZE =3D=3D 64 +# define __clock_gettime64 __clock_gettime +#else +extern int __clock_gettime64 (clockid_t clock_id, + struct __timespec64 *tp); +libc_hidden_proto (__clock_gettime64); +#endif 2. The line 44 (@sysv/linux/clock_gettime.c) is a bit tricky I've grepped the recent kernel (-master branch) tag: v5.4-rc5 with git grep -n "vdso_clock_gettime64" And the __vdso_clock_gettime64 is available for mips, aarch64 and x86 (plain ARM 32 bits is missing though). Considering the above - the vDSO may be a bit tricky for some archs as the 'clock_gettime64' "name" argument to INLINE_VSYSCALL () macro is then extended to __vdso_##name (@ sysdeps/unix/sysv/linux/sysdep-vdso.h) It seems like one would need a global (i.e. at clock_gettime.c file) __vdso_clock_gettime64 fallback. IMHO the condition '&& defined HAVE_CLOCK_GETTIME64_VSYSCALL' in Line 44 [3] could be removed. 3. Line 50 - replace tp32 with ts32 (as we define structure, not pointer). 4. Line 54 - IMHO the 'if (ret =3D=3D 0 || errno !=3D ENOSYS)' shall be replaced with 'if (! ret && tp)'=20 (as we reference *tp, which may be NULL). The same situation is in Line 70. Links: [1] - https://github.com/alistair23/glibc/commit/b7682ca51f6d7ea702eeb9066c7710f5= a40f6590 [2] - https://github.com/alistair23/glibc/commit/b7682ca51f6d7ea702eeb9066c7710f5= a40f6590#diff-5b9f1c6457e0e10079f657f283c19861R182 [3] - https://github.com/alistair23/glibc/commit/b7682ca51f6d7ea702eeb9066c7710f5= a40f6590#diff-cb7e59ab5b305ba007394bee79cdd6d6R44 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_/fXCGTgV8k.aZhgpqLuW9307 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl24KfkACgkQAR8vZIA0 zr3ymwf/fmCrgbp1+h5li1IIxY0FU7CpBByd8uLVD3lNAblaEDohZmtNmmRA1FWN qgBdK+KuhYe3ixXeDQA5vTH4Ldsu25KsAe0TMIEVJq4I4NskGINtiX6GobHQSjGw MibHTWWPzWi25kdD6P7iddKefM3qh003i+QoTeLfvh3cJivQWU391czunJovUr35 RXbyk75BXKEB5wceTrXceZJLe8SCmP7jRTgEOwKyU7aj9ev1DC5h4XBtlptlDvf6 /yGsVehmXa0AFTlMhPfxv11vlE7cygxc/blZWwmi7Y63aMBLsuPliFWJtcCy/E9D rWAj2+TNbGlfKSltXzuY+5eAuO053Q== =5iRX -----END PGP SIGNATURE----- --Sig_/fXCGTgV8k.aZhgpqLuW9307--