On Wed, 10 Aug 2011, Alexander Best wrote:

On Wed Aug 10 11, Bruce Evans wrote:
On Wed, 10 Aug 2011, Alexander Best wrote:
any reason {TIMEVAL,TIMESPEC}_TO_{TIMESPEC,TIMEVAL}()s code is being
executed
in a

do { ... } while (0)

conditional loop?

Just the usual syntactical trick for making large macros that look
like function calls almost usable like function calls.  Without the
...
thanks a lot for the in depth information. :) any reason, back in the days, it
was decided that the functionality of converting a timespec to a timeval and
vice versa should be implemented as a macro and not a function?

Macros avoid some namespace pollution problems, and all the old kernel
timeval manipulation interfaces are either extern functions or macros,
partly because inline functions didn't exist when these interfaces were
designed.  But the TIME* macros still have gratuitously different styles:
1) they are spelled in upper case (which is "correct" since they are unsafe
   macros, but this is not done for the other timeval macros which are almost
   all unsafe)
2) FreeBSD moved their definitions from <sys/time.h> (where 4.4BSD-Lite
   put them) to <sys/timespec.h>.  This is not incorrect (since <sys/time.h>
   is an old header that should only declare timeval interfaces (POSIX
   put timespec interfaces in <time.h>).  However, the move became out of
   date before it was done (in 2001) because <sys/time.h> had already
   grown several other timespec interfaces which were not moved.  But these
   were kernel-only, so they didn't cause namespace problems.  Now
   <sys/time.h> has grown several more user timespec interfaces.

Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to