[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH glic] hurd: Add CLOCK_MONOTONIC case in clock_gettime()
From: |
Samuel Thibault |
Subject: |
Re: [RFC PATCH glic] hurd: Add CLOCK_MONOTONIC case in clock_gettime() |
Date: |
Wed, 1 Jan 2025 22:42:50 +0100 |
Zhaoming Luo, le mer. 01 janv. 2025 18:04:16 +0800, a ecrit:
> On 1/1/25 5:51 PM, Zhaoming Luo wrote:
> > ---
> > sysdeps/mach/clock_gettime.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> The website[0] mentions making `gettimeofday()` use the CLOCK_MONOTONIC.
Mmm, that website comment actually looks bogus: one can't assume that
CLOCK_MONOTONIC provides something that can be used to display actuall
wallclock time, which is subject to jumps.
I have dropped it.
> Does that refer to this one[1]?
>
> [0]: https://darnassus.sceen.net/~hurd-web/open_issues/clock_gettime/
> [1]:
> https://sourceware.org/git?p=glibc.git;a=blob;f=time/gettimeofday.c;h=bf92756cae906b9afff44d302800babbb1413b4a;hb=HEAD#l26
> >
> > diff --git a/sysdeps/mach/clock_gettime.c b/sysdeps/mach/clock_gettime.c
> > index 6fffad39f5..22faf85730 100644
> > --- a/sysdeps/mach/clock_gettime.c
> > +++ b/sysdeps/mach/clock_gettime.c
> > @@ -31,6 +31,18 @@ __clock_gettime (clockid_t clock_id, struct timespec *ts)
> > switch (clock_id) {
> > + case CLOCK_MONOTONIC:
> > + {
> > + /* __host_get_uptime64 can only fail if passed an invalid host_t.
> > + __mach_host_self could theoretically fail (producing an
> > + invalid host_t) due to resource exhaustion, but we assume
> > + this will never happen. */
> > + time_value64_t tv;
> > + __host_get_uptime64 (__mach_host_self (), &tv);
> > + TIME_VALUE64_TO_TIMESPEC (&tv, ts);
> > + return 0;
> > + }
> > +
> > case CLOCK_REALTIME:
> > {
> > /* __host_get_time can only fail if passed an invalid host_t.