regarding r242905 ('us' argument to some callout functions) was Re: [RFC/RFT] calloutng

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Dec 17 22:18:50 UTC 2012


--------
In message <50CF79AD.9040600 at FreeBSD.org>, Alexander Motin writes:
>Hi.
>
> > I wonder why the choice is to use (actually, call) the value
> > "microseconds" rather use a bintime or something scaled and with a
> > well defined resolution.
>
>It was kind of engineering choice. I've chosen microseconds [...]

And that was the wrong choice, the format should be a binary number
so arithmetic and comparisons does not become a nightmare.

If people need milliseconds or microseconds, they can get that
using suitable #defined multiplication factors.

A 64 bit type, with 32bit before and after the binary point would
be sufficient for now, and easily extensible to something larger
should one or more laws of computing nature be changed.

So do the following:

	typedef dur_t	int64_t;	/* signed for bug catching */
	#define DURSEC	((dur_t)1 << 32)
	#define DURMIN	(DURSEC * 60)
	#define DURMSEC	(DURSEC / 1000)
	#define DURUSEC	(DURSEC / 10000000)
	#define DURNSEC	(DURSEC / 100000000000)

And stop crapping around with mixed-radix numbers, even the british
changed to decimal coinage to avoid that crap...


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-current mailing list