From owner-cvs-all Mon Nov 27 21:56: 6 2000 Delivered-To: cvs-all@freebsd.org Received: from green.dyndns.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 00A3037B4D7; Mon, 27 Nov 2000 21:56:00 -0800 (PST) Received: from localhost (u1buze@localhost [127.0.0.1]) by green.dyndns.org (8.11.0/8.11.0) with ESMTP id eAS5ts503375; Tue, 28 Nov 2000 00:55:56 -0500 (EST) (envelope-from green@FreeBSD.org) Message-Id: <200011280555.eAS5ts503375@green.dyndns.org> X-Mailer: exmh version 2.2 06/23/2000 with nmh-1.0.4 To: Warner Losh Cc: Alfred Perlstein , "Brian F. Feldman" , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/inetd builtins.c In-Reply-To: Message from Warner Losh of "Mon, 27 Nov 2000 22:24:03 MST." <200011280524.WAA07413@harmony.village.org> From: "Brian F. Feldman" Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 28 Nov 2000 00:55:53 -0500 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Warner Losh 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