Date: Thu, 14 Nov 1996 08:43:24 -0800 From: Jason Thorpe <thorpej@nas.nasa.gov> To: Bruce Evans <bde@zeta.org.au> Cc: freebsd-bugs@freefall.freebsd.org Subject: Re: misc/2007: /usr/include/sys lacking timer arithmetic functions.. Message-ID: <199611141643.IAA18936@lestat.nas.nasa.gov>
next in thread | raw e-mail | index | archive | help
On Thu, 14 Nov 1996 06:30:02 -0800 (PST) Bruce Evans <bde@zeta.org.au> wrote: > Applications got along for years without these functions, so why add them > now that floating point is faster than timeval arithmetic on most machines, > 64-bit machines are becoming available, and 64 bit long longs are available? > I usually use the following timeval arithmetic functions: > > timeval difference -> double > ((tv2.tv_sec - tv1.tv_sec) + (tv2.tv_usec - tv1.tv_sec) * 1e-6) > timeval -> double > (tv1.tv_sec + tv1.tv_sec * 1e-6) NetBSD added these because there were a zillion places where timeval arithmetic was implemented in the kernel. Centralizing it reduced code complexity, which is generally considered a good thing. They aren't function calls. Everything is done inline, so there's no additional cost associated with using the abstraction. The nice things about those macros (and using them consistently everywhere) is that you can change the implementation of timeval math just once (such as the floating point hack you suggest) and have it magically fixed everywhere. (I'd hesitate to use the floating point hack, but that's not the point. :-) Jason R. Thorpe thorpej@nas.nasa.gov NASA Ames Research Center Home: 408.866.1912 NAS: M/S 258-6 Work: 415.604.0935 Moffett Field, CA 94035 Pager: 415.428.6939
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611141643.IAA18936>