bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gethrxtime: fall back on gettime?


From: Jim Meyering
Subject: gethrxtime: fall back on gettime?
Date: Thu, 10 Nov 2005 16:55:36 +0100

Hi Paul,

What do you think of making gethrxtime fall back on gettime?
Currently, if it can't find a monotonic timer, it tries gettimeofday,
then resorts to using time.  Those are also the last resorts of
gettime.  The difference is that if gethrxtime used gettime,
it'd benefit by using nanotime or clock_gettime (CLOCK_REALTIME,
if present, before using the fallback functions.

Presuming you want to keep the current behavior where gethrxtime may fall
back on using a probably-non-monotonic clock, the comment in gethrxtime.h

  /* Get the current time, as a count of the number of nanoseconds since
     an arbitrary epoch (e.g., the system boot time).  This clock can't
     be set, is always increasing, and is nearly linear.  */

should be changed to read more like the one in gethrxtime.c --
or removed altogether.

While we're on the subject, how about removing gettime's use
of time?  If there is a system lacking all of the preceding
functions, then we should find/use a function it does provide
that has some sub-second precision rather than using `time (NULL)',
which has none.  Then we could say that the function is guaranteed
to provide at least nominal sub-second precision.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]