From owner-freebsd-hackers Wed Jun 25 03:12:08 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id DAA14941 for hackers-outgoing; Wed, 25 Jun 1997 03:12:08 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id DAA14936 for ; Wed, 25 Jun 1997 03:12:04 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.5/8.6.9) id UAA30436; Wed, 25 Jun 1997 20:09:09 +1000 Date: Wed, 25 Jun 1997 20:09:09 +1000 From: Bruce Evans Message-Id: <199706251009.UAA30436@godzilla.zeta.org.au> To: joerg_wunsch@uriah.heep.sax.de, msmith@atrad.adelaide.edu.au Subject: Re: libedit, etc. (CVS issues) Cc: hackers@FreeBSD.ORG Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Dang; I was too quick. Ok, rule of thumb is "once changed from the >original import, should have $Id$", correct? No, it is 1. Once changed from the vendor branch, should have $Id$". More important rules: 2. Don't gratuitously change from the vendor branch. 3. Don't change just to add $Id$". >I'll backtrack and catch the ones I've just committed. Breaks rule 3. >Does anyone know what the NetBSD function "timersub()" is supposed to do? Yes :-). It is supposed to pollute with a kernel interface. It is usually a poor way to subtract timevals in userland. ftp/util.c gives two examples of how to misuse it, of the form: double delta; struct timeval start, finish, td; ... timersub(&finish, &start, &td); delta = td.tv_sec + tv.tv_usec / 1000000.0; This can be done more efficiently and naturally directly: ... delta = finish.tv_sec - start.tv_sec + (finish.tv_usec - start.tv_usec) / 1000000.0; ftp/util.c gives one example of how to use it, of the form: struct timeval start, finish, td, start1, finish1, td1; double delta; ... if (something) { timersub(&finish1, &start1, td1); /* BUG (should use timeradd() here): */ start.tv_sec += start1.tv_sec; start.tv_usec += start1.tv_usec; } /* * BUG: timersub() only works on valid timevals, but `start' * may be invalid here (its tv_usec may be > 1000000. However, * the floating point calculation fixes up the value. */ timevalsub(&finish, &start, &td); delta = td.tv_sec + tv.tv_usec / 1000000.0; ... /* Something else using td1. */ This example could be changed to use a floating point td1, but that would be slower on machines with slow floating point. Bruce