Re: [chrony-dev] [PATCH] MacOS X drift removal |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
On Thu, Jul 23, 2015 at 07:34:42PM +1200, Bryan Christianson wrote:
> I thought about the frequency shift and realised its totally wrong. The problem is coming from the way the MacOS driver is handling rounding erros. I've discarded using the kernel tickadj and just use rounding derived from conversion of adjust_required to timeval.
Ok, great. Can you send that as a separate bugfix commit?
> Incidentally. I think there may be a bug in UTI_DoubleToTimeval()
>
> the line:
> frac_part = (long)(0.5 + 1.0e6 * (a - (double)(int_part)));
>
> won't this round towards 0 if the if the double is < 0 ?
>
> e.g -1.75 -> -1.0
Right. The rounding is wrong for negative values.
> Probably better to use round() which will round in the correct direction
I'm not sure how portable round() is. I think we at least officially
still don't require C99, but I suspect there may already be some code
that depends on it.
There are few other places in the code which do rounding, but they
currently all use a condition to select between +0.5 and -0.5 before
converting to an integer.
> I don't know what the implications of changing UTI_DoubleToTimeval() are so I'm not proposing to change it, but it looks odd.
I think it should be fixed, please feel free to send a patch :).
--
Miroslav Lichvar
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.