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.0 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 E5BAD1F461 for ; Fri, 19 Jul 2019 22:29:37 +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=jMdN d2Uf13FbxP3rI/kOoyNVYAH96gRD/hzYzbk1fxQjAqc6kg198r+lt/OYQ1nWEOfg mWprZyVP2moM3Dlvih2Nulrrj9wjDYj35aCGAN5rzhu8dHw9/oVvzPjvPqgLWWuN GLo0Hik1+uPyBBiyC2fp+8R5zaAV6VPYgxM7W1g= 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=CJqmZ2amD8 ZzxgWgEPaI4UM5OLY=; b=vS9RbxlkLNt0FvEJ4effGBijLqDfpNurch6b1gZx6c yPGTDXP2T2OkHy7pFKveD97uBKkuA+4Ar+vGHkMsFJXVswGmZ76HVaph6tVNyTR0 /SkCOrTLz0/hdrI+oeuz2dJkx90BCC/egxYdIykBPyi7VJg45n6yom/TwnxlqaHQ I= Received: (qmail 102763 invoked by alias); 19 Jul 2019 22:29:35 -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 102755 invoked by uid 89); 19 Jul 2019 22:29:35 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-io1-f68.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=/Qf6noZwXQhSClSQSTkqKiYy8jjMkeYzirt0GIBgzqA=; b=OxrCP3COzxOqYV6wUzTPjGJ4vJMEXoiGsJqoihupnayXYRw+qMvt4bByJvAJrN/le8 3TtjqfBROmSL9D1RSzFnZlpWpXOYoq/Q2ArER1K6hJHFRDcMqW/hZBi44VLZvaal7Oxn 7N4vZl2dfR7O6iEL/Cqh53U7wxUWF1vyflAcK3ApCff0aIMB39YTk7/fC4hs6XOMuKYq PnJnpEv/bYDiNbBfGsVdHwfKv2hyp6FgILYsbtpt0G/heoui1juoEYsCWe4fhY7Ndvau ey4a7QOMNqt9MvQJuLphnEt5U2RTwsWESSSuQL9EnCxKNcA2nWkWmI3FS+zfOuXNfnxd gshg== MIME-Version: 1.0 References: <20190717144305.3eda6678@jawa> In-Reply-To: <20190717144305.3eda6678@jawa> From: Alistair Francis Date: Fri, 19 Jul 2019 15:26:09 -0700 Message-ID: Subject: Re: [RFC v3 02/23] sysdeps/gettimeofday: Use clock_gettime64 if avaliable To: Lukasz Majewski Cc: Alistair Francis , GNU C Library , Arnd Bergmann , Adhemerval Zanella , Palmer Dabbelt , macro@wdc.com, Zong Li , Wolfgang Denk , Joseph Myers , Florian Weimer Content-Type: text/plain; charset="UTF-8" On Wed, Jul 17, 2019 at 5:43 AM Lukasz Majewski wrote: > > Hi Alistair, > > > 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 477b9b49b3..9ca390a9c3 100644 > > --- a/ChangeLog > > +++ b/ChangeLog > > @@ -1028,6 +1028,7 @@ > > * nptl/thrd_sleep.c: Use clock_nanosleep_time64 instead of > > nanosleep. > > * sysdeps/unix/sysv/linux/nanosleep.c: Likewise. > > * sysdeps/unix/sysv/linux/nanosleep_nocancel.c: Likewise. > > + * 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..151b1e606c > > 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 > > I'm not the glibc expert but according to [1], the > __ASSUME_TIME64_SYSCALLS will be defined also for __WORDSIZE = 64 archs. > > This means that this code will be executed on x86_64 and return with an > ENOTSUPP error as those archs shall not define clock_gettime64 and > will just use the clock_settime. > > Please consider re-using pattern from clock_settime conversion [2]. Yep, good point. I have updated this to better match what is being discussed on the list and your patches. Alistair > > > + int ret; > > + struct __timespec64 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 __timespec64 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) > > Note: > > [1] - > https://github.com/lmajewski/y2038_glibc/commit/1fdbc6002101a78a8a6a076bbb642b3082c2225d > > [2] - > https://github.com/lmajewski/y2038_glibc/commit/69f842a8519ca13ed11fab0ff1bcc6fa1a524192 > > 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