From c5565af98a75bbfb13fe30c44e494bd0fbdda655 Mon Sep 17 00:00:00 2001 From: otto Date: Sun, 14 Jan 2007 19:18:12 +0000 Subject: Add some comments on the expresssion which converts sensor timedeltas to ntp offsets; also, rewrite the expression to make it more clear with no change in semantics. ok henning@ --- usr.sbin/ntpd/sensors.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.sbin/ntpd/sensors.c b/usr.sbin/ntpd/sensors.c index 7057220e4ce..0216667163c 100644 --- a/usr.sbin/ntpd/sensors.c +++ b/usr.sbin/ntpd/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.28 2006/12/28 00:24:27 naddy Exp $ */ +/* $OpenBSD: sensors.c,v 1.29 2007/01/14 19:18:12 otto Exp $ */ /* * Copyright (c) 2006 Henning Brauer @@ -164,8 +164,13 @@ sensor_query(struct ntp_sensor *s) s->last = sensor.tv.tv_sec; memcpy(&refid, "HARD", sizeof(refid)); - s->offsets[s->shift].offset = (0 - (float)sensor.value / 1000000000.0) - - getoffset(); + /* + * TD = device time + * TS = system time + * sensor.value = TS - TD in ns + * if value is positive, system time is ahead + */ + s->offsets[s->shift].offset = (sensor.value / -1e9) - getoffset(); s->offsets[s->shift].rcvd = sensor.tv.tv_sec; s->offsets[s->shift].good = 1; -- cgit v1.2.3-59-g8ed1b