[PATCH] Update HP_TIMING_NOW for _ISOMAC in sysdeps/generic/hp-timing.h
Carlos O'Donell
carlos@redhat.com
Fri Jun 5 16:26:26 GMT 2020
On 5/28/20 10:50 AM, H.J. Lu via Libc-alpha wrote:
> 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?
OK for master.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> 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:
Yes, Patsy Griffin in testing for Fedora Rawhide has seen this for
aarch64, s390x, and armv7hl. Patsy is testing this patch now.
> 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.
OK.
> ---
> 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
OK.
> #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) \
OK.
> ({ \
> 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
>
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list