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=-2.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,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 179481F461 for ; Wed, 3 Jul 2019 23:52:24 +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:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=O4h8 NIMxk17Gp2rDn+oH1Rf5ks+t5cTqsJUp1gwJZCZb5WWpmozxWHXMbCmu+6GjoXJ9 n31OQ4cPgAFuTeYvccDRMx6+2DdYvsKHwI0voydbnnOlCnVcMUmuRWSnbhKVST80 mAWIHzjmOBHmeOOhi5OEk2tCEeN0anrS7wzfJ+M= 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:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; s=default; bh=bq5N+/vinG Jom8VX2MbkdMVT7Ec=; b=uwCvhVA2nfx/i9Na0aShiehOR1Uf4OKJ/6PBezx6tX xsg23M5Y2V0uUQaafhS9ruuEjXvsrfuBfiqT1H3rkVVDlLiGxxIbW0lHwOohdrXK +1QReMpekxZpMAPWInd78WlzyFo02oNIKxpGWH9D9IqM6kbrKpIXUCYUm4905NCG Q= Received: (qmail 59122 invoked by alias); 3 Jul 2019 23:52:21 -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 59107 invoked by uid 89); 3 Jul 2019 23:52:21 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-lj1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wshaO3+hjBdJJRPxSfSsLZ0VPyLQRKyWfwt7VzM2KNk=; b=BVwJP2L654RZxR3vdVuEVJbJdGa63lC0k2eCPzrf8qJYEfbRxl5TwAdBgaVNyeo3ho /g/YeaMCwECz8PIEAC1H7ZY09W6iE41VF4X2gWJq44TyOXaxzF5LWLCm1d1DeeKKGR5o K7daUwo+SB3jzw9kML91TA25yDGtdsYfCzcrbY5Uc0ervcUuQMxQAx4xc1pZvrJSaDMg KK4/CTEEQeA1s/grcLEbyXomYKrGezm3vGnedOTGb4pK5wgawHiznuZ7Qr5N6XqlaiK1 7LWMyL5h/Y4GrOkxilMGjBMHhZpd94BJejrBTfwmKNom2UhQvD5pzFv40WxoN+dQhcN0 7qdQ== MIME-Version: 1.0 References: <23ad951b-63f7-7c00-0dde-57b05b8039dc@linaro.org> In-Reply-To: <23ad951b-63f7-7c00-0dde-57b05b8039dc@linaro.org> From: Alistair Francis Date: Wed, 3 Jul 2019 16:49:12 -0700 Message-ID: Subject: Re: [RFC v2 07/20] sysdeps/gettimeofday: Use clock_gettime64 if avaliable To: Adhemerval Zanella Cc: Alistair Francis , GNU C Library , Arnd Bergmann , Florian Weimer , Palmer Dabbelt , macro@wdc.com, Zong Li , Zong Li Content-Type: text/plain; charset="UTF-8" On Thu, Jun 27, 2019 at 6:15 AM Adhemerval Zanella wrote: > > > > On 24/06/2019 21:09, Alistair Francis wrote: > > Not all architectures support the obsolete gettimeofday so use the > > newer clock_gettime64 syscall if it is avaliable. This fixes RV32 > > build issues. > > > > Signed-off-by: Alistair Francis > > --- > > ChangeLog | 1 + > > sysdeps/unix/sysv/linux/gettimeofday.c | 28 ++++++++++++++++++++++++++ > > 2 files changed, 29 insertions(+) > > > > diff --git a/ChangeLog b/ChangeLog > > index a700783ef3..f1c7acb6ab 100644 > > --- a/ChangeLog > > +++ b/ChangeLog > > @@ -4,6 +4,7 @@ > > * sysdeps/unix/sysv/linux/nanosleep.c: Likewise. > > * sysdeps/unix/sysv/linux/nanosleep_nocancel.c: Likewise. > > * sysdeps/unix/sysv/linux/lowlevellock-futex.h: Use __NR_futex_time64 if we don't have __NR_futex. > > + * sysdeps/unix/sysv/linux/gettimeofday.c: Use clock_gettime64 syscall for gettimeofday. > > > > 2019-06-20 Dmitry V. Levin > > Florian Weimer > > diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c > > index a74f03825a..3d2b943123 100644 > > --- a/sysdeps/unix/sysv/linux/gettimeofday.c > > +++ b/sysdeps/unix/sysv/linux/gettimeofday.c > > @@ -32,7 +32,35 @@ > > int > > __gettimeofday (struct timeval *tv, struct timezone *tz) > > { > > +#ifdef __ASSUME_TIME64_SYSCALLS > > + int ret; > > + struct timespec now; > > + > > + ret = INLINE_VSYSCALL (clock_gettime64, 2, CLOCK_REALTIME, > > + &now); > > + > > + /* Convert from timespec to timeval */ > > + tv->tv_sec = now.tv_sec; > > + tv->tv_usec = now.tv_nsec / 1000; > > + > > + return ret; > > +#else > > +# ifdef __NR_clock_gettime64 > > + long int ret; > > + struct timespec now; > > + > > + ret = INLINE_VSYSCALL (clock_gettime64, 2, CLOCK_REALTIME, > > + &now); > > + > > + /* Convert from timespec to timeval */ > > + tv->tv_sec = now.tv_sec; > > + tv->tv_usec = now.tv_nsec / 1000; > > + > > + if (ret == 0 || errno != ENOSYS) > > + return ret; > > +# endif > > return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); > > +#endif > > } > > libc_hidden_def (__gettimeofday) > > weak_alias (__gettimeofday, gettimeofday) > > > > Wouldn't be simpler to just call __clock_gettime instead: > > -- > __gettimeofday (struct timeval *tv, struct timezone *tz) > { > if (tv == NULL) > return 0; > > struct timespec ts; > __clock_gettime (CLOCK_REALTIME, &ts); > tv->tv_sec = ts.tv_sec; > tv->tv_usec = (__suseconds_t)ts.tv_nsec / 1000; > return 0; > } > -- > > From the patch 'linux: Provide __clock_settime64 implementation' internal > include/time.h will redefine __clock_gettime to __clock_gettime64 if the > case. The version of this patch that I have only implements __clock_settime and not __clock_gettime. Alistair