tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Typo(s) in sys/time.h ?
Date: Thu, 5 Jan 2017 11:58:46 +0800 (PHT)
From: Paul Goyette <paul%whooppee.com@localhost>
I suspect we should have a left shift here, rather than a right shift:
bt.frac = (((ms % 1000U) << 32)/1000U) >> 32;
They should both be left shifts. The point of the exercise is to
reduce ms to the range [0, 999) as a fraction of a second, and then to
convert a number of milliseconds (= 1000ths of a second) to a number
of 2^64ths of a second by
ms*2^64/1000 = ((ms*2^32)/1000)*2^32 = (ms << 32)/1000 << 32.
This was all written for a cv_timedwaitbt API I intended to add a
while back but never got around to:
https://www.NetBSD.org/~riastradh/tmp/20150412/cv_timedwaitbt.c
https://mail-index.NetBSD.org/tech-kern/2015/03/20/msg018546.html
https://mail-index.NetBSD.org/tech-kern/2015/03/23/msg018557.html
Home |
Main Index |
Thread Index |
Old Index