]> sourceware.org Git - newlib-cygwin.git/commit
Add inline functions to convert between sbintime_t
authorian <ian@FreeBSD.org>
Sat, 29 Jul 2017 17:00:23 +0000 (17:00 +0000)
committerSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 4 Dec 2018 06:29:51 +0000 (07:29 +0100)
commit3c3c17500c568785bc19beeae137456f501228f6
tree33ab7557c2cbde07af5fd42b280eb50a05757dfe
parent8f4149ea9395e4dbd4b9df5e05668bd487ab42eb
Add inline functions to convert between sbintime_t

and decimal time units. Use them in some existing code that is
vulnerable to roundoff errors.

The existing constant SBT_1NS is a honeypot, luring unsuspecting folks into
writing code such as long_timeout_ns*SBT_1NS to generate the argument for a
sleep call.  The actual value of 1ns in sbt units is ~4.3, leading to a
large roundoff error giving a shorter sleep than expected when multiplying
by the trucated value of 4 in SBT_1NS.  (The evil honeypot aspect becomes
clear after you waste a whole day figuring out why your sleeps return early.)
newlib/libc/include/sys/time.h
This page took 0.03081 seconds and 5 git commands to generate.