diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-03-27 18:22:03 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-03-27 18:22:03 +0000 |
commit | fa5dc2669576785b40c4f35e6dee5c8c91ac4102 (patch) | |
tree | 526947444b8a5fbbec2518485e5e69ba84f18bc1 /usr.sbin | |
parent | c7db996bd2fd1750ef4b2f8196a4b03a6a7cdf42 (diff) |
Normalize tv so that tv_usec is positive. The kernel also normalizes,
but this might increase portability since some other systems do not
grok negative tv_usec well. ok henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ntpd/util.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/ntpd/util.c b/usr.sbin/ntpd/util.c index 68468710cc2..10075076ad5 100644 --- a/usr.sbin/ntpd/util.c +++ b/usr.sbin/ntpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.12 2006/10/27 12:22:41 henning Exp $ */ +/* $OpenBSD: util.c,v 1.13 2007/03/27 18:22:02 otto Exp $ */ /* * Copyright (c) 2004 Alexander Guy <alexander.guy@andern.org> @@ -64,6 +64,10 @@ d_to_tv(double d, struct timeval *tv) { tv->tv_sec = (long)d; tv->tv_usec = (d - tv->tv_sec) * 1000000; + while (tv->tv_usec < 0) { + tv->tv_usec += 1000000; + tv->tv_sec -= 1; + } } double |