From owner-svn-src-projects@FreeBSD.ORG Thu Feb 23 20:15:35 2012 Return-Path: Delivered-To: svn-src-projects@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B45281065745 for ; Thu, 23 Feb 2012 20:15:35 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from fallbackmx08.syd.optusnet.com.au (fallbackmx08.syd.optusnet.com.au [211.29.132.10]) by mx1.freebsd.org (Postfix) with ESMTP id 5067B8FC1D for ; Thu, 23 Feb 2012 20:15:34 +0000 (UTC) Received: from mail15.syd.optusnet.com.au (mail15.syd.optusnet.com.au [211.29.132.196]) by fallbackmx08.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q1NHUxhe016470 for ; Fri, 24 Feb 2012 04:30:59 +1100 Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail15.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q1NHUrTr027705 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Feb 2012 04:30:54 +1100 Date: Fri, 24 Feb 2012 04:30:53 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Gleb Smirnoff In-Reply-To: <201202231019.q1NAJObb099152@svn.freebsd.org> Message-ID: <20120224034735.T1834@besplex.bde.org> References: <201202231019.q1NAJObb099152@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-projects@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r232044 - projects/pf/head/sys/sys X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Feb 2012 20:15:35 -0000 On Thu, 23 Feb 2012, Gleb Smirnoff wrote: > Log: > Expose NetBSD/OpenBSD compat defines to kernel code, too. These should be removed instead of used further. In another commit, you made changes make the use of the FreeBSD API clearer. This change makes it possible to not even use the FreeBSD API. > Modified: projects/pf/head/sys/sys/time.h > ============================================================================== > --- projects/pf/head/sys/sys/time.h Thu Feb 23 10:18:28 2012 (r232043) > +++ projects/pf/head/sys/sys/time.h Thu Feb 23 10:19:24 2012 (r232044) > @@ -199,8 +199,7 @@ timeval2bintime(const struct timeval *tv > > #endif /* _KERNEL */ > > -#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */ > - > +/* NetBSD/OpenBSD compatible interfaces. */ > #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) > #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) > #define timercmp(tvp, uvp, cmp) \ > @@ -225,7 +224,6 @@ timeval2bintime(const struct timeval *tv > (vvp)->tv_usec += 1000000; \ > } \ > } while (0) > -#endif This is the old Net/2 and 4.4BSD API (extended). One of the bugs in it is that it users the generic name `timer' for just one of the types of time-related structures, and even that type is time-related, not always timer-related. This timeval type should have gone away with POSIX timespecs in 1988, so it is the one least deserving of the generic name. FreeBSD started fixing this in 1998 by renaming the above to timeval*() in the kernel. Unfortunately, the old APIs remained as compatibility cruft for userland (now under ifdefs). FreeBSD also added timespec*() macros in 1998. timevaladd() and timevalsub() were correctly spelled and correctly implemented as functions in FreeBSD-1. FreeBSD extended the old mistakes in 1996 by adding timeradd() and timersub() macros for NetBSD userland compatibility. These are heavier-weight and otherwise more suitable for being functions than the others, so they were only functions, and were correctly named too. timespecadd() and timespecsub() are simalarly better implemented as functions, but FreeBSD added macros for them in 1998, while intentionally not doing this for timevaladd() and timevalsub(). But there is a problem with any of these API being functions in userland, since the functions have never been in libc. Hacking on time.h is easier than adding them in libc. Even correct hacking on time.h for them would be easier than changing libc. The 1996-2012 hacking is missing visibility ifdefs, and gives unsafe macros although their names indicate that they are safe. POSIX extended the lifetime of timevals by standardizing them 2001. 13 years wasn't long enough for them to go away. Now, 24 years hasn't been long enough. Bruce