Date: Tue, 28 Nov 2000 00:55:53 -0500 From: "Brian F. Feldman" <green@FreeBSD.org> To: Warner Losh <imp@village.org> Cc: Alfred Perlstein <bright@wintelcom.net>, "Brian F. Feldman" <green@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/inetd builtins.c Message-ID: <200011280555.eAS5ts503375@green.dyndns.org> In-Reply-To: Message from Warner Losh <imp@village.org> of "Mon, 27 Nov 2000 22:24:03 MST." <200011280524.WAA07413@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Warner Losh <imp@village.org> wrote:
> In message <20001126182240.A8051@fw.wintelcom.net> Alfred Perlstein writes:
> : - if ((to.tv_usec += tv.tv_usec) >= 1000000) {
> : + to.tv_usec += tv.tv_usec;
> : + if (to.tv_usec >= 1000000) {
> : to.tv_usec -= 1000000;
> : to.tv_sec++;
> : }
>
> Shouldn't this be
> if (to.tv_usec >= 1000000) {
> to.tv_sec += to.tv_usec / 1000000;
> to.tv_usec %= 1000000;
> }
I asked Poul-Henning the same thing with regard to similar checks in the
kernel code. The reply was that, although this is the "most correct" way of
doing things, a properly done calculation of to.tv_usec + tv.tv_usec in
this (and many other) case(s) will result in a maximum of 1999998, so at
most one subtraction and increment will be necessary.
If it's not possible to have a higher tv_usec, you save the REALLY expensive
divide-family instructions.
--
Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! /
green@FreeBSD.org `------------------------------'
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200011280555.eAS5ts503375>
