summaryrefslogtreecommitdiffstats
path: root/common.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-08-01 08:41:25 +0000
committerRoy Marples <roy@marples.name>2008-08-01 08:41:25 +0000
commit8fd2efb43e5d216dadd6386d7e26663b22f2144f (patch)
tree09c00162d9542bf21e154cbe7ea504c23715c360 /common.c
parentf92a185f0ef10af23a273c225a793a6d3c6a4a6e (diff)
downloaddhcpcd-8fd2efb43e5d216dadd6386d7e26663b22f2144f.tar.xz
Tweak README about monotonic, and improve warning message.
Diffstat (limited to 'common.c')
-rw-r--r--common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/common.c b/common.c
index 9911b345..9bedc6de 100644
--- a/common.c
+++ b/common.c
@@ -184,13 +184,14 @@ set_nonblock(int fd)
* Which is why we use CLOCK_MONOTONIC, but it is not available on all
* platforms.
*/
+#define NO_MONOTONIC "host does not support a montonic clock - timing can skew"
int
get_monotonic(struct timeval *tp)
{
+ static int posix_clock_set = 0;
#if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC)
struct timespec ts;
static clockid_t posix_clock;
- static int posix_clock_set = 0;
#ifdef FORCE_MONOTONIC
if (!posix_clock_set) {
@@ -205,7 +206,7 @@ get_monotonic(struct timeval *tp)
clock_monotonic = 1;
} else {
posix_clock = CLOCK_REALTIME;
- logger(LOG_WARNING, "host does not support a monotonic clock");
+ logger(LOG_WARNING, NO_MONOTONIC);
}
posix_clock_set = 1;
@@ -219,6 +220,11 @@ get_monotonic(struct timeval *tp)
tp->tv_usec = ts.tv_nsec / 1000;
return 0;
#else
+
+ if (!posix_clock_set) {
+ logger(LOG_WARNING, NO_MONOTONIC);
+ posix_clock_set = 1;
+ }
return gettimeofday(tp, NULL);
#endif
}