Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/ntp/dist/ntpd bring back our status printing fu...
details: https://anonhg.NetBSD.org/src/rev/b1732b0ab131
branches: trunk
changeset: 749977:b1732b0ab131
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 14 00:41:03 2009 +0000
description:
bring back our status printing function
diffstat:
external/bsd/ntp/dist/ntpd/ntp_loopfilter.c | 43 +++++++++++++++++++---------
1 files changed, 29 insertions(+), 14 deletions(-)
diffs (95 lines):
diff -r d43579f59604 -r b1732b0ab131 external/bsd/ntp/dist/ntpd/ntp_loopfilter.c
--- a/external/bsd/ntp/dist/ntpd/ntp_loopfilter.c Mon Dec 14 00:40:26 2009 +0000
+++ b/external/bsd/ntp/dist/ntpd/ntp_loopfilter.c Mon Dec 14 00:41:03 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntp_loopfilter.c,v 1.1.1.1 2009/12/13 16:55:34 kardel Exp $ */
+/* $NetBSD: ntp_loopfilter.c,v 1.2 2009/12/14 00:41:03 christos Exp $ */
/*
* ntp_loopfilter.c - implements the NTP loop filter algorithm
@@ -20,6 +20,9 @@
#include <signal.h>
#include <setjmp.h>
+#ifdef __NetBSD__
+#include <util.h>
+#endif
#if defined(VMS) && defined(VMS_LOCALUNIT) /*wjm*/
#include "ntp_refclock.h"
@@ -178,6 +181,19 @@
#endif /* SIGSYS */
#endif /* KERNEL_PLL */
+static void
+sync_status(const char *what, int status)
+{
+ char buf[256], tbuf[1024];
+#ifdef STA_FMT
+ snprintb(buf, sizeof(buf), STA_FMT, status);
+#else
+ snprintf(buf, sizeof(buf), "%04x", status);
+#endif
+ snprintf(tbuf, sizeof(tbuf), "%s status=%s", what, buf);
+ report_event(EVNT_KERN, NULL, tbuf);
+}
+
/*
* init_loopfilter - initialize loop filter data
*/
@@ -545,16 +561,13 @@
* Enable/disable the PPS if requested.
*/
if (pps_enable) {
+ ntv.status |= STA_PPSTIME | STA_PPSFREQ;
if (!(pll_status & STA_PPSTIME))
- report_event(EVNT_KERN,
- NULL, "PPS enabled");
- ntv.status |= STA_PPSTIME | STA_PPSFREQ;
+ sync_status("PPS enbled", ntv.status);
} else {
+ ntv.status &= ~(STA_PPSTIME | STA_PPSFREQ);
if (pll_status & STA_PPSTIME)
- report_event(EVNT_KERN,
- NULL, "PPS disabled");
- ntv.status &= ~(STA_PPSTIME |
- STA_PPSFREQ);
+ sync_status("PPS disabled", ntv.status);
}
if (sys_leap == LEAP_ADDSECOND)
ntv.status |= STA_INS;
@@ -569,8 +582,12 @@
*/
if (ntp_adjtime(&ntv) == TIME_ERROR) {
if (!(ntv.status & STA_PPSSIGNAL))
- report_event(EVNT_KERN, NULL,
- "PPS no signal");
+ sync_status("PPS no signal", ntv.status);
+ else
+ sync_status("adjtime error", ntv.status);
+ } else {
+ if ((ntv.status ^ pll_status) & ~STA_FLL)
+ sync_status("status change", ntv.status);
}
pll_status = ntv.status;
#ifdef STA_NANO
@@ -914,8 +931,7 @@
if (pll_status & STA_CLK)
ext_enable = 1;
#endif /* STA_NANO */
- report_event(EVNT_KERN, NULL,
- "kernel time sync enabled");
+ sync_status("kernel time sync enabled", ntv.status);
}
#endif /* KERNEL_PLL */
#endif /* LOCKCLOCK */
@@ -953,8 +969,7 @@
ntv.modes = MOD_STATUS;
ntv.status = STA_UNSYNC;
ntp_adjtime(&ntv);
- report_event(EVNT_KERN, NULL,
- "kernel time sync disabledx");
+ sync_status("kernel time sync disabled", ntv.status);
}
#endif /* KERNEL_PLL */
#endif /* LOCKCLOCK */
Home |
Main Index |
Thread Index |
Old Index