]> sourceware.org Git - newlib-cygwin.git/commit
Ensure that all values of ns, us and ms work
authorimp <imp@FreeBSD.org>
Tue, 20 Nov 2018 07:11:23 +0000 (07:11 +0000)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 4 Dec 2018 06:39:15 +0000 (07:39 +0100)
commitbe517bd298641a4148f7b17dfc4528332154b459
tree023ccb11e3157e9b18fd8ad2ad7b71e82511b96f
parent7bf8fc0987838fc435e251183410ed16bfb36c95
Ensure that all values of ns, us and ms work

for {n,u,m}stosbt

Integer overflows and wrong constants limited the accuracy of these
functions and created situatiosn where sbttoXs(Xstosbt(Y)) != Y. This
was especailly true in the ns case where we had millions of values
that were wrong.

Instead, used fixed constants because there's no way to say ceil(X)
for integer math. Document what these crazy constants are.

Also, use a shift one fewer left to avoid integer overflow causing
incorrect results, and adjust the equasion accordingly. Document this.

Allow times >= 1s to be well defined for these conversion functions
(at least the Xstosbt). There's too many users in the tree that they
work for >= 1s.

This fixes a failure on boot to program firmware on the mlx4
NIC. There was a msleep(1000) in the code. Prior to my recent rounding
changes, msleep(1000) worked, but msleep(1001) did not because the old
code rounded to just below 2^64 and the new code rounds to just above
it (overflowing, causing the msleep(1000) to really sleep 1ms).

A test program to test all cases will be committed shortly. The test
exaustively tries every value (thanks to bde for the test).

Sponsored by: Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D18051
newlib/libc/include/sys/time.h
This page took 0.031682 seconds and 5 git commands to generate.