From owner-freebsd-net@FreeBSD.ORG Tue Jan 20 03:32:28 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0AA4F16A4CE for ; Tue, 20 Jan 2004 03:32:28 -0800 (PST) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0D33F43D2D for ; Tue, 20 Jan 2004 03:32:26 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])i0KBWLug015640; Tue, 20 Jan 2004 22:32:21 +1100 Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) i0KBWHp2023265; Tue, 20 Jan 2004 22:32:19 +1100 Date: Tue, 20 Jan 2004 22:32:18 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: itojun@iijlab.net In-Reply-To: <20040120063133.EC399B2@coconut.itojun.org> Message-ID: <20040120210418.V3916@gamplex.bde.org> References: <20040120063133.EC399B2@coconut.itojun.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@freebsd.org cc: rrs@cisco.com Subject: Re: timersub/timeradd/timercmp X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jan 2004 11:32:28 -0000 On Tue, 20 Jan 2004 itojun@iijlab.net wrote: > could anyone let me know why timersub/add/cmp are disabled in the > kernel? They are spelled timevalsub/add/cmp in the kernel. This is a better spelling, since there are several data structures that can represent the time. timersub/add/cmp are disabled in the kernel to prevent regressions to worse names. > they were introduced in 4.4BSD, Actually, they were mostly introduced in NetBSD. 4.4BSD only has timercmp (and some other timer* functions) as a macro, and timevalsub/add as (unprototyped, not even declared) non-inline functions. FreeBSD picked up timersub/add from NetBSD for use in userland, and soon after renamed timercmp to timevalcmp in the kernel, and added timeval* for userland and timespec* for the kernel, and a few years later added bintime* for both the userland and the kernel. So FreeBSD now has kitchensinktime*^Wtimekitchensink*, and is only missing timercmp in the kernel relative to 4.4BSD. > and (non-)availability of > these macro makes it difficult for kame/rrs to deal with multiple > *BSDs. (guessing: are you trying to enforce the use of timespec > in the kernel?) That may have been a minor reason (before FreeBSD renamed timercmp to get the consistently better timeval* names). I tried to prevent timersub/add from being exported to userland. timevals are stupid interfaces that were needed when CPUs were slow and couldn't do floating point or wide integer operations very well. Why introduce macros to operate on them several years after they became obsolete? Portable code can't use these macros anyway. I agree the timeval access macros are better suited to things like adjusting select() timeouts than converting everything to floating point and back. It was in Dec. 1996 that timevals had been obsolete for several years and FreeBSD picked up the timer macros from NetBSD. timevals weren't obsolete in practice then of course. timespecs had only been standard in POSIX for 8 years, and lots of interfaces still used only timevals. 7 years later, time handling is messier than ever. POSIX has standardized all the old interfaces, so timevals are unlikely to go away for more than another 8+7 years (I guess twice that). OTOH, timespecs stopped being precise enough for some applications at about the same time as POSIX regressed from supporting only timespecs. phk is now trying to convert things to bintimes, and C99 couldn't agree on any useful extensions of time_t. Bruce