[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bug in xtime.h
From: |
Paul Eggert |
Subject: |
Re: bug in xtime.h |
Date: |
Sun, 22 Dec 2019 12:48:23 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
On 12/22/19 3:31 AM, Bruno Haible wrote:
> 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. I
installed the first attached patch to revert that, and am cc'ing this to Akim to
see why it might be needed. If it is needed, we'll need to complicate the
overflow suppression a bit.
> 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.
0001-gethrxtime-remove-incorrect-overflow-detection.patch
Description: Text Data
0002-gethrxtime-fix-rounding-bug-with-negative-args.patch
Description: Text Data
- bug in xtime.h, Bruno Haible, 2019/12/22
- Re: bug in xtime.h,
Paul Eggert <=
- Re: bug in xtime.h, Bruno Haible, 2019/12/22
- Re: bug in xtime.h, Bruno Haible, 2019/12/23
- Re: bug in xtime.h, Paul Eggert, 2019/12/23
- Re: bug in xtime.h, Bruno Haible, 2019/12/23
- Re: bug in xtime.h, Paul Eggert, 2019/12/24
- Re: bug in xtime.h, Bruno Haible, 2019/12/24
- Re: bug in xtime.h, Paul Eggert, 2019/12/24
Re: bug in xtime.h, Akim Demaille, 2019/12/25