bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug in xtime.h


From: Bruno Haible
Subject: Re: bug in xtime.h
Date: Sun, 22 Dec 2019 23:40:26 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

Hi Paul,

> > diff --git a/lib/xtime.h b/lib/xtime.h
> > index 77f1c30..5e0ae89 100644
> > --- a/lib/xtime.h
> > +++ b/lib/xtime.h
> > @@ -42,12 +42,13 @@ extern "C" {
> >  XTIME_INLINE xtime_t
> >  xtime_make (xtime_t s, long int ns)
> >  {
> > -  const long int giga = 1000 * 1000 * 1000;
> > -  s += ns / giga;
> > -  ns %= giga;
> >    return XTIME_PRECISION * s + ns;
> >  }
> 
> Akim put in that code in October 2018, but I can't see the need for it either.

It was surely needed before the simplification of commit
"gethrxtime: Assume that the compiler supports 'long long'."
that I did earlier today.

> >  xtime_sec (xtime_t t)
> >  {
> >    return (t < 0
> > -          ? (t + XTIME_PRECISION - 1) / XTIME_PRECISION - 1
> > +          ? (t + 1) / XTIME_PRECISION - 1
> >            : xtime_nonnegative_sec (t));
> 
> Thanks for pointing out the bug. We can simplify the fix further (and speed it
> up a bit on typical hosts). I installed the second attached patch to do that.

Thanks! I confirm that the new formula is correct.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]