svn commit: r232044 - projects/pf/head/sys/sys
Gleb Smirnoff
glebius at FreeBSD.org
Thu Feb 23 19:10:33 UTC 2012
Bruce,
On Fri, Feb 24, 2012 at 04:30:53AM +1100, Bruce Evans wrote:
B> This is the old Net/2 and 4.4BSD API (extended). One of the bugs in
B> it is that it users the generic name `timer' for just one of the types
B> of time-related structures, and even that type is time-related, not
B> always timer-related. This timeval type should have gone away with POSIX
B> timespecs in 1988, so it is the one least deserving of the generic name.
B>
B> FreeBSD started fixing this in 1998 by renaming the above to timeval*()
B> in the kernel. Unfortunately, the old APIs remained as compatibility
B> cruft for userland (now under ifdefs). FreeBSD also added timespec*()
B> macros in 1998.
B>
B> timevaladd() and timevalsub() were correctly spelled and correctly
B> implemented as functions in FreeBSD-1. FreeBSD extended the old
B> mistakes in 1996 by adding timeradd() and timersub() macros for NetBSD
B> userland compatibility. These are heavier-weight and otherwise more
B> suitable for being functions than the others, so they were only
B> functions, and were correctly named too. timespecadd() and
B> timespecsub() are simalarly better implemented as functions, but FreeBSD
B> added macros for them in 1998, while intentionally not doing this for
B> timevaladd() and timevalsub(). But there is a problem with any of
B> these API being functions in userland, since the functions have never
B> been in libc. Hacking on time.h is easier than adding them in libc.
B> Even correct hacking on time.h for them would be easier than changing
B> libc. The 1996-2012 hacking is missing visibility ifdefs, and gives
B> unsafe macros although their names indicate that they are safe.
B>
B> POSIX extended the lifetime of timevals by standardizing them 2001.
B> 13 years wasn't long enough for them to go away. Now, 24 years hasn't
B> been long enough.
Thanks for important comments. Is the fix in r232062 okay?
--
Totus tuus, Glebius.
More information about the svn-src-projects
mailing list