unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: Andreas Schwab <schwab@suse.de>,
	Alistair Francis <alistair.francis@wdc.com>,
	"H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>,
	Joseph Myers <joseph@codesourcery.com>
Subject: [PATCH] Update HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.h
Date: Thu, 28 May 2020 07:50:42 -0700	[thread overview]
Message-ID: <CAMe9rOpYRvBnQe6EoEsNgSUXcCOqqYeCC0NbHiAm=-Ur4DgPRg@mail.gmail.com> (raw)
In-Reply-To: <87sgfk9lqw.fsf@oldenburg2.str.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]

On Thu, May 28, 2020 at 7:29 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Thu, May 28, 2020 at 5:58 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu via Libc-alpha:
> >>
> >> > diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
> >> > index af9d92f7f7..99b12995f1 100644
> >> > --- a/sysdeps/generic/hp-timing.h
> >> > +++ b/sysdeps/generic/hp-timing.h
> >> > @@ -24,6 +24,11 @@
> >> >  #include <stdint.h>
> >> >  #include <hp-timing-common.h>
> >> >
> >> > +#ifdef _ISOMAC
> >> > +# define __timespec64 timespec
> >> > +# define __clock_gettime64 clock_gettime
> >> > +#endif
> >> > +
> >> >  /* It should not be used for ld.so.  */
> >> >  #define HP_TIMING_INLINE     (0)
> >>
> >> To be honest, I would have expected different definitions of the timing
> >> macros.  This redirection looks a bit iffy for me for _ISOMAC.
> >
> > What do you have in mind?
>
> Something like this:
>
> /* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
>    nano-second accuracy, and for some architectues is implemented as
>    vDSO symbol.  */
> #ifdef _ISOMAC
> # define HP_TIMING_NOW(var) \
> ({                                                              \
>   struct timespec tv;                                           \
>   clock_gettime (CLOCK_MONOTONIC, &tv);                         \
>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);      \
> })
> #else
> # define HP_TIMING_NOW(var) \
> ({                                                              \
>   struct __timespec64 tv;                                       \
>   __clock_gettime64 (CLOCK_MONOTONIC, &tv);                     \
>   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);      \
> })
> #endif
>
> in sysdeps/generic/hp-timing.h.
>

Here is the updated patch.  OK for master?

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Update-HP_TIMING_NOW-for-_ISOMAC-in-sysdeps-generic-.patch --]
[-- Type: text/x-patch, Size: 2468 bytes --]

From f312c52fa80828ecdc473594e160ef2f5d2a00d7 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 23 May 2020 10:04:20 -0700
Subject: [PATCH] Update HP_TIMING_NOW for _ISOMAC in
 sysdeps/generic/hp-timing.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit e9698175b0b60407db1e89bcf29437ab224bca0b
Author: Lukasz Majewski <lukma@denx.de>
Date:   Mon Mar 16 08:31:41 2020 +0100

    y2038: Replace __clock_gettime with __clock_gettime64

breaks benchtests with sysdeps/generic/hp-timing.h:

In file included from ./bench-timing.h:23,
                 from ./bench-skeleton.c:25,
                 from
/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/benchtests/bench-rint.c:45:
./bench-skeleton.c: In function ‘main’:
../sysdeps/generic/hp-timing.h:37:23: error: storage size of ‘tv’ isn’t known
   37 |   struct __timespec64 tv;      \
      |                       ^~

Define HP_TIMING_NOW with clock_gettime in sysdeps/generic/hp-timing.h
if _ISOMAC is defined.  Don't define __clock_gettime in bench-timing.h
since it is no longer needed.
---
 benchtests/bench-timing.h   |  1 -
 sysdeps/generic/hp-timing.h | 11 ++++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h
index a0d6f82465..d0176fb76e 100644
--- a/benchtests/bench-timing.h
+++ b/benchtests/bench-timing.h
@@ -18,7 +18,6 @@
 
 #undef attribute_hidden
 #define attribute_hidden
-#define __clock_gettime __clock_gettime64
 #include <hp-timing.h>
 #include <stdint.h>
 
diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h
index af9d92f7f7..1960a71c62 100644
--- a/sysdeps/generic/hp-timing.h
+++ b/sysdeps/generic/hp-timing.h
@@ -32,11 +32,20 @@ typedef uint64_t hp_timing_t;
 /* The clock_gettime (CLOCK_MONOTONIC) has unspecified starting time,
    nano-second accuracy, and for some architectues is implemented as
    vDSO symbol.  */
-#define HP_TIMING_NOW(var) \
+#ifdef _ISOMAC
+# define HP_TIMING_NOW(var) \
+({								\
+  struct timespec tv;						\
+  clock_gettime (CLOCK_MONOTONIC, &tv);				\
+  (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
+})
+#else
+# define HP_TIMING_NOW(var) \
 ({								\
   struct __timespec64 tv;						\
   __clock_gettime64 (CLOCK_MONOTONIC, &tv);			\
   (var) = (tv.tv_nsec + UINT64_C(1000000000) * tv.tv_sec);	\
 })
+#endif
 
 #endif	/* hp-timing.h */
-- 
2.26.2


  reply	other threads:[~2020-05-28 14:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05 18:16 [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Lukasz Majewski
2020-05-19 19:51 ` Lukasz Majewski
2020-05-20 10:29 ` Andreas Schwab
2020-05-21  1:09 ` H.J. Lu via Libc-alpha
2020-05-21 10:24   ` Lukasz Majewski
2020-05-21 11:11     ` H.J. Lu via Libc-alpha
2020-05-23 20:32       ` [PATCH] Fix __clock_gettime64 for sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
2020-05-24  9:03         ` Lukasz Majewski
2020-05-24 11:39           ` H.J. Lu via Libc-alpha
2020-05-24 15:30             ` Lukasz Majewski
2020-05-24 16:13               ` H.J. Lu via Libc-alpha
2020-05-24 23:34                 ` V2 " H.J. Lu via Libc-alpha
2020-05-25 10:40                   ` Lukasz Majewski
2020-05-25 10:57   ` [PATCH v3] y2038: Replace __clock_gettime with __clock_gettime64 Andreas Schwab
2020-05-27 12:44     ` Florian Weimer via Libc-alpha
2020-05-27 12:47       ` H.J. Lu via Libc-alpha
2020-05-27 12:50         ` Florian Weimer via Libc-alpha
2020-05-28 12:28           ` [PATCH] Fix __clock_gettime64 with _ISOMAC in sysdeps/generic/hp-timing.h H.J. Lu via Libc-alpha
2020-05-28 12:58             ` Florian Weimer via Libc-alpha
2020-05-28 13:07               ` H.J. Lu via Libc-alpha
2020-05-28 14:28                 ` Florian Weimer via Libc-alpha
2020-05-28 14:50                   ` H.J. Lu via Libc-alpha [this message]
2020-06-05 16:26                     ` [PATCH] Update HP_TIMING_NOW for " Carlos O'Donell via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOpYRvBnQe6EoEsNgSUXcCOqqYeCC0NbHiAm=-Ur4DgPRg@mail.gmail.com' \
    --to=libc-alpha@sourceware.org \
    --cc=alistair.francis@wdc.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).