[ntp:bk-ntp-dev-send] BitKeeper diffs

Harlan Stenn stenn at deacon.udel.edu
Sun Dec 18 10:47:15 UTC 2011


#### ChangeSet ####
2011-12-18 04:24:58+00:00, davehart at shiny.ad.hartbrothers.com
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.
  [Bug 2068] "tos ceiling" default and cap changed to 15.
  Floor peer delay using system precision, as with jitter, reflecting
    inability to measure shorter intervals.

==== ChangeLog ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +4 -0
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.
  [Bug 2068] "tos ceiling" default and cap changed to 15.
  Floor peer delay using system precision, as with jitter, reflecting
    inability to measure shorter intervals.

--- 1.1075/ChangeLog	2011-12-16 21:33:40 -05:00
+++ 1.1076/ChangeLog	2011-12-17 23:24:55 -05:00
@@ -1,4 +1,8 @@
+* [Bug 2015] Overriding sys_tick should recalculate sys_precision.
 * [Bug 2037] Fuzzed non-interpolated clock may decrease.
+* [Bug 2068] "tos ceiling" default and cap changed to 15.
+* Floor peer delay using system precision, as with jitter, reflecting
+  inability to measure shorter intervals.
 (4.2.7p240) 2011/12/15 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 2092] clock_select() selection jitter miscalculated.
 * [Bug 2093] Reintroduce smaller stratum factor to system peer metric.

==== include/ntp.h ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +2 -1
  move sys_tick override from proto_config() to loop_config()

--- 1.201/include/ntp.h	2011-11-29 16:58:47 -05:00
+++ 1.202/include/ntp.h	2011-12-17 23:24:55 -05:00
@@ -696,7 +696,7 @@ struct pkt {
 #define PROTO_CALLDELAY		20
 #define PROTO_MINDISP		21
 #define PROTO_MAXDIST		22
-#define PROTO_ADJ		23
+	/* available		23 */
 #define	PROTO_MAXHOP		24
 #define	PROTO_BEACON		25
 #define	PROTO_ORPHAN		26
@@ -718,6 +718,7 @@ struct pkt {
 #define LOOP_FREQ		10	/* set initial frequency */
 #define LOOP_CODEC		11	/* set audio codec frequency */
 #define	LOOP_LEAP		12	/* insert leap after second 23:59 */
+#define	LOOP_TICK		13	/* sim. low precision clock */
 
 /*
  * Configuration items for the stats printer

==== include/ntp_stdlib.h ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.

--- 1.68/include/ntp_stdlib.h	2011-12-16 21:30:40 -05:00
+++ 1.69/include/ntp_stdlib.h	2011-12-17 23:24:55 -05:00
@@ -276,6 +276,7 @@ extern char *	ntp_strerror	(int e);
 
 /* systime.c */
 extern double	sys_tick;		/* tick size or time to read */
+extern double	measured_tick;		/* non-overridable sys_tick */
 extern double	sys_fuzz;		/* min clock read latency */
 
 /* version.c */

==== include/ntp_unixtime.h ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +2 -0
  include timespecops.h and timevalops.h

--- 1.11/include/ntp_unixtime.h	2011-12-14 22:26:59 -05:00
+++ 1.12/include/ntp_unixtime.h	2011-12-17 23:24:55 -05:00
@@ -8,6 +8,8 @@
 
 #include "ntp_types.h"	/* picks up time.h via ntp_machine.h */
 #include "ntp_calendar.h"
+#include "timespecops.h"
+#include "timevalops.h"
 
 #ifdef SIM
 #   define GETTIMEOFDAY(a, b) (node_gettime(&ntp_node, a))

==== include/ntpd.h ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.

--- 1.170/include/ntpd.h	2011-11-26 05:14:43 -05:00
+++ 1.171/include/ntpd.h	2011-12-17 23:24:55 -05:00
@@ -236,6 +236,7 @@ extern	void	poll_update	(struct peer *, 
 extern	void	clear		(struct peer *);
 extern	void	clock_filter	(struct peer *, double, double, double);
 extern	void	init_proto	(void);
+extern	void	set_sys_tick_precision(double);
 extern	void	proto_config	(int, u_long, double, sockaddr_u *);
 extern	void	proto_clr_stats (void);
 

==== libntp/systime.c ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +11 -3
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.

--- 1.60/libntp/systime.c	2011-12-16 21:33:40 -05:00
+++ 1.61/libntp/systime.c	2011-12-17 23:24:55 -05:00
@@ -71,10 +71,13 @@
 double	sys_tick = 0;		/* tick size or time to read (s) */
 double	sys_fuzz = 0;		/* min. time to read the clock (s) */
 long	sys_fuzz_nsec = 0;	/* min. time to read the clock (ns) */
+double	measured_tick;		/* non-overridable sys_tick (s) */
 double	sys_residual = 0;	/* adjustment residue (s) */
 time_stepped_callback	step_callback;
 
+#ifndef SIM
 static int lamport_violated;	/* clock was stepped back */
+#endif
 
 void
 set_sys_fuzz(
@@ -95,7 +98,8 @@ get_ostime(
 	struct timespec *	tsp
 	)
 {
-	int rc;
+	int	rc;
+	long	ticks;
 
 #if defined(HAVE_CLOCK_GETTIME)
 	rc = clock_gettime(CLOCK_REALTIME, tsp);
@@ -113,6 +117,11 @@ get_ostime(
 			errno);
 		exit(1);
 	}
+
+	if (sys_tick > measured_tick) {
+		ticks = (long)((tsp->tv_nsec * 1e-9) / sys_tick);
+		tsp->tv_nsec = (long)(ticks * 1e9 * sys_tick);
+	}
 }
 
 
@@ -125,8 +134,7 @@ get_systime(
 	)
 {
 	static struct timespec	ts_prev;	/* prior os time */
-	static l_fp		lfp_prev;	/* prior pre-residual result */
-	static l_fp		lfp_prev_w_resid;/* prior result including sys_residual */
+	static l_fp		lfp_prev;	/* prior result */
 	struct timespec ts;	/* seconds and nanoseconds */
 	struct timespec ts_min;	/* earliest permissible */
 	struct timespec ts_lam;	/* lamport fictional increment */

==== ntpd/complete.conf ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  add "tinker tick 0.01" coverage

--- 1.20/ntpd/complete.conf	2011-10-31 00:40:01 -04:00
+++ 1.21/ntpd/complete.conf	2011-12-17 23:24:55 -05:00
@@ -24,7 +24,7 @@ requestkey 12
 enable auth ntp monitor
 disable bclient calibrate kernel mode7
 tos beacon 3600 ceiling 16 cohort 0 floor 1 maxclock 10 maxdist 1.5 minclock 3 mindist 0.001 minsane 1 orphan 16 orphanwait 300
-tinker allan 1500 dispersion 15 freq 0 huffpuff 7200 panic 1000 step 0.128 stepout 900
+tinker allan 1500 dispersion 15 freq 0 huffpuff 7200 panic 1000 step 0.128 stepout 900 tick 0.01
 broadcastclient
 server 127.127.1.0 mode 4294967295 prefer true
 fudge 127.127.1.0 time1 0 time2 1.1 stratum 7 refid Abcd

==== ntpd/ntp_config.c ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +17 -4
  support "tinker tick 0.01" syntax alongside older "tick 0.01"
  [Bug 2068] "tos ceiling" default and cap changed to 15.

--- 1.295/ntpd/ntp_config.c	2011-11-26 05:14:43 -05:00
+++ 1.296/ntpd/ntp_config.c	2011-12-17 23:24:55 -05:00
@@ -1942,12 +1942,14 @@ config_tos(
 	config_tree *ptree
 	)
 {
-	attr_val *tos;
-	int item;
+	attr_val *	tos;
+	int		item;
+	double		val;
 
 	item = -1;	/* quiet warning */
 	tos = HEAD_PFIFO(ptree->orphan_cmds);
 	for (; tos != NULL; tos = tos->link) {
+		val = tos->value.d;
 		switch(tos->attr) {
 
 		default:
@@ -1955,6 +1957,12 @@ config_tos(
 			break;
 
 		case T_Ceiling:
+			if (val > STRATUM_UNSPEC - 1) {
+				msyslog(LOG_WARNING,
+					"Using maximum tos ceiling %d, %g requested",
+					STRATUM_UNSPEC - 1, val);
+				val = STRATUM_UNSPEC - 1;
+			}
 			item = PROTO_CEILING;
 			break;
 
@@ -1998,7 +2006,7 @@ config_tos(
 			item = PROTO_BEACON;
 			break;
 		}
-		proto_config(item, 0, tos->value.d, NULL);
+		proto_config(item, 0, val, NULL);
 	}
 }
 
@@ -2580,6 +2588,10 @@ config_tinker(
 		case T_Stepout:
 			item = LOOP_MINSTEP;
 			break;
+
+		case T_Tick:
+			item = LOOP_TICK;
+			break;
 		}
 		loop_config(item, tinker->value.d);
 	}
@@ -3395,8 +3407,9 @@ config_vars(
 		case T_Broadcastdelay:
 			proto_config(PROTO_BROADDELAY, 0, curr_var->value.d, NULL);
 			break;
+
 		case T_Tick:
-			proto_config(PROTO_ADJ, 0, curr_var->value.d, NULL);
+			loop_config(LOOP_TICK, curr_var->value.d);
 			break;
 
 		case T_Driftfile:

==== ntpd/ntp_control.c ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +8 -2
  Expose sys_fuzz to ntpq as nondefault system variable fuzz.

--- 1.177/ntpd/ntp_control.c	2011-12-05 12:23:33 -05:00
+++ 1.178/ntpd/ntp_control.c	2011-12-17 23:24:55 -05:00
@@ -219,7 +219,8 @@ static const struct ctl_proc control_cod
 #define	CS_TIMERSTATS_RESET	85
 #define	CS_TIMER_OVERRUNS	86
 #define	CS_TIMER_XMTS		87
-#define	CS_MAX_NOAUTOKEY	CS_TIMER_XMTS
+#define	CS_FUZZ			88
+#define	CS_MAX_NOAUTOKEY	CS_FUZZ
 #ifdef AUTOKEY
 #define	CS_FLAGS		(1 + CS_MAX_NOAUTOKEY)
 #define	CS_HOST			(2 + CS_MAX_NOAUTOKEY)
@@ -413,6 +414,7 @@ static const struct ctl_var sys_var[] = 
 	{ CS_TIMERSTATS_RESET,	RO, "timerstats_reset" },/* 85 */
 	{ CS_TIMER_OVERRUNS,	RO, "timer_overruns" },	/* 86 */
 	{ CS_TIMER_XMTS,	RO, "timer_xmts" },	/* 87 */
+	{ CS_FUZZ,		RO, "fuzz" },		/* 88 */
 #ifdef AUTOKEY
 	{ CS_FLAGS,	RO, "flags" },		/* 1 + CS_MAX_NOAUTOKEY */
 	{ CS_HOST,	RO, "host" },		/* 2 + CS_MAX_NOAUTOKEY */
@@ -679,7 +681,7 @@ int num_ctl_traps;
  * different than CTL_SST_TS_UNSPEC.
  */
 #ifdef REFCLOCK
-static u_char clocktypes[] = {
+static const u_char clocktypes[] = {
 	CTL_SST_TS_NTP, 	/* REFCLK_NONE (0) */
 	CTL_SST_TS_LOCAL,	/* REFCLK_LOCALCLOCK (1) */
 	CTL_SST_TS_UHF, 	/* deprecated REFCLK_GPS_TRAK (2) */
@@ -2231,6 +2233,10 @@ ctl_putsys(
 
 	case CS_TIMER_XMTS:
 		ctl_putuint(sys_var[varid].text, timer_xmtcalls);
+		break;
+
+	case CS_FUZZ:
+		ctl_putdbl(sys_var[varid].text, sys_fuzz * 1e3);
 		break;
 #ifdef AUTOKEY
 	case CS_FLAGS:

==== ntpd/ntp_io.c ====
2011-12-18 04:24:55+00:00, davehart at shiny.ad.hartbrothers.com +30 -25
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.

--- 1.363/ntpd/ntp_io.c	2011-11-26 07:11:53 -05:00
+++ 1.364/ntpd/ntp_io.c	2011-12-17 23:24:55 -05:00
@@ -3162,51 +3162,56 @@ fetch_timestamp(
 	)
 {
 #ifdef USE_TIMESTAMP_CMSG
-	struct cmsghdr *cmsghdr;
+	struct cmsghdr *	cmsghdr;
+	struct timeval *	tvp;
+	long			ticks;
+	double			fuzz;
+	l_fp			lfpfuzz;
+	l_fp			nts;
+#ifdef DEBUG_TIMING
+	l_fp			dts;
+#endif
 
 	cmsghdr = CMSG_FIRSTHDR(msghdr);
 	while (cmsghdr != NULL) {
 		switch (cmsghdr->cmsg_type)
 		{
 		case SCM_TIMESTAMP:
-		{
-			struct timeval *tvp;
-			double dtemp;
-			l_fp nts;
-
 			tvp = (struct timeval *)CMSG_DATA(cmsghdr);
+			if (sys_tick > measured_tick &&
+			    sys_tick > 1e-6) {
+				ticks = (long)((tvp->tv_usec * 1e-6) /
+					sys_tick);
+				tvp->tv_usec = (long)(ticks * 1e6 *
+						      sys_tick);
+			}
 			DPRINTF(4, ("fetch_timestamp: system network time stamp: %ld.%06ld\n",
 				    tvp->tv_sec, tvp->tv_usec));
-			nts.l_i = tvp->tv_sec + JAN_1970;
-			dtemp = (tvp->tv_usec 
-				 + (ntp_random() * 2. / FRAC)) / 1e6;
-			nts.l_uf = (u_int32)(dtemp * FRAC);
+			timeval_abstolfp(&nts, tvp);
+			fuzz = ntp_random() * 2. / FRAC * sys_fuzz;
+			DTOLFP(fuzz, &lfpfuzz);
+			L_ADD(&nts, &lfpfuzz);
 #ifdef DEBUG_TIMING
-			{
-				l_fp dts;
-
-				dts = ts;
-				L_SUB(&dts, &nts);
-				collect_timing(rb, 
-					       "input processing delay",
-					       1, &dts);
-				DPRINTF(4, ("fetch_timestamp: timestamp delta: %s (incl. prec fuzz)\n",
-					    lfptoa(&dts, 9)));
-			}
-#endif
+			dts = ts;
+			L_SUB(&dts, &nts);
+			collect_timing(rb, "input processing delay", 1,
+				       &dts);
+			DPRINTF(4, ("fetch_timestamp: timestamp delta: %s (incl. prec fuzz)\n",
+				    lfptoa(&dts, 9)));
+#endif	/* DEBUG_TIMING */
 			ts = nts;  /* network time stamp */
 			break;
-		}
+
 		default:
 			DPRINTF(4, ("fetch_timestamp: skipping control message 0x%x\n",
 				    cmsghdr->cmsg_type));
 		}
 		cmsghdr = CMSG_NXTHDR(msghdr, cmsghdr);
 	}
-#endif
+#endif	/* USE_TIMESTAMP_CMSG */
 	return ts;
 }
-#endif
+#endif	/* HAVE_TIMESTAMP */
 
 
 /*

==== ntpd/ntp_loopfilter.c ====
2011-12-18 04:24:56+00:00, davehart at shiny.ad.hartbrothers.com +5 -1
  move sys_tick override from proto_config() to loop_config()

--- 1.168/ntpd/ntp_loopfilter.c	2011-10-09 16:33:27 -04:00
+++ 1.169/ntpd/ntp_loopfilter.c	2011-12-17 23:24:56 -05:00
@@ -1060,7 +1060,11 @@ loop_config(
 			clock_minstep = freq; 
 		break;
 
-	case LOOP_LEAP:		/* not used */
+	case LOOP_TICK:		/* tick increment (tick) */
+		set_sys_tick_precision(freq);
+		break;
+
+	case LOOP_LEAP:		/* not used, fall through */
 	default:
 		msyslog(LOG_NOTICE,
 		    "loop_config: unsupported option %d", item);

==== ntpd/ntp_parser.c ====
2011-12-18 04:24:56+00:00, davehart at shiny.ad.hartbrothers.com +428 -424
  Bison output for ntp_parser.y

--- 1.77/ntpd/ntp_parser.c	2011-10-31 00:40:02 -04:00
+++ 1.78/ntpd/ntp_parser.c	2011-12-17 23:24:56 -05:00
@@ -749,18 +749,18 @@ union yyalloc
 #endif
 
 /* YYFINAL -- State number of the termination state.  */
-#define YYFINAL  195
+#define YYFINAL  196
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   560
+#define YYLAST   584
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  189
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  100
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  297
+#define YYNRULES  298
 /* YYNRULES -- Number of states.  */
-#define YYNSTATES  398
+#define YYNSTATES  399
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
@@ -843,16 +843,16 @@ static const yytype_uint16 yyprhs[] =
      401,   404,   407,   409,   411,   413,   415,   417,   419,   422,
      425,   428,   430,   432,   434,   436,   438,   440,   442,   444,
      446,   448,   450,   453,   456,   458,   461,   463,   465,   467,
-     469,   471,   473,   475,   477,   479,   482,   485,   488,   492,
-     494,   497,   500,   503,   506,   510,   513,   515,   517,   519,
-     521,   523,   525,   527,   529,   531,   533,   536,   537,   542,
-     544,   545,   546,   549,   552,   555,   558,   560,   562,   566,
-     570,   572,   574,   576,   578,   580,   582,   584,   586,   588,
-     591,   594,   596,   598,   600,   602,   604,   606,   608,   610,
-     613,   615,   618,   620,   622,   624,   630,   633,   635,   638,
-     640,   642,   644,   646,   648,   650,   656,   658,   662,   665,
-     669,   671,   673,   676,   678,   684,   689,   693,   696,   698,
-     705,   709,   712,   716,   718,   720,   722,   724
+     469,   471,   473,   475,   477,   479,   481,   484,   487,   490,
+     494,   496,   499,   502,   505,   508,   512,   515,   517,   519,
+     521,   523,   525,   527,   529,   531,   533,   535,   538,   539,
+     544,   546,   547,   548,   551,   554,   557,   560,   562,   564,
+     568,   572,   574,   576,   578,   580,   582,   584,   586,   588,
+     590,   593,   596,   598,   600,   602,   604,   606,   608,   610,
+     612,   615,   617,   620,   622,   624,   626,   632,   635,   637,
+     640,   642,   644,   646,   648,   650,   652,   658,   660,   664,
+     667,   671,   673,   675,   678,   680,   686,   691,   695,   698,
+     700,   707,   711,   714,   718,   720,   722,   724,   726
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
@@ -905,32 +905,32 @@ static const yytype_int16 yyrhs[] =
       66,    -1,    98,    -1,   113,    -1,    97,    -1,   143,    -1,
      156,   246,    -1,   246,   247,    -1,   247,    -1,   248,   274,
       -1,     5,    -1,    30,    -1,    46,    -1,    49,    -1,   118,
-      -1,   145,    -1,   146,    -1,   260,    -1,   264,    -1,   250,
-     274,    -1,   251,   148,    -1,   252,   148,    -1,    57,   148,
-     192,    -1,    36,    -1,    32,   253,    -1,    76,   258,    -1,
-     121,   271,    -1,   140,   254,    -1,   158,   196,   256,    -1,
-     161,   267,    -1,    15,    -1,   106,    -1,   151,    -1,    51,
-      -1,    72,    -1,   123,    -1,   130,    -1,    77,    -1,   138,
-      -1,   148,    -1,   148,    31,    -1,    -1,   148,   184,   148,
-     255,    -1,    26,    -1,    -1,    -1,   256,   257,    -1,   125,
-      58,    -1,    59,   196,    -1,   258,   259,    -1,   259,    -1,
-     148,    -1,   261,   263,   262,    -1,   261,   263,   148,    -1,
-      59,    -1,   102,    -1,     4,    -1,    62,    -1,    64,    -1,
-     169,    -1,    75,    -1,    52,    -1,    33,    -1,   135,   265,
-      -1,   265,   266,    -1,   266,    -1,     6,    -1,     7,    -1,
-      24,    -1,    61,    -1,    89,    -1,   149,    -1,   154,    -1,
-     267,    58,    -1,    58,    -1,   268,   269,    -1,   269,    -1,
-      58,    -1,   270,    -1,   185,    58,    34,    58,   186,    -1,
-     271,   148,    -1,   148,    -1,   272,   195,    -1,   195,    -1,
-      58,    -1,   159,    -1,    37,    -1,    58,    -1,    31,    -1,
-     276,   187,   277,   280,   188,    -1,   174,    -1,   277,   278,
-     173,    -1,   278,   173,    -1,   279,   184,   274,    -1,   175,
-      -1,   176,    -1,   280,   281,    -1,   281,    -1,   283,   187,
-     282,   284,   188,    -1,   177,   184,   274,   173,    -1,   139,
-     184,   195,    -1,   284,   285,    -1,   285,    -1,   178,   184,
-     274,   187,   286,   188,    -1,   286,   287,   173,    -1,   287,
-     173,    -1,   288,   184,   274,    -1,   179,    -1,   180,    -1,
-     181,    -1,   182,    -1,   183,    -1
+      -1,   145,    -1,   146,    -1,   151,    -1,   260,    -1,   264,
+      -1,   250,   274,    -1,   251,   148,    -1,   252,   148,    -1,
+      57,   148,   192,    -1,    36,    -1,    32,   253,    -1,    76,
+     258,    -1,   121,   271,    -1,   140,   254,    -1,   158,   196,
+     256,    -1,   161,   267,    -1,    15,    -1,   106,    -1,   151,
+      -1,    51,    -1,    72,    -1,   123,    -1,   130,    -1,    77,
+      -1,   138,    -1,   148,    -1,   148,    31,    -1,    -1,   148,
+     184,   148,   255,    -1,    26,    -1,    -1,    -1,   256,   257,
+      -1,   125,    58,    -1,    59,   196,    -1,   258,   259,    -1,
+     259,    -1,   148,    -1,   261,   263,   262,    -1,   261,   263,
+     148,    -1,    59,    -1,   102,    -1,     4,    -1,    62,    -1,
+      64,    -1,   169,    -1,    75,    -1,    52,    -1,    33,    -1,
+     135,   265,    -1,   265,   266,    -1,   266,    -1,     6,    -1,
+       7,    -1,    24,    -1,    61,    -1,    89,    -1,   149,    -1,
+     154,    -1,   267,    58,    -1,    58,    -1,   268,   269,    -1,
+     269,    -1,    58,    -1,   270,    -1,   185,    58,    34,    58,
+     186,    -1,   271,   148,    -1,   148,    -1,   272,   195,    -1,
+     195,    -1,    58,    -1,   159,    -1,    37,    -1,    58,    -1,
+      31,    -1,   276,   187,   277,   280,   188,    -1,   174,    -1,
+     277,   278,   173,    -1,   278,   173,    -1,   279,   184,   274,
+      -1,   175,    -1,   176,    -1,   280,   281,    -1,   281,    -1,
+     283,   187,   282,   284,   188,    -1,   177,   184,   274,   173,
+      -1,   139,   184,   195,    -1,   284,   285,    -1,   285,    -1,
+     178,   184,   274,   187,   286,   188,    -1,   286,   287,   173,
+      -1,   287,   173,    -1,   288,   184,   274,    -1,   179,    -1,
+     180,    -1,   181,    -1,   182,    -1,   183,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
@@ -956,16 +956,16 @@ static const yytype_uint16 yyrline[] =
      942,   944,   949,   950,   954,   955,   956,   957,   965,   967,
      972,   977,   985,   987,  1004,  1005,  1006,  1007,  1008,  1009,
     1013,  1014,  1022,  1027,  1032,  1040,  1045,  1046,  1047,  1048,
-    1049,  1050,  1051,  1060,  1061,  1062,  1069,  1076,  1092,  1111,
-    1116,  1118,  1120,  1122,  1124,  1131,  1136,  1137,  1138,  1142,
-    1143,  1144,  1145,  1149,  1150,  1154,  1161,  1171,  1180,  1185,
-    1187,  1192,  1193,  1201,  1203,  1211,  1216,  1224,  1249,  1256,
-    1266,  1267,  1271,  1272,  1273,  1274,  1278,  1279,  1280,  1284,
-    1289,  1294,  1302,  1303,  1304,  1305,  1306,  1307,  1308,  1318,
-    1323,  1331,  1336,  1344,  1346,  1350,  1355,  1360,  1368,  1373,
-    1381,  1390,  1391,  1395,  1396,  1405,  1423,  1427,  1432,  1440,
-    1445,  1446,  1450,  1455,  1463,  1468,  1473,  1478,  1483,  1491,
-    1496,  1501,  1509,  1514,  1515,  1516,  1517,  1518
+    1049,  1050,  1051,  1052,  1061,  1062,  1063,  1070,  1077,  1093,
+    1112,  1117,  1119,  1121,  1123,  1125,  1132,  1137,  1138,  1139,
+    1143,  1144,  1145,  1146,  1150,  1151,  1155,  1162,  1172,  1181,
+    1186,  1188,  1193,  1194,  1202,  1204,  1212,  1217,  1225,  1250,
+    1257,  1267,  1268,  1272,  1273,  1274,  1275,  1279,  1280,  1281,
+    1285,  1290,  1295,  1303,  1304,  1305,  1306,  1307,  1308,  1309,
+    1319,  1324,  1332,  1337,  1345,  1347,  1351,  1356,  1361,  1369,
+    1374,  1382,  1391,  1392,  1396,  1397,  1406,  1424,  1428,  1433,
+    1441,  1446,  1447,  1451,  1456,  1464,  1469,  1474,  1479,  1484,
+    1492,  1497,  1502,  1510,  1515,  1516,  1517,  1518,  1519
 };
 #endif
 
@@ -1093,16 +1093,16 @@ static const yytype_uint16 yyr1[] =
      237,   237,   238,   238,   239,   239,   239,   239,   240,   240,
      241,   241,   242,   242,   243,   243,   243,   243,   243,   243,
      244,   244,   245,   246,   246,   247,   248,   248,   248,   248,
-     248,   248,   248,   249,   249,   249,   249,   249,   249,   249,
-     249,   249,   249,   249,   249,   249,   250,   250,   250,   251,
-     251,   251,   251,   252,   252,   253,   253,   253,   254,   255,
-     255,   256,   256,   257,   257,   258,   258,   259,   260,   260,
-     261,   261,   262,   262,   262,   262,   263,   263,   263,   264,
-     265,   265,   266,   266,   266,   266,   266,   266,   266,   267,
-     267,   268,   268,   269,   269,   270,   271,   271,   272,   272,
-     273,   273,   273,   274,   274,   275,   276,   277,   277,   278,
-     279,   279,   280,   280,   281,   282,   283,   284,   284,   285,
-     286,   286,   287,   288,   288,   288,   288,   288
+     248,   248,   248,   248,   249,   249,   249,   249,   249,   249,
+     249,   249,   249,   249,   249,   249,   249,   250,   250,   250,
+     251,   251,   251,   251,   252,   252,   253,   253,   253,   254,
+     255,   255,   256,   256,   257,   257,   258,   258,   259,   260,
+     260,   261,   261,   262,   262,   262,   262,   263,   263,   263,
+     264,   265,   265,   266,   266,   266,   266,   266,   266,   266,
+     267,   267,   268,   268,   269,   269,   270,   271,   271,   272,
+     272,   273,   273,   273,   274,   274,   275,   276,   277,   277,
+     278,   279,   279,   280,   280,   281,   282,   283,   284,   284,
+     285,   286,   286,   287,   288,   288,   288,   288,   288
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
@@ -1128,16 +1128,16 @@ static const yytype_uint8 yyr2[] =
        2,     2,     1,     1,     1,     1,     1,     1,     2,     2,
        2,     1,     1,     1,     1,     1,     1,     1,     1,     1,
        1,     1,     2,     2,     1,     2,     1,     1,     1,     1,
-       1,     1,     1,     1,     1,     2,     2,     2,     3,     1,
-       2,     2,     2,     2,     3,     2,     1,     1,     1,     1,
-       1,     1,     1,     1,     1,     1,     2,     0,     4,     1,
-       0,     0,     2,     2,     2,     2,     1,     1,     3,     3,
-       1,     1,     1,     1,     1,     1,     1,     1,     1,     2,
-       2,     1,     1,     1,     1,     1,     1,     1,     1,     2,
-       1,     2,     1,     1,     1,     5,     2,     1,     2,     1,
-       1,     1,     1,     1,     1,     5,     1,     3,     2,     3,
-       1,     1,     2,     1,     5,     4,     3,     2,     1,     6,
-       3,     2,     3,     1,     1,     1,     1,     1
+       1,     1,     1,     1,     1,     1,     2,     2,     2,     3,
+       1,     2,     2,     2,     2,     3,     2,     1,     1,     1,
+       1,     1,     1,     1,     1,     1,     1,     2,     0,     4,
+       1,     0,     0,     2,     2,     2,     2,     1,     1,     3,
+       3,     1,     1,     1,     1,     1,     1,     1,     1,     1,
+       2,     2,     1,     1,     1,     1,     1,     1,     1,     1,
+       2,     1,     2,     1,     1,     1,     5,     2,     1,     2,
+       1,     1,     1,     1,     1,     1,     5,     1,     3,     2,
+       3,     1,     1,     2,     1,     5,     4,     3,     2,     1,
+       6,     3,     2,     3,     1,     1,     1,     1,     1
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -1145,123 +1145,123 @@ static const yytype_uint8 yyr2[] =
    means the default is an error.  */
 static const yytype_uint16 yydefact[] =
 {
-       0,     0,     0,    23,    57,   216,     0,    69,     0,     0,
-     227,     0,   209,     0,     0,   219,     0,   240,     0,     0,
-     220,     0,   223,    24,     0,     0,     0,   241,   217,     0,
-      22,     0,   221,    21,   222,     0,     0,     0,     0,   224,
-      20,     0,     0,     0,   218,     0,     0,     0,     0,     0,
-      55,    56,   276,     0,     2,     0,     7,     0,     8,     0,
+       0,     0,     0,    23,    57,   217,     0,    69,     0,     0,
+     228,     0,   210,     0,     0,   220,     0,   241,     0,     0,
+     221,     0,   224,    24,     0,     0,     0,   242,   218,     0,
+      22,     0,   222,    21,   223,     0,     0,     0,     0,   225,
+      20,     0,     0,     0,   219,     0,     0,     0,     0,     0,
+      55,    56,   277,     0,     2,     0,     7,     0,     8,     0,
        9,    10,    13,    11,    12,    14,    15,    16,    17,     0,
-       0,     0,   203,     0,   204,    18,     0,     5,    60,    61,
+       0,     0,   204,     0,   205,    18,     0,     5,    60,    61,
       62,   184,   185,   186,   187,   190,   188,   189,   191,   179,
-     181,   182,   183,   151,   152,   153,   124,   149,     0,   225,
-     210,   178,    99,   100,   101,   102,   106,   103,   104,   105,
+     181,   182,   183,   151,   152,   153,   124,   149,     0,   226,
+     211,   178,    99,   100,   101,   102,   106,   103,   104,   105,
      107,    28,    29,    27,     0,    25,     0,     6,    63,    64,
-     237,   211,   236,   269,    58,   157,   158,   159,   160,   161,
-     162,   163,   164,   125,   155,     0,    59,    68,   267,   212,
-      65,   252,   253,   254,   255,   256,   257,   258,   249,   251,
-     132,    28,    29,   132,   132,    25,    66,     0,   213,    94,
-      98,    95,   196,   197,   198,   199,   200,   201,   202,   192,
-     194,     0,    89,    84,     0,    85,    93,    91,    92,    90,
-      88,    86,    87,    78,    80,     0,     0,   231,   263,     0,
-      67,   262,   264,   260,   215,     1,     0,     4,    30,    54,
-     274,   273,   205,   206,   207,   248,   247,   246,     0,     0,
-      77,    73,    74,    75,    76,     0,    70,     0,   180,   148,
-     150,   226,    96,   174,   175,   176,   177,     0,     0,   172,
-     173,   165,   167,     0,     0,    26,   208,   235,   268,   154,
-     156,   266,   250,   128,   132,   132,   131,   126,     0,     0,
-      97,   193,   195,   272,   270,   271,    83,    79,    81,    82,
-     214,     0,   261,   259,     3,    19,   242,   243,   244,   239,
-     245,   238,   280,   281,     0,     0,     0,    72,    71,   116,
-     115,     0,   113,   114,     0,   108,   111,   112,   171,   170,
-     166,   168,   169,   134,   135,   136,   137,   138,   139,   140,
-     141,   142,   143,   144,   145,   146,   147,   133,   129,   130,
-     132,   230,     0,     0,   232,     0,    36,    37,    38,    53,
-      46,    48,    47,    50,    39,    40,    41,    42,    49,    51,
-      43,    31,    32,    35,    33,     0,    34,     0,     0,     0,
-       0,   283,     0,   278,     0,   109,   123,   119,   121,   117,
-     118,   120,   122,   110,   127,   229,   228,   234,   233,     0,
-      44,    45,    52,     0,   277,   275,   282,     0,   279,   265,
-     286,     0,     0,     0,     0,     0,   288,     0,     0,   284,
-     287,   285,     0,     0,   293,   294,   295,   296,   297,     0,
-       0,     0,   289,     0,   291,     0,   290,   292
+     238,   212,   237,   270,    58,   157,   158,   159,   160,   161,
+     162,   163,   164,   125,   155,     0,    59,    68,   268,   213,
+      65,   253,   254,   255,   256,   257,   258,   259,   250,   252,
+     132,    28,    29,   132,   132,    25,    66,     0,   214,    94,
+      98,    95,   196,   197,   198,   199,   200,   201,   202,   203,
+     192,   194,     0,    89,    84,     0,    85,    93,    91,    92,
+      90,    88,    86,    87,    78,    80,     0,     0,   232,   264,
+       0,    67,   263,   265,   261,   216,     1,     0,     4,    30,
+      54,   275,   274,   206,   207,   208,   249,   248,   247,     0,
+       0,    77,    73,    74,    75,    76,     0,    70,     0,   180,
+     148,   150,   227,    96,   174,   175,   176,   177,     0,     0,
+     172,   173,   165,   167,     0,     0,    26,   209,   236,   269,
+     154,   156,   267,   251,   128,   132,   132,   131,   126,     0,
+       0,    97,   193,   195,   273,   271,   272,    83,    79,    81,
+      82,   215,     0,   262,   260,     3,    19,   243,   244,   245,
+     240,   246,   239,   281,   282,     0,     0,     0,    72,    71,
+     116,   115,     0,   113,   114,     0,   108,   111,   112,   171,
+     170,   166,   168,   169,   134,   135,   136,   137,   138,   139,
+     140,   141,   142,   143,   144,   145,   146,   147,   133,   129,
+     130,   132,   231,     0,     0,   233,     0,    36,    37,    38,
+      53,    46,    48,    47,    50,    39,    40,    41,    42,    49,
+      51,    43,    31,    32,    35,    33,     0,    34,     0,     0,
+       0,     0,   284,     0,   279,     0,   109,   123,   119,   121,
+     117,   118,   120,   122,   110,   127,   230,   229,   235,   234,
+       0,    44,    45,    52,     0,   278,   276,   283,     0,   280,
+     266,   287,     0,     0,     0,     0,     0,   289,     0,     0,
+     285,   288,   286,     0,     0,   294,   295,   296,   297,   298,
+       0,     0,     0,   290,     0,   292,     0,   291,   293
 };
 
 /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
-      -1,    53,    54,    55,    56,    57,   123,   115,   116,   265,
-     331,   332,   333,   334,   335,   336,   337,    58,    59,    60,
-      61,    80,   216,   217,    62,   183,   184,   185,   186,    63,
-     159,   110,   222,   285,   286,   287,   353,    64,   243,   307,
-      96,    97,    98,   133,   134,   135,    65,   231,   232,   233,
-     234,    66,    89,    90,    91,    92,    67,   169,   170,   171,
-      68,    69,    70,    71,   100,   158,   356,   260,   314,   121,
-     122,    72,    73,   271,   208,    74,   148,   149,   194,   190,
-     191,   192,   139,   124,   256,   202,    75,    76,   274,   275,
-     276,   340,   341,   372,   342,   375,   376,   389,   390,   391
+      -1,    53,    54,    55,    56,    57,   123,   115,   116,   266,
+     332,   333,   334,   335,   336,   337,   338,    58,    59,    60,
+      61,    80,   217,   218,    62,   184,   185,   186,   187,    63,
+     159,   110,   223,   286,   287,   288,   354,    64,   244,   308,
+      96,    97,    98,   133,   134,   135,    65,   232,   233,   234,
+     235,    66,    89,    90,    91,    92,    67,   170,   171,   172,
+      68,    69,    70,    71,   100,   158,   357,   261,   315,   121,
+     122,    72,    73,   272,   209,    74,   148,   149,   195,   191,
+     192,   193,   139,   124,   257,   203,    75,    76,   275,   276,
+     277,   341,   342,   373,   343,   376,   377,   390,   391,   392
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -170
+#define YYPACT_NINF -171
 static const yytype_int16 yypact[] =
 {
-      12,  -144,   -20,  -170,  -170,  -170,   -16,  -170,   123,     8,
-     -98,   123,  -170,   -11,    -7,  -170,   -96,  -170,   -95,   -94,
-    -170,   -91,  -170,  -170,    -7,   467,    -7,  -170,  -170,   -72,
-    -170,   -71,  -170,  -170,  -170,    -3,    54,    40,    27,  -170,
-    -170,   -62,   -11,   -61,  -170,    19,   419,   -58,   -53,    33,
-    -170,  -170,  -170,    96,   178,   -75,  -170,    -7,  -170,    -7,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,    39,
-     -49,   -48,  -170,   -13,  -170,  -170,   -83,  -170,  -170,  -170,
-     241,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,   123,
-    -170,  -170,  -170,  -170,  -170,  -170,     8,  -170,    49,    80,
-    -170,   123,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,   264,  -170,   -32,   332,  -170,  -170,
-    -170,   -91,  -170,  -170,    -7,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,   467,  -170,    61,    -7,  -170,  -170,   -25,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,    54,  -170,
-    -170,   100,   102,  -170,  -170,    47,  -170,   -39,  -170,   -11,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,    19,
-    -170,    39,  -170,  -170,   -21,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,   419,  -170,    95,    39,  -170,  -170,    97,
-     -53,  -170,  -170,  -170,    99,  -170,   -12,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,    10,  -140,
-    -170,  -170,  -170,  -170,  -170,   101,  -170,    14,  -170,  -170,
-    -170,  -170,   195,  -170,  -170,  -170,  -170,    18,   109,  -170,
-    -170,   264,  -170,    39,   -21,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,   311,  -170,  -170,   311,   311,   -58,    30,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,
-     -50,   146,  -170,  -170,  -170,   390,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,   -93,     9,    -1,  -170,  -170,  -170,
-    -170,    36,  -170,  -170,     3,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,   311,   311,
-    -170,   164,   -58,   143,  -170,   144,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,   -43,  -170,    57,    31,    38,
-    -109,  -170,    29,  -170,    39,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,   311,  -170,  -170,  -170,  -170,    32,
-    -170,  -170,  -170,    -7,  -170,  -170,  -170,    42,  -170,  -170,
-    -170,    43,    44,    39,    48,  -156,  -170,    51,    39,  -170,
-    -170,  -170,    41,    15,  -170,  -170,  -170,  -170,  -170,    60,
-      58,    50,  -170,    65,  -170,    39,  -170,  -170
+      12,  -142,   -26,  -171,  -171,  -171,   -23,  -171,   123,     8,
+    -112,   123,  -171,   136,   -41,  -171,  -110,  -171,   -96,   -94,
+    -171,   -87,  -171,  -171,   -41,   244,   -41,  -171,  -171,   -83,
+    -171,   -75,  -171,  -171,  -171,    18,    43,    40,    19,  -171,
+    -171,   -69,   136,   -66,  -171,    48,   443,   -65,   -48,    27,
+    -171,  -171,  -171,    86,   202,   -86,  -171,   -41,  -171,   -41,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,   -16,
+     -58,   -57,  -171,   -13,  -171,  -171,   -89,  -171,  -171,  -171,
+     191,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,   123,
+    -171,  -171,  -171,  -171,  -171,  -171,     8,  -171,    41,    69,
+    -171,   123,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,   160,  -171,   -39,   356,  -171,  -171,
+    -171,   -87,  -171,  -171,   -41,  -171,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,   244,  -171,    53,   -41,  -171,  -171,   -33,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,    43,  -171,
+    -171,    93,    94,  -171,  -171,    39,  -171,   -56,  -171,   136,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+      48,  -171,   -16,  -171,  -171,   -21,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,   443,  -171,    71,   -16,  -171,  -171,
+      81,   -48,  -171,  -171,  -171,    83,  -171,   -30,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,    10,
+    -146,  -171,  -171,  -171,  -171,  -171,    87,  -171,    -4,  -171,
+    -171,  -171,  -171,    88,  -171,  -171,  -171,  -171,     5,    99,
+    -171,  -171,   160,  -171,   -16,   -21,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,   335,  -171,  -171,   335,   335,   -65,
+      16,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+    -171,   -50,   126,  -171,  -171,  -171,   414,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -120,    -8,   -17,  -171,  -171,
+    -171,  -171,    30,  -171,  -171,     3,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,   335,
+     335,  -171,   154,   -65,   124,  -171,   125,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,   -46,  -171,    36,     6,
+      14,  -131,  -171,     9,  -171,   -16,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,   335,  -171,  -171,  -171,  -171,
+      20,  -171,  -171,  -171,   -41,  -171,  -171,  -171,    21,  -171,
+    -171,  -171,    11,    29,   -16,    24,  -118,  -171,    32,   -16,
+    -171,  -171,  -171,    23,   217,  -171,  -171,  -171,  -171,  -171,
+      64,    46,    28,  -171,    49,  -171,   -16,  -171,  -171
 };
 
 /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -170,  -170,  -170,   -44,  -170,  -170,   -14,   -36,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,    62,  -170,  -170,  -170,
-    -170,   -35,  -170,  -170,  -170,  -170,  -170,  -170,  -150,  -170,
-    -170,   148,  -170,  -170,   116,  -170,  -170,  -170,    20,  -170,
-    -170,  -170,   242,   -70,  -170,  -170,  -170,  -170,    83,  -170,
-    -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,  -170,
-     135,  -170,  -170,  -170,  -170,  -170,  -170,   112,  -170,  -170,
-      67,  -170,  -170,   235,    28,  -169,  -170,  -170,  -170,   -10,
-    -170,  -170,   -77,  -170,  -170,  -170,  -110,  -170,  -122,  -170
+    -171,  -171,  -171,   -49,  -171,  -171,   -14,   -36,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,    44,  -171,  -171,  -171,
+    -171,   -35,  -171,  -171,  -171,  -171,  -171,  -171,  -150,  -171,
+    -171,   129,  -171,  -171,    96,  -171,  -171,  -171,    -5,  -171,
+    -171,  -171,   221,   -43,  -171,  -171,  -171,  -171,    63,  -171,
+    -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,  -171,
+     114,  -171,  -171,  -171,  -171,  -171,  -171,    92,  -171,  -171,
+      57,  -171,  -171,   225,    22,  -170,  -171,  -171,  -171,   -20,
+    -171,  -171,   -81,  -171,  -171,  -171,  -122,  -171,  -132,  -171
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
@@ -1271,124 +1271,128 @@ static const yytype_int16 yypgoto[] =
 #define YYTABLE_NINF -7
 static const yytype_int16 yytable[] =
 {
-     114,   155,   252,   246,   247,   188,   346,   160,   102,   312,
-     196,   187,   103,     1,   266,   360,   253,   259,    93,   218,
-     205,     2,   374,   154,   162,     3,     4,     5,   347,    77,
-     338,   218,   379,     6,     7,   272,   273,   254,    78,   206,
-       8,     9,    79,   198,    10,   199,   338,    11,    12,   163,
-      99,    13,   117,   118,   119,   140,   111,   120,   112,    14,
-     141,   142,   207,    15,   291,   164,   150,   104,   165,    16,
-     200,    17,   267,   236,   268,   313,   137,   138,   143,   365,
-      18,    19,   272,   273,    20,   156,   157,   161,    21,    22,
-     113,   193,    23,    24,   308,   309,   195,   201,   197,   203,
-     204,    94,   348,   151,   209,   152,    95,   220,   349,   105,
-     238,   221,    25,    26,    27,   144,   235,   106,    28,   240,
-     361,   107,   238,   241,   250,   350,   244,    29,   245,   248,
-      81,    30,   189,    31,    82,    32,    33,   166,   255,   108,
-      83,   113,    34,   145,   109,   249,    35,    36,    37,    38,
-      39,    40,    41,   258,    42,   261,    43,   263,   269,   277,
-     354,   264,   278,    44,   167,   168,   288,   289,    45,    46,
-      47,   351,    48,    49,   352,   368,    50,    51,   311,   270,
-     315,   153,   343,   344,   345,    -6,    52,     2,   113,    84,
-     355,     3,     4,     5,   384,   385,   386,   387,   388,     6,
-       7,   358,   359,   146,   377,   362,     8,     9,   147,   382,
-      10,   364,   310,    11,    12,   363,   367,    13,   369,   371,
-      85,    86,   374,   279,   381,    14,   397,   373,   383,    15,
-     280,   394,   378,   281,   395,    16,    87,    17,   396,   384,
-     385,   386,   387,   388,   219,   257,    18,    19,   392,   239,
-      20,   290,   251,   101,    21,    22,   237,   262,    23,    24,
-     242,   136,   292,   366,   339,   380,    88,   393,   210,   282,
-       0,     0,     0,     0,     0,     0,   357,     0,    25,    26,
-      27,     0,     0,     0,    28,     0,     0,     0,     0,   211,
-       0,     0,   212,    29,     0,     0,     0,    30,   283,    31,
-       0,    32,    33,     0,   223,   224,   225,   226,    34,     0,
-       0,     0,    35,    36,    37,    38,    39,    40,    41,     0,
-      42,     0,    43,     0,     0,     0,     0,     0,     0,    44,
-       0,     0,     0,     0,    45,    46,    47,     0,    48,    49,
-       0,     2,    50,    51,     0,     3,     4,     5,     0,   370,
-       0,    -6,    52,     6,     7,   293,     0,   284,     0,     0,
-       8,     9,     0,   294,    10,     0,     0,    11,    12,     0,
-     213,    13,   214,     0,     0,     0,     0,     0,   215,    14,
-       0,   295,   296,    15,   297,     0,     0,     0,     0,    16,
-     298,    17,     0,     0,     0,     0,     0,   227,   316,     0,
-      18,    19,     0,     0,    20,     0,   317,     0,    21,    22,
-       0,   228,    23,    24,     0,   299,   229,   230,   300,   301,
-       0,   302,   303,   304,     0,   305,     0,     0,     0,     0,
-       0,   172,    25,    26,    27,     0,     0,   173,    28,   174,
-     318,   319,     0,     0,     0,     0,     0,    29,     0,     0,
-       0,    30,     0,    31,     0,    32,    33,   320,     0,     0,
-       0,     0,    34,     0,   175,     0,    35,    36,    37,    38,
-      39,    40,    41,     0,    42,     0,    43,   306,   321,     0,
-       0,     0,     0,    44,   322,     0,   323,     0,    45,    46,
-      47,     0,    48,    49,     0,     0,    50,    51,     0,   324,
-       0,     0,     0,   176,     0,   177,    52,     0,     0,   178,
-       0,   179,     0,     0,   180,     0,   325,   326,     0,     0,
-     125,   126,   127,   128,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,   181,   182,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,   327,
-     129,   328,   130,     0,   131,     0,   329,     0,   132,     0,
-     330
+     114,   155,   253,   247,   248,   197,   347,   160,   339,   313,
+     189,   188,   361,     1,   267,   201,   254,   260,    93,   339,
+     206,     2,   111,   154,   112,     3,     4,     5,   348,   273,
+     274,    77,    78,     6,     7,    79,    99,   255,   117,   207,
+       8,     9,   202,   199,    10,   200,   219,    11,    12,   141,
+     142,    13,   118,   162,   119,   273,   274,   366,   219,    14,
+     375,   120,   208,    15,   292,   137,   150,   143,   237,    16,
+     380,    17,   268,   138,   269,   314,   140,   156,   163,   157,
+      18,    19,   161,   113,    20,   194,   196,   198,    21,    22,
+     204,   205,    23,    24,   164,   309,   310,   165,   210,   221,
+     222,    94,   349,   151,   144,   152,    95,   113,   350,   236,
+     239,   241,    25,    26,    27,   242,   280,   362,    28,   245,
+     246,   249,   239,   281,   251,   351,   282,    29,   250,   259,
+      81,    30,   145,    31,    82,    32,    33,   190,   256,   262,
+      83,   264,    34,   265,   279,   278,    35,    36,    37,    38,
+      39,    40,    41,   289,    42,   102,    43,   290,   270,   103,
+     316,   355,   283,    44,   312,   344,   166,   345,    45,    46,
+      47,   352,    48,    49,   353,   369,    50,    51,   346,   271,
+     356,   153,   359,   360,   363,    -6,    52,   365,   113,    84,
+     364,   284,   146,   167,   168,   374,   368,   147,   372,   169,
+     224,   225,   226,   227,   378,   382,   370,   375,   379,   383,
+     384,     2,   396,   311,   104,     3,     4,     5,   211,   395,
+      85,    86,   397,     6,     7,   220,   398,   291,   258,   240,
+       8,     9,   101,   252,    10,   238,    87,    11,    12,   212,
+     243,    13,   213,   385,   386,   387,   388,   389,   263,    14,
+     285,   136,   393,    15,   381,   340,   105,   293,   394,    16,
+     367,    17,     0,     0,   106,     0,    88,     0,   107,     0,
+      18,    19,     0,     0,    20,     0,     0,   358,    21,    22,
+       0,     0,    23,    24,     0,     0,   108,     0,     0,     0,
+       0,   109,     0,   228,     0,     0,     0,   125,   126,   127,
+     128,     0,    25,    26,    27,     0,     0,   229,    28,     0,
+       0,     0,   230,   231,     0,     0,     0,    29,     0,     0,
+     214,    30,   215,    31,     0,    32,    33,   129,   216,   130,
+       0,   131,    34,     0,     0,   132,    35,    36,    37,    38,
+      39,    40,    41,     0,    42,     0,    43,     0,     0,     0,
+     371,     0,     0,    44,     0,     0,     0,     0,    45,    46,
+      47,     0,    48,    49,     0,     2,    50,    51,     0,     3,
+       4,     5,     0,     0,     0,    -6,    52,     6,     7,   294,
+       0,     0,     0,     0,     8,     9,     0,   295,    10,     0,
+       0,    11,    12,     0,     0,    13,   385,   386,   387,   388,
+     389,     0,     0,    14,     0,   296,   297,    15,   298,     0,
+       0,     0,     0,    16,   299,    17,     0,     0,     0,     0,
+       0,     0,   317,     0,    18,    19,     0,     0,    20,     0,
+     318,     0,    21,    22,     0,     0,    23,    24,     0,   300,
+       0,     0,   301,   302,     0,   303,   304,   305,     0,   306,
+       0,     0,     0,     0,     0,   173,    25,    26,    27,     0,
+       0,   174,    28,   175,   319,   320,     0,     0,     0,     0,
+       0,    29,     0,     0,     0,    30,     0,    31,     0,    32,
+      33,   321,     0,     0,     0,     0,    34,     0,   176,     0,
+      35,    36,    37,    38,    39,    40,    41,     0,    42,     0,
+      43,   307,   322,     0,     0,     0,     0,    44,   323,     0,
+     324,     0,    45,    46,    47,     0,    48,    49,     0,     0,
+      50,    51,     0,   325,     0,     0,     0,   177,     0,   178,
+      52,     0,     0,   179,     0,   180,     0,     0,   181,     0,
+     326,   327,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,   182,
+     183,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,   328,     0,   329,     0,     0,     0,     0,
+     330,     0,     0,     0,   331
 };
 
 static const yytype_int16 yycheck[] =
 {
-      14,    37,   171,   153,   154,    58,     3,    42,    19,    59,
-      54,    47,    23,     1,     4,    58,    37,   186,    10,    89,
-      33,     9,   178,    37,     5,    13,    14,    15,    25,   173,
-     139,   101,   188,    21,    22,   175,   176,    58,    58,    52,
-      28,    29,    58,    57,    32,    59,   139,    35,    36,    30,
-     148,    39,   148,   148,   148,    58,    63,   148,    65,    47,
-       6,     7,    75,    51,   233,    46,    26,    78,    49,    57,
-      31,    59,    62,   117,    64,   125,   148,   148,    24,   188,
-      68,    69,   175,   176,    72,    58,   148,   148,    76,    77,
-     148,    58,    80,    81,   244,   245,     0,    58,   173,   148,
-     148,    93,    99,    63,   187,    65,    98,    58,   105,   120,
-     124,    31,   100,   101,   102,    61,   148,   128,   106,    58,
-     163,   132,   136,   148,   159,   122,    26,   115,    26,    82,
-       7,   119,   185,   121,    11,   123,   124,   118,   159,   150,
-      17,   148,   130,    89,   155,   184,   134,   135,   136,   137,
-     138,   139,   140,    58,   142,    58,   144,    58,   148,    58,
-     310,   173,   148,   151,   145,   146,   148,    58,   156,   157,
-     158,   168,   160,   161,   171,   344,   164,   165,   148,   169,
-      34,   141,   173,   184,   148,   173,   174,     9,   148,    66,
-      26,    13,    14,    15,   179,   180,   181,   182,   183,    21,
-      22,    58,    58,   149,   373,   148,    28,    29,   154,   378,
-      32,   173,   248,    35,    36,   184,   187,    39,   186,   177,
-      97,    98,   178,    28,   173,    47,   395,   184,   187,    51,
-      35,   173,   184,    38,   184,    57,   113,    59,   173,   179,
-     180,   181,   182,   183,    96,   183,    68,    69,   188,   133,
-      72,   231,   169,    11,    76,    77,   121,   190,    80,    81,
-     148,    26,   234,   340,   274,   375,   143,   389,    27,    74,
-      -1,    -1,    -1,    -1,    -1,    -1,   312,    -1,   100,   101,
-     102,    -1,    -1,    -1,   106,    -1,    -1,    -1,    -1,    48,
-      -1,    -1,    51,   115,    -1,    -1,    -1,   119,   103,   121,
-      -1,   123,   124,    -1,    40,    41,    42,    43,   130,    -1,
-      -1,    -1,   134,   135,   136,   137,   138,   139,   140,    -1,
-     142,    -1,   144,    -1,    -1,    -1,    -1,    -1,    -1,   151,
-      -1,    -1,    -1,    -1,   156,   157,   158,    -1,   160,   161,
-      -1,     9,   164,   165,    -1,    13,    14,    15,    -1,   363,
-      -1,   173,   174,    21,    22,    44,    -1,   162,    -1,    -1,
-      28,    29,    -1,    52,    32,    -1,    -1,    35,    36,    -1,
-     129,    39,   131,    -1,    -1,    -1,    -1,    -1,   137,    47,
-      -1,    70,    71,    51,    73,    -1,    -1,    -1,    -1,    57,
-      79,    59,    -1,    -1,    -1,    -1,    -1,   133,     8,    -1,
-      68,    69,    -1,    -1,    72,    -1,    16,    -1,    76,    77,
-      -1,   147,    80,    81,    -1,   104,   152,   153,   107,   108,
-      -1,   110,   111,   112,    -1,   114,    -1,    -1,    -1,    -1,
-      -1,    12,   100,   101,   102,    -1,    -1,    18,   106,    20,
-      50,    51,    -1,    -1,    -1,    -1,    -1,   115,    -1,    -1,
-      -1,   119,    -1,   121,    -1,   123,   124,    67,    -1,    -1,
-      -1,    -1,   130,    -1,    45,    -1,   134,   135,   136,   137,
-     138,   139,   140,    -1,   142,    -1,   144,   166,    88,    -1,
-      -1,    -1,    -1,   151,    94,    -1,    96,    -1,   156,   157,
-     158,    -1,   160,   161,    -1,    -1,   164,   165,    -1,   109,
-      -1,    -1,    -1,    84,    -1,    86,   174,    -1,    -1,    90,
-      -1,    92,    -1,    -1,    95,    -1,   126,   127,    -1,    -1,
-      53,    54,    55,    56,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,   116,   117,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   159,
-      83,   161,    85,    -1,    87,    -1,   166,    -1,    91,    -1,
-     170
+      14,    37,   172,   153,   154,    54,     3,    42,   139,    59,
+      58,    47,    58,     1,     4,    31,    37,   187,    10,   139,
+      33,     9,    63,    37,    65,    13,    14,    15,    25,   175,
+     176,   173,    58,    21,    22,    58,   148,    58,   148,    52,
+      28,    29,    58,    57,    32,    59,    89,    35,    36,     6,
+       7,    39,   148,     5,   148,   175,   176,   188,   101,    47,
+     178,   148,    75,    51,   234,   148,    26,    24,   117,    57,
+     188,    59,    62,   148,    64,   125,    58,    58,    30,   148,
+      68,    69,   148,   148,    72,    58,     0,   173,    76,    77,
+     148,   148,    80,    81,    46,   245,   246,    49,   187,    58,
+      31,    93,    99,    63,    61,    65,    98,   148,   105,   148,
+     124,    58,   100,   101,   102,   148,    28,   163,   106,    26,
+      26,    82,   136,    35,   159,   122,    38,   115,   184,    58,
+       7,   119,    89,   121,    11,   123,   124,   185,   159,    58,
+      17,    58,   130,   173,   148,    58,   134,   135,   136,   137,
+     138,   139,   140,   148,   142,    19,   144,    58,   148,    23,
+      34,   311,    74,   151,   148,   173,   118,   184,   156,   157,
+     158,   168,   160,   161,   171,   345,   164,   165,   148,   169,
+      26,   141,    58,    58,   148,   173,   174,   173,   148,    66,
+     184,   103,   149,   145,   146,   184,   187,   154,   177,   151,
+      40,    41,    42,    43,   374,   173,   186,   178,   184,   379,
+     187,     9,   184,   249,    78,    13,    14,    15,    27,   173,
+      97,    98,   173,    21,    22,    96,   396,   232,   184,   133,
+      28,    29,    11,   170,    32,   121,   113,    35,    36,    48,
+     148,    39,    51,   179,   180,   181,   182,   183,   191,    47,
+     162,    26,   188,    51,   376,   275,   120,   235,   390,    57,
+     341,    59,    -1,    -1,   128,    -1,   143,    -1,   132,    -1,
+      68,    69,    -1,    -1,    72,    -1,    -1,   313,    76,    77,
+      -1,    -1,    80,    81,    -1,    -1,   150,    -1,    -1,    -1,
+      -1,   155,    -1,   133,    -1,    -1,    -1,    53,    54,    55,
+      56,    -1,   100,   101,   102,    -1,    -1,   147,   106,    -1,
+      -1,    -1,   152,   153,    -1,    -1,    -1,   115,    -1,    -1,
+     129,   119,   131,   121,    -1,   123,   124,    83,   137,    85,
+      -1,    87,   130,    -1,    -1,    91,   134,   135,   136,   137,
+     138,   139,   140,    -1,   142,    -1,   144,    -1,    -1,    -1,
+     364,    -1,    -1,   151,    -1,    -1,    -1,    -1,   156,   157,
+     158,    -1,   160,   161,    -1,     9,   164,   165,    -1,    13,
+      14,    15,    -1,    -1,    -1,   173,   174,    21,    22,    44,
+      -1,    -1,    -1,    -1,    28,    29,    -1,    52,    32,    -1,
+      -1,    35,    36,    -1,    -1,    39,   179,   180,   181,   182,
+     183,    -1,    -1,    47,    -1,    70,    71,    51,    73,    -1,
+      -1,    -1,    -1,    57,    79,    59,    -1,    -1,    -1,    -1,
+      -1,    -1,     8,    -1,    68,    69,    -1,    -1,    72,    -1,
+      16,    -1,    76,    77,    -1,    -1,    80,    81,    -1,   104,
+      -1,    -1,   107,   108,    -1,   110,   111,   112,    -1,   114,
+      -1,    -1,    -1,    -1,    -1,    12,   100,   101,   102,    -1,
+      -1,    18,   106,    20,    50,    51,    -1,    -1,    -1,    -1,
+      -1,   115,    -1,    -1,    -1,   119,    -1,   121,    -1,   123,
+     124,    67,    -1,    -1,    -1,    -1,   130,    -1,    45,    -1,
+     134,   135,   136,   137,   138,   139,   140,    -1,   142,    -1,
+     144,   166,    88,    -1,    -1,    -1,    -1,   151,    94,    -1,
+      96,    -1,   156,   157,   158,    -1,   160,   161,    -1,    -1,
+     164,   165,    -1,   109,    -1,    -1,    -1,    84,    -1,    86,
+     174,    -1,    -1,    90,    -1,    92,    -1,    -1,    95,    -1,
+     126,   127,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   116,
+     117,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,   159,    -1,   161,    -1,    -1,    -1,    -1,
+     166,    -1,    -1,    -1,   170
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1411,30 +1415,30 @@ static const yytype_uint16 yystos[] =
       85,    87,    91,   232,   233,   234,   272,   148,   148,   271,
       58,     6,     7,    24,    61,    89,   149,   154,   265,   266,
       26,    63,    65,   141,   195,   196,    58,   148,   254,   219,
-     220,   148,     5,    30,    46,    49,   118,   145,   146,   246,
-     247,   248,    12,    18,    20,    45,    84,    86,    90,    92,
-      95,   116,   117,   214,   215,   216,   217,   196,    58,   185,
-     268,   269,   270,    58,   267,     0,   192,   173,   195,   195,
-      31,    58,   274,   148,   148,    33,    52,    75,   263,   187,
-      27,    48,    51,   129,   131,   137,   211,   212,   242,   230,
-      58,    31,   221,    40,    41,    42,    43,   133,   147,   152,
-     153,   236,   237,   238,   239,   148,   192,   259,   195,   233,
-      58,   148,   266,   227,    26,    26,   227,   227,    82,   184,
-     220,   247,   274,    37,    58,   159,   273,   215,    58,   274,
-     256,    58,   269,    58,   173,   198,     4,    62,    64,   148,
-     169,   262,   175,   176,   277,   278,   279,    58,   148,    28,
-      35,    38,    74,   103,   162,   222,   223,   224,   148,    58,
-     237,   274,   273,    44,    52,    70,    71,    73,    79,   104,
-     107,   108,   110,   111,   112,   114,   166,   228,   227,   227,
-     196,   148,    59,   125,   257,    34,     8,    16,    50,    51,
-      67,    88,    94,    96,   109,   126,   127,   159,   161,   166,
-     170,   199,   200,   201,   202,   203,   204,   205,   139,   278,
-     280,   281,   283,   173,   184,   148,     3,    25,    99,   105,
-     122,   168,   171,   225,   227,    26,   255,   196,    58,    58,
-      58,   163,   148,   184,   173,   188,   281,   187,   274,   186,
-     195,   177,   282,   184,   178,   284,   285,   274,   184,   188,
-     285,   173,   274,   187,   179,   180,   181,   182,   183,   286,
-     287,   288,   188,   287,   173,   184,   173,   274
+     220,   148,     5,    30,    46,    49,   118,   145,   146,   151,
+     246,   247,   248,    12,    18,    20,    45,    84,    86,    90,
+      92,    95,   116,   117,   214,   215,   216,   217,   196,    58,
+     185,   268,   269,   270,    58,   267,     0,   192,   173,   195,
+     195,    31,    58,   274,   148,   148,    33,    52,    75,   263,
+     187,    27,    48,    51,   129,   131,   137,   211,   212,   242,
+     230,    58,    31,   221,    40,    41,    42,    43,   133,   147,
+     152,   153,   236,   237,   238,   239,   148,   192,   259,   195,
+     233,    58,   148,   266,   227,    26,    26,   227,   227,    82,
+     184,   220,   247,   274,    37,    58,   159,   273,   215,    58,
+     274,   256,    58,   269,    58,   173,   198,     4,    62,    64,
+     148,   169,   262,   175,   176,   277,   278,   279,    58,   148,
+      28,    35,    38,    74,   103,   162,   222,   223,   224,   148,
+      58,   237,   274,   273,    44,    52,    70,    71,    73,    79,
+     104,   107,   108,   110,   111,   112,   114,   166,   228,   227,
+     227,   196,   148,    59,   125,   257,    34,     8,    16,    50,
+      51,    67,    88,    94,    96,   109,   126,   127,   159,   161,
+     166,   170,   199,   200,   201,   202,   203,   204,   205,   139,
+     278,   280,   281,   283,   173,   184,   148,     3,    25,    99,
+     105,   122,   168,   171,   225,   227,    26,   255,   196,    58,
+      58,    58,   163,   148,   184,   173,   188,   281,   187,   274,
+     186,   195,   177,   282,   184,   178,   284,   285,   274,   184,
+     188,   285,   173,   274,   187,   179,   180,   181,   182,   183,
+     286,   287,   288,   188,   287,   173,   184,   173,   274
 };
 
 #define yyerrok		(yyerrstatus = 0)
@@ -3009,10 +3013,10 @@ yyreduce:
     { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Double)); }
     break;
 
-  case 205:
+  case 206:
 
 /* Line 1464 of yacc.c  */
-#line 1063 "ntp_parser.y"
+#line 1064 "ntp_parser.y"
     {
 			attr_val *av;
 			
@@ -3021,10 +3025,10 @@ yyreduce:
 		}
     break;
 
-  case 206:
+  case 207:
 
 /* Line 1464 of yacc.c  */
-#line 1070 "ntp_parser.y"
+#line 1071 "ntp_parser.y"
     {
 			attr_val *av;
 			
@@ -3033,10 +3037,10 @@ yyreduce:
 		}
     break;
 
-  case 207:
+  case 208:
 
 /* Line 1464 of yacc.c  */
-#line 1077 "ntp_parser.y"
+#line 1078 "ntp_parser.y"
     {
 			char error_text[64];
 			attr_val *av;
@@ -3054,10 +3058,10 @@ yyreduce:
 		}
     break;
 
-  case 208:
+  case 209:
 
 /* Line 1464 of yacc.c  */
-#line 1093 "ntp_parser.y"
+#line 1094 "ntp_parser.y"
     {
 			if (!input_from_file) {
 				yyerror("remote includefile ignored");
@@ -3078,48 +3082,48 @@ yyreduce:
 		}
     break;
 
-  case 209:
+  case 210:
 
 /* Line 1464 of yacc.c  */
-#line 1112 "ntp_parser.y"
+#line 1113 "ntp_parser.y"
     {
 			while (curr_include_level != -1)
 				FCLOSE(fp[curr_include_level--]);
 		}
     break;
 
-  case 210:
+  case 211:
 
 /* Line 1464 of yacc.c  */
-#line 1117 "ntp_parser.y"
+#line 1118 "ntp_parser.y"
     { /* see drift_parm below for actions */ }
     break;
 
-  case 211:
+  case 212:
 
 /* Line 1464 of yacc.c  */
-#line 1119 "ntp_parser.y"
+#line 1120 "ntp_parser.y"
     { CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[(2) - (2)].Attr_val_fifo)); }
     break;
 
-  case 212:
+  case 213:
 
 /* Line 1464 of yacc.c  */
-#line 1121 "ntp_parser.y"
+#line 1122 "ntp_parser.y"
     { CONCAT_G_FIFOS(cfgt.phone, (yyvsp[(2) - (2)].String_fifo)); }
     break;
 
-  case 213:
+  case 214:
 
 /* Line 1464 of yacc.c  */
-#line 1123 "ntp_parser.y"
+#line 1124 "ntp_parser.y"
     { APPEND_G_FIFO(cfgt.setvar, (yyvsp[(2) - (2)].Set_var)); }
     break;
 
-  case 214:
+  case 215:
 
 /* Line 1464 of yacc.c  */
-#line 1125 "ntp_parser.y"
+#line 1126 "ntp_parser.y"
     {
 			addr_opts_node *aon;
 			
@@ -3128,17 +3132,17 @@ yyreduce:
 		}
     break;
 
-  case 215:
+  case 216:
 
 /* Line 1464 of yacc.c  */
-#line 1132 "ntp_parser.y"
+#line 1133 "ntp_parser.y"
     { CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[(2) - (2)].Attr_val_fifo)); }
     break;
 
-  case 225:
+  case 226:
 
 /* Line 1464 of yacc.c  */
-#line 1155 "ntp_parser.y"
+#line 1156 "ntp_parser.y"
     {
 			attr_val *av;
 			
@@ -3147,10 +3151,10 @@ yyreduce:
 		}
     break;
 
-  case 226:
+  case 227:
 
 /* Line 1464 of yacc.c  */
-#line 1162 "ntp_parser.y"
+#line 1163 "ntp_parser.y"
     {
 			attr_val *av;
 			
@@ -3161,10 +3165,10 @@ yyreduce:
 		}
     break;
 
-  case 227:
+  case 228:
 
 /* Line 1464 of yacc.c  */
-#line 1171 "ntp_parser.y"
+#line 1172 "ntp_parser.y"
     {
 			attr_val *av;
 			
@@ -3173,78 +3177,78 @@ yyreduce:
 		}
     break;
 
-  case 228:
+  case 229:
 
 /* Line 1464 of yacc.c  */
-#line 1181 "ntp_parser.y"
+#line 1182 "ntp_parser.y"
     { (yyval.Set_var) = create_setvar_node((yyvsp[(1) - (4)].String), (yyvsp[(3) - (4)].String), (yyvsp[(4) - (4)].Integer)); }
     break;
 
-  case 230:
+  case 231:
 
 /* Line 1464 of yacc.c  */
-#line 1187 "ntp_parser.y"
+#line 1188 "ntp_parser.y"
     { (yyval.Integer) = 0; }
     break;
 
-  case 231:
+  case 232:
 
 /* Line 1464 of yacc.c  */
-#line 1192 "ntp_parser.y"
+#line 1193 "ntp_parser.y"
     { (yyval.Attr_val_fifo) = NULL; }
     break;
 
-  case 232:
+  case 233:
 
 /* Line 1464 of yacc.c  */
-#line 1194 "ntp_parser.y"
+#line 1195 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val));
 		}
     break;
 
-  case 233:
+  case 234:
 
 /* Line 1464 of yacc.c  */
-#line 1202 "ntp_parser.y"
+#line 1203 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival((yyvsp[(1) - (2)].Integer), (yyvsp[(2) - (2)].Integer)); }
     break;
 
-  case 234:
+  case 235:
 
 /* Line 1464 of yacc.c  */
-#line 1204 "ntp_parser.y"
+#line 1205 "ntp_parser.y"
     {
 			(yyval.Attr_val) = create_attr_sval((yyvsp[(1) - (2)].Integer), estrdup((yyvsp[(2) - (2)].Address_node)->address));
 			destroy_address_node((yyvsp[(2) - (2)].Address_node));
 		}
     break;
 
-  case 235:
+  case 236:
 
 /* Line 1464 of yacc.c  */
-#line 1212 "ntp_parser.y"
+#line 1213 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val));
 		}
     break;
 
-  case 236:
+  case 237:
 
 /* Line 1464 of yacc.c  */
-#line 1217 "ntp_parser.y"
+#line 1218 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val));
 		}
     break;
 
-  case 237:
+  case 238:
 
 /* Line 1464 of yacc.c  */
-#line 1225 "ntp_parser.y"
+#line 1226 "ntp_parser.y"
     {
 			char	prefix;
 			char *	type;
@@ -3268,10 +3272,10 @@ yyreduce:
 		}
     break;
 
-  case 238:
+  case 239:
 
 /* Line 1464 of yacc.c  */
-#line 1250 "ntp_parser.y"
+#line 1251 "ntp_parser.y"
     {
 			nic_rule_node *nrn;
 			
@@ -3280,10 +3284,10 @@ yyreduce:
 		}
     break;
 
-  case 239:
+  case 240:
 
 /* Line 1464 of yacc.c  */
-#line 1257 "ntp_parser.y"
+#line 1258 "ntp_parser.y"
     {
 			nic_rule_node *nrn;
 			
@@ -3292,131 +3296,131 @@ yyreduce:
 		}
     break;
 
-  case 249:
+  case 250:
 
 /* Line 1464 of yacc.c  */
-#line 1285 "ntp_parser.y"
+#line 1286 "ntp_parser.y"
     { CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[(2) - (2)].Int_fifo)); }
     break;
 
-  case 250:
+  case 251:
 
 /* Line 1464 of yacc.c  */
-#line 1290 "ntp_parser.y"
+#line 1291 "ntp_parser.y"
     {
 			(yyval.Int_fifo) = (yyvsp[(1) - (2)].Int_fifo);
 			APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(2) - (2)].Integer)));
 		}
     break;
 
-  case 251:
+  case 252:
 
 /* Line 1464 of yacc.c  */
-#line 1295 "ntp_parser.y"
+#line 1296 "ntp_parser.y"
     {
 			(yyval.Int_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[(1) - (1)].Integer)));
 		}
     break;
 
-  case 259:
+  case 260:
 
 /* Line 1464 of yacc.c  */
-#line 1319 "ntp_parser.y"
+#line 1320 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[(2) - (2)].Integer)));
 		}
     break;
 
-  case 260:
+  case 261:
 
 /* Line 1464 of yacc.c  */
-#line 1324 "ntp_parser.y"
+#line 1325 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[(1) - (1)].Integer)));
 		}
     break;
 
-  case 261:
+  case 262:
 
 /* Line 1464 of yacc.c  */
-#line 1332 "ntp_parser.y"
+#line 1333 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = (yyvsp[(1) - (2)].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (2)].Attr_val));
 		}
     break;
 
-  case 262:
+  case 263:
 
 /* Line 1464 of yacc.c  */
-#line 1337 "ntp_parser.y"
+#line 1338 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (1)].Attr_val));
 		}
     break;
 
-  case 263:
+  case 264:
 
 /* Line 1464 of yacc.c  */
-#line 1345 "ntp_parser.y"
+#line 1346 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_ival('i', (yyvsp[(1) - (1)].Integer)); }
     break;
 
-  case 265:
+  case 266:
 
 /* Line 1464 of yacc.c  */
-#line 1351 "ntp_parser.y"
+#line 1352 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[(2) - (5)].Integer), (yyvsp[(4) - (5)].Integer)); }
     break;
 
-  case 266:
+  case 267:
 
 /* Line 1464 of yacc.c  */
-#line 1356 "ntp_parser.y"
+#line 1357 "ntp_parser.y"
     {
 			(yyval.String_fifo) = (yyvsp[(1) - (2)].String_fifo);
 			APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[(2) - (2)].String)));
 		}
     break;
 
-  case 267:
+  case 268:
 
 /* Line 1464 of yacc.c  */
-#line 1361 "ntp_parser.y"
+#line 1362 "ntp_parser.y"
     {
 			(yyval.String_fifo) = NULL;
 			APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[(1) - (1)].String)));
 		}
     break;
 
-  case 268:
+  case 269:
 
 /* Line 1464 of yacc.c  */
-#line 1369 "ntp_parser.y"
+#line 1370 "ntp_parser.y"
     {
 			(yyval.Address_fifo) = (yyvsp[(1) - (2)].Address_fifo);
 			APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[(2) - (2)].Address_node));
 		}
     break;
 
-  case 269:
+  case 270:
 
 /* Line 1464 of yacc.c  */
-#line 1374 "ntp_parser.y"
+#line 1375 "ntp_parser.y"
     {
 			(yyval.Address_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[(1) - (1)].Address_node));
 		}
     break;
 
-  case 270:
+  case 271:
 
 /* Line 1464 of yacc.c  */
-#line 1382 "ntp_parser.y"
+#line 1383 "ntp_parser.y"
     {
 			if ((yyvsp[(1) - (1)].Integer) != 0 && (yyvsp[(1) - (1)].Integer) != 1) {
 				yyerror("Integer value is not boolean (0 or 1). Assuming 1");
@@ -3427,31 +3431,31 @@ yyreduce:
 		}
     break;
 
-  case 271:
+  case 272:
 
 /* Line 1464 of yacc.c  */
-#line 1390 "ntp_parser.y"
+#line 1391 "ntp_parser.y"
     { (yyval.Integer) = 1; }
     break;
 
-  case 272:
+  case 273:
 
 /* Line 1464 of yacc.c  */
-#line 1391 "ntp_parser.y"
+#line 1392 "ntp_parser.y"
     { (yyval.Integer) = 0; }
     break;
 
-  case 273:
+  case 274:
 
 /* Line 1464 of yacc.c  */
-#line 1395 "ntp_parser.y"
+#line 1396 "ntp_parser.y"
     { (yyval.Double) = (double)(yyvsp[(1) - (1)].Integer); }
     break;
 
-  case 275:
+  case 276:
 
 /* Line 1464 of yacc.c  */
-#line 1406 "ntp_parser.y"
+#line 1407 "ntp_parser.y"
     {
 			sim_node *sn;
 			
@@ -3463,139 +3467,139 @@ yyreduce:
 		}
     break;
 
-  case 276:
+  case 277:
 
 /* Line 1464 of yacc.c  */
-#line 1423 "ntp_parser.y"
+#line 1424 "ntp_parser.y"
     { old_config_style = 0; }
     break;
 
-  case 277:
+  case 278:
 
 /* Line 1464 of yacc.c  */
-#line 1428 "ntp_parser.y"
+#line 1429 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = (yyvsp[(1) - (3)].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (3)].Attr_val));
 		}
     break;
 
-  case 278:
+  case 279:
 
 /* Line 1464 of yacc.c  */
-#line 1433 "ntp_parser.y"
+#line 1434 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (2)].Attr_val));
 		}
     break;
 
-  case 279:
+  case 280:
 
 /* Line 1464 of yacc.c  */
-#line 1441 "ntp_parser.y"
+#line 1442 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); }
     break;
 
-  case 282:
+  case 283:
 
 /* Line 1464 of yacc.c  */
-#line 1451 "ntp_parser.y"
+#line 1452 "ntp_parser.y"
     {
 			(yyval.Sim_server_fifo) = (yyvsp[(1) - (2)].Sim_server_fifo);
 			APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[(2) - (2)].Sim_server));
 		}
     break;
 
-  case 283:
+  case 284:
 
 /* Line 1464 of yacc.c  */
-#line 1456 "ntp_parser.y"
+#line 1457 "ntp_parser.y"
     {
 			(yyval.Sim_server_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[(1) - (1)].Sim_server));
 		}
     break;
 
-  case 284:
+  case 285:
 
 /* Line 1464 of yacc.c  */
-#line 1464 "ntp_parser.y"
+#line 1465 "ntp_parser.y"
     { (yyval.Sim_server) = create_sim_server((yyvsp[(1) - (5)].Address_node), (yyvsp[(3) - (5)].Double), (yyvsp[(4) - (5)].Sim_script_fifo)); }
     break;
 
-  case 285:
+  case 286:
 
 /* Line 1464 of yacc.c  */
-#line 1469 "ntp_parser.y"
+#line 1470 "ntp_parser.y"
     { (yyval.Double) = (yyvsp[(3) - (4)].Double); }
     break;
 
-  case 286:
+  case 287:
 
 /* Line 1464 of yacc.c  */
-#line 1474 "ntp_parser.y"
+#line 1475 "ntp_parser.y"
     { (yyval.Address_node) = (yyvsp[(3) - (3)].Address_node); }
     break;
 
-  case 287:
+  case 288:
 
 /* Line 1464 of yacc.c  */
-#line 1479 "ntp_parser.y"
+#line 1480 "ntp_parser.y"
     {
 			(yyval.Sim_script_fifo) = (yyvsp[(1) - (2)].Sim_script_fifo);
 			APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[(2) - (2)].Sim_script));
 		}
     break;
 
-  case 288:
+  case 289:
 
 /* Line 1464 of yacc.c  */
-#line 1484 "ntp_parser.y"
+#line 1485 "ntp_parser.y"
     {
 			(yyval.Sim_script_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[(1) - (1)].Sim_script));
 		}
     break;
 
-  case 289:
+  case 290:
 
 /* Line 1464 of yacc.c  */
-#line 1492 "ntp_parser.y"
+#line 1493 "ntp_parser.y"
     { (yyval.Sim_script) = create_sim_script_info((yyvsp[(3) - (6)].Double), (yyvsp[(5) - (6)].Attr_val_fifo)); }
     break;
 
-  case 290:
+  case 291:
 
 /* Line 1464 of yacc.c  */
-#line 1497 "ntp_parser.y"
+#line 1498 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = (yyvsp[(1) - (3)].Attr_val_fifo);
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(2) - (3)].Attr_val));
 		}
     break;
 
-  case 291:
+  case 292:
 
 /* Line 1464 of yacc.c  */
-#line 1502 "ntp_parser.y"
+#line 1503 "ntp_parser.y"
     {
 			(yyval.Attr_val_fifo) = NULL;
 			APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[(1) - (2)].Attr_val));
 		}
     break;
 
-  case 292:
+  case 293:
 
 /* Line 1464 of yacc.c  */
-#line 1510 "ntp_parser.y"
+#line 1511 "ntp_parser.y"
     { (yyval.Attr_val) = create_attr_dval((yyvsp[(1) - (3)].Integer), (yyvsp[(3) - (3)].Double)); }
     break;
 
 
 
 /* Line 1464 of yacc.c  */
-#line 3599 "ntp_parser.c"
+#line 3603 "ntp_parser.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3807,7 +3811,7 @@ yyreturn:
 
 
 /* Line 1684 of yacc.c  */
-#line 1521 "ntp_parser.y"
+#line 1522 "ntp_parser.y"
 
 
 void 

==== ntpd/ntp_parser.y ====
2011-12-18 04:24:56+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  support "tinker tick 0.01" syntax alongside older "tick 0.01"

--- 1.71/ntpd/ntp_parser.y	2011-10-31 00:40:02 -04:00
+++ 1.72/ntpd/ntp_parser.y	2011-12-17 23:24:56 -05:00
@@ -1049,6 +1049,7 @@ tinker_option_keyword
 	|	T_Panic
 	|	T_Step
 	|	T_Stepout
+	|	T_Tick
 	;
 
 

==== ntpd/ntp_proto.c ====
2011-12-18 04:24:56+00:00, davehart at shiny.ad.hartbrothers.com +46 -17
  [Bug 2015] Overriding sys_tick should recalculate sys_precision.
  [Bug 2068] "tos ceiling" default and cap changed to 15.
  Floor peer delay using system precision, as with jitter, reflecting
    inability to measure shorter intervals.

--- 1.336/ntpd/ntp_proto.c	2011-12-16 21:31:04 -05:00
+++ 1.337/ntpd/ntp_proto.c	2011-12-17 23:24:56 -05:00
@@ -108,7 +108,7 @@ char	*sys_ident = NULL;	/* identity sche
  * TOS and multicast mapping stuff
  */
 int	sys_floor = 0;		/* cluster stratum floor */
-int	sys_ceiling = STRATUM_UNSPEC; /* cluster stratum ceiling */
+int	sys_ceiling = STRATUM_UNSPEC - 1; /* cluster stratum ceiling */
 int	sys_minsane = 1;	/* minimum candidates */
 int	sys_minclock = NTP_MINCLOCK; /* minimum candidates */
 int	sys_maxclock = NTP_MAXCLOCK; /* maximum candidates */
@@ -140,7 +140,7 @@ static	void	peer_xmit	(struct peer *);
 static	void	fast_xmit	(struct recvbuf *, int, keyid_t, int);
 static	void	pool_xmit	(struct peer *);
 static	void	clock_update	(struct peer *);
-static	int	default_get_precision (void);
+static	void	measure_precision(void);
 static	int	local_refid	(struct peer *);
 static	int	peer_unfit	(struct peer *);
 #ifdef AUTOKEY
@@ -1692,6 +1692,7 @@ process_packet(
 		p_del = fabs(t21 - t34);
 		p_offset = (t21 + t34) / 2.;
 	}
+	p_del = max(p_del, LOGTOD(sys_precision));
 	p_disp = LOGTOD(sys_precision) + LOGTOD(peer->precision) +
 	    clock_phi * p_del;
 
@@ -3804,7 +3805,7 @@ peer_unfit(
 /*
  * Find the precision of this particular machine
  */
-#define MINSTEP		100e-9	/* minimum clock increment (s) */
+#define MINSTEP		20e-9	/* minimum clock increment (s) */
 #define MAXSTEP		1	/* maximum clock increment (s) */
 #define MINCHANGES	5	/* minimum number of step samples */
 #define MAXLOOPS	((int)(1. / MINSTEP))	/* avoid infinite loop */
@@ -3829,8 +3830,8 @@ peer_unfit(
  * to read the clock is saved as sys_fuzz, and used to ensure the
  * get_systime() readings always increase and are fuzzed below sys_fuzz.
  */
-int
-default_get_precision(void)
+void
+measure_precision(void)
 {
 	l_fp	val;		/* current seconds fraction */
 	l_fp	last;		/* last seconds fraction */
@@ -3845,13 +3846,17 @@ default_get_precision(void)
 	/*
 	 * Loop to find precision value in seconds.  With sys_fuzz set
 	 * to zero, get_systime() disables its fuzzing of low bits.
+	 * measured_tick and sys_tick are zeroed to disable get_ostime()
+	 * low-precision clock simulation.
 	 */
 	tick = MAXSTEP;
+	sys_tick = 0;
+	measured_tick = 0;
 	set_sys_fuzz(0.);
-	get_systime(&last);
 	max_repeats = 0;
 	repeats = 0;
 	changes = 0;
+	get_systime(&last);
 	for (i = 0; i < MAXLOOPS && changes < MINCHANGES; i++) {
 		get_systime(&val);
 		ldiff = val;
@@ -3871,15 +3876,43 @@ default_get_precision(void)
 		msyslog(LOG_ERR, "Fatal error: precision could not be measured (MINSTEP too large?)");
 		exit(1);
 	}
-	sys_tick = tick;
+	measured_tick = tick;
+	set_sys_tick_precision(tick);
 	if (0 == max_repeats) {
-		set_sys_fuzz(sys_tick);
+		set_sys_fuzz(tick);
 	} else {
-		set_sys_fuzz(sys_tick / max_repeats);
+		set_sys_fuzz(tick / max_repeats);
 		msyslog(LOG_NOTICE, "proto: fuzz beneath %.3f usec",
 			sys_fuzz * 1e6);
 	}
 
+}
+
+
+void
+set_sys_tick_precision(
+	double tick
+	)
+{
+	int i;
+
+	if (tick > 1.) {
+		msyslog(LOG_ERR,
+			"unsupported tick %.3f > 1s ignored", tick);
+		return;
+	}
+	if (tick < measured_tick) {
+		msyslog(LOG_ERR,
+			"proto: tick %.3f less than measured tick %.3f, ignored",
+			tick, measured_tick);
+		return;
+	} else if (tick > measured_tick) {
+		msyslog(LOG_NOTICE,
+			"proto: truncating system clock to multiples of %.9f",
+			tick);
+	}
+	sys_tick = tick;
+
 	/*
 	 * Find the nearest power of two.
 	 */
@@ -3887,10 +3920,10 @@ default_get_precision(void)
 		tick *= 2;
 	if (tick - 1 > 1 - tick / 2)
 		i++;
-	msyslog(LOG_NOTICE, "proto: precision = %.3f usec (%d)",
-		sys_tick * 1e6, i);
 
-	return i;
+	sys_precision = (s_char)i;
+	msyslog(LOG_NOTICE, "proto: precision = %.3f usec (%d)",
+		sys_tick * 1e6, sys_precision);
 }
 
 
@@ -3915,7 +3948,7 @@ init_proto(void)
 	sys_rootdisp = 0;
 	L_CLR(&sys_reftime);
 	sys_jitter = 0;
-	sys_precision = (s_char)default_get_precision();
+	measure_precision();
 	get_systime(&dummy);
 	sys_survivors = 0;
 	sys_manycastserver = 0;
@@ -4055,10 +4088,6 @@ proto_config(
 		orphwait -= sys_orphwait;
 		sys_orphwait = (int)dvalue;
 		orphwait += sys_orphwait;
-		break;
-
-	case PROTO_ADJ:		/* tick increment (tick) */
-		sys_tick = dvalue;
 		break;
 
 	/*

==== ports/winnt/ntpd/nt_clockstuff.c ====
2011-12-18 04:24:56+00:00, davehart at shiny.ad.hartbrothers.com +6 -13
  nonfunctional cleanup

--- 1.54/ports/winnt/ntpd/nt_clockstuff.c	2011-12-16 21:30:40 -05:00
+++ 1.55/ports/winnt/ntpd/nt_clockstuff.c	2011-12-17 23:24:56 -05:00
@@ -559,15 +559,10 @@ adj_systime(
 
 
 	sys_residual = dtemp / 1e6;
-#if 0
-	msyslog(LOG_NOTICE, "adj_systime: %.9f -> %.9f residual %.9f", 
-		    now, 1e-6 * (TimeAdjustment * ppm_per_adjust_unit),
-		    sys_residual);
-#endif
 	DPRINTF(3, ("adj_systime: %.9f -> %.9f residual %.9f", 
 		    now, 1e-6 * (TimeAdjustment * ppm_per_adjust_unit),
 		    sys_residual));
-	if (0 == adjtime_carry)
+	if (0. == adjtime_carry)
 		DPRINTF(3, ("\n"));
 	else
 		DPRINTF(3, (" adjtime %.9f\n", adjtime_carry));
@@ -577,16 +572,14 @@ adj_systime(
 	if (last_Adj != TimeAdjustment) {
 		last_Adj = TimeAdjustment;
 		DPRINTF(2, ("SetSystemTimeAdjustment(%+ld)\n", TimeAdjustment));
-		rc = !SetSystemTimeAdjustment(clockperiod + TimeAdjustment, FALSE);
+		rc = SetSystemTimeAdjustment(clockperiod + TimeAdjustment, FALSE);
+		if (!rc)
+			msyslog(LOG_ERR, "Can't adjust time: %m");
 	} else {
-		rc = FALSE;
-	}
-	if (rc) {
-		msyslog(LOG_ERR, "Can't adjust time: %m");
-		return FALSE;
+		rc = TRUE;
 	}
 
-	return TRUE;
+	return rc;
 }
 
 

==== util/ntp-keygen.c ====
2011-12-18 04:24:56+00:00, davehart at shiny.ad.hartbrothers.com +1 -2
  remove now-redundant MAXHOSTNAME declaration (in ntp.h)

--- 1.87/util/ntp-keygen.c	2011-10-30 23:52:18 -04:00
+++ 1.88/util/ntp-keygen.c	2011-12-17 23:24:56 -05:00
@@ -114,8 +114,7 @@
 #define	MD5SIZE		20	/* maximum key size */
 #define DAY		((long)60*60*24) /* one day in seconds */
 #define	YEAR		((long)365) /* one year in days */
-#define MAXFILENAME	256	/* max file name length */
-#define MAXHOSTNAME	256	/* max host name length */
+#define MAXFILENAME	MAXHOSTNAME /* max file name length */
 #ifdef AUTOKEY
 #define	PLEN		512	/* default prime modulus size (bits) */
 #define	ILEN		256	/* default identity modulus size (bits) */

#### ChangeSet ####
2011-12-17 02:30:42+00:00, davehart at shiny.ad.hartbrothers.com
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

==== ChangeLog ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +1 -0
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.1065/ChangeLog	2011-12-01 00:30:17 -05:00
+++ 1.1065.1.1/ChangeLog	2011-12-16 21:30:40 -05:00
@@ -1,3 +1,4 @@
+* [Bug 2037] Fuzzed non-interpolated clock may decrease.
 (4.2.7p237) 2011/12/01 Released by Harlan Stenn <stenn at ntp.org>
 * [Bug 2050] from 4.2.6p5-RC2: Orphan mode stratum counting to infinity.
 * [Bug 2059] from 4.2.6p5-RC2: optional billboard column "server" does

==== include/ntp_fp.h ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +7 -1
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.26/include/ntp_fp.h	2011-11-26 18:06:48 -05:00
+++ 1.27/include/ntp_fp.h	2011-12-16 21:30:40 -05:00
@@ -199,12 +199,16 @@ typedef u_int32 u_fp;
 #define	M_ISNEG(v_i, v_f)		/* v < 0 */ \
 	(((v_i) & 0x80000000u) != 0)
 
+#define	M_ISGTU(a_i, a_f, b_i, b_f)	/* a > b unsigned */ \
+	(((u_int32)(a_i)) > ((u_int32)(b_i)) || \
+	  ((a_i) == (b_i) && ((u_int32)(a_f)) > ((u_int32)(b_f))))
+
 #define	M_ISHIS(a_i, a_f, b_i, b_f)	/* a >= b unsigned */ \
 	(((u_int32)(a_i)) > ((u_int32)(b_i)) || \
 	  ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
 
 #define	M_ISGEQ(a_i, a_f, b_i, b_f)	/* a >= b signed */ \
-	(((u_int32)(a_i) - (u_int32)(b_i) + 0x80000000u > 0x80000000u) || \
+	(((u_int32)(a_i) - (u_int32)(b_i) + 0x80000000 > 0x80000000) || \
 	  ((a_i) == (b_i) && (u_int32)(a_f) >= (u_int32)(b_f)))
 
 #define	M_ISEQU(a_i, a_f, b_i, b_f)	/* a == b unsigned */ \
@@ -226,6 +230,7 @@ typedef u_int32 u_fp;
 
 #define	L_ISNEG(v)	M_ISNEG((v)->l_ui, (v)->l_uf)
 #define L_ISZERO(v)	(((v)->l_ui | (v)->l_uf) == 0)
+#define	L_ISGTU(a, b)	M_ISGTU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
 #define	L_ISHIS(a, b)	M_ISHIS((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
 #define	L_ISGEQ(a, b)	M_ISGEQ((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
 #define	L_ISEQU(a, b)	M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
@@ -327,6 +332,7 @@ extern	char *	gmprettydate	(l_fp *);
 extern	char *	uglydate	(l_fp *);
 extern  void	mfp_mul		(int32 *, u_int32 *, int32, u_int32, int32, u_int32);
 
+extern	void	set_sys_fuzz	(double);
 extern	void	get_systime	(l_fp *);
 extern	int	step_systime	(double);
 extern	int	adj_systime	(double);

==== include/ntp_stdlib.h ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +2 -1
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.67/include/ntp_stdlib.h	2011-11-03 06:46:37 -04:00
+++ 1.68/include/ntp_stdlib.h	2011-12-16 21:30:40 -05:00
@@ -275,7 +275,8 @@ extern char *	ntp_strerror	(int e);
 #endif
 
 /* systime.c */
-extern double	sys_tick;		/* adjtime() resolution */
+extern double	sys_tick;		/* tick size or time to read */
+extern double	sys_fuzz;		/* min clock read latency */
 
 /* version.c */
 extern const char *Version;		/* version declaration */

==== libntp/systime.c ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +151 -74
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.58/libntp/systime.c	2011-10-20 22:07:24 -04:00
+++ 1.58.1.1/libntp/systime.c	2011-12-16 21:30:40 -05:00
@@ -27,21 +27,10 @@
 #endif /* HAVE_UTMPX_H */
 
 
-#define	FUZZ	500e-6		/* fuzz pivot */
-
 #ifndef USE_COMPILETIME_PIVOT
 # define USE_COMPILETIME_PIVOT 1
 #endif
 
-#if defined(HAVE_CLOCK_GETTIME)
-# define GET_SYSTIME_AS_TIMESPEC(tsp) clock_gettime(CLOCK_REALTIME, tsp)
-#elif defined(HAVE_GETCLOCK)
-# define GET_SYSTIME_AS_TIMESPEC(tsp) getclock(TIMEOFDAY, tsp)
-#elif !defined(GETTIMEOFDAY)
-# include "bletch: cannot get system time?"
-#endif
-
-
 /*
  * These routines (get_systime, step_systime, adj_systime) implement an
  * interface between the system independent NTP clock and the Unix
@@ -51,26 +40,82 @@
  * residues.
  *
  * In order to improve the apparent resolution, provide unbiased
- * rounding and insure that the readings cannot be predicted, the low-
- * order unused portion of the time below the resolution limit is filled
- * with an unbiased random fuzz.
+ * rounding and most importantly ensure that the readings cannot be
+ * predicted, the low-order unused portion of the time below the minimum
+ * time to read the clock is filled with an unbiased random fuzz.
+ *
+ * The sys_tick variable specifies the system clock tick interval in
+ * seconds, for stepping clocks, defined as those which return times
+ * less than MINSTEP greater than the previous reading. For systems that
+ * use a high-resolution counter such that each clock reading is always
+ * at least MINSTEP greater than the prior, sys_tick is the time to read
+ * the system clock.
+ *
+ * The sys_fuzz variable measures the minimum time to read the system
+ * clock, regardless of its precision.  When reading the system clock
+ * using get_systime() after sys_tick and sys_fuzz have been determined,
+ * ntpd ensures each unprocessed clock reading is no less than sys_fuzz
+ * later than the prior unprocessed reading, and then fuzzes the bits
+ * below sys_fuzz in the timestamp returned, ensuring each of its
+ * resulting readings is strictly later than the previous.
  *
- * The sys_tick variable secifies the system clock tick interval in
- * seconds. For systems that can interpolate between timer interrupts,
- * the resolution is presumed much less than the time to read the system
- * clock, which is the value of sys_tick after the precision has been
- * determined. For those systems that cannot interpolate between timer
- * interrupts, sys_tick will be much larger in the order of 10 ms, so the
- * fuzz should be that value. For Sunses the tick is not interpolated, but
- * the system clock is derived from a 2-MHz oscillator, so the resolution
- * is 500 ns and sys_tick is 500 ns.
+ * When slewing the system clock using adj_systime() (with the kernel
+ * loop discipline unavailable or disabled), adjtime() offsets are
+ * quantized to sys_tick, if sys_tick is greater than sys_fuzz, which
+ * is to say if the OS presents a stepping clock.  Otherwise, offsets
+ * are quantized to the microsecond resolution of adjtime()'s timeval
+ * input.  The remaining correction sys_residual is carried into the
+ * next adjtime() and meanwhile is also factored into get_systime()
+ * readings.
  */
-double	sys_tick = 0;		/* precision (time to read the clock) */
+double	sys_tick = 0;		/* tick size or time to read (s) */
+double	sys_fuzz = 0;		/* min. time to read the clock (s) */
+long	sys_fuzz_nsec = 0;	/* min. time to read the clock (ns) */
 double	sys_residual = 0;	/* adjustment residue (s) */
 time_stepped_callback	step_callback;
 
+static int lamport_violated;	/* clock was stepped back */
+
+void
+set_sys_fuzz(
+	double	fuzz_val
+	)
+{
+	sys_fuzz = fuzz_val;
+	INSIST(sys_fuzz >= 0);
+	INSIST(sys_fuzz <= 1.0);
+	sys_fuzz_nsec = (long)(sys_fuzz * 1e9 + 0.5);
+}
+
+
 #ifndef SIM	/* ntpsim.c has get_systime() and friends for sim */
 
+static inline void
+get_ostime(
+	struct timespec *	tsp
+	)
+{
+	int rc;
+
+#if defined(HAVE_CLOCK_GETTIME)
+	rc = clock_gettime(CLOCK_REALTIME, tsp);
+#elif defined(HAVE_GETCLOCK)
+	rc = getclock(TIMEOFDAY, tsp);
+#else
+	struct timeval		tv;
+
+	rc = GETTIMEOFDAY(&tv, NULL);
+	tsp->tv_sec = tv.tv_sec;
+	tsp->tv_nsec = tv_tv_usec * 1000;
+#endif
+	if (rc < 0) {
+		msyslog(LOG_ERR, "read system clock failed: %m (%d)",
+			errno);
+		exit(1);
+	}
+}
+
+
 /*
  * get_systime - return system time in NTP timestamp format.
  */
@@ -79,59 +124,91 @@ get_systime(
 	l_fp *now		/* system time */
 	)
 {
-	double	dtemp;
-
-#if defined(GET_SYSTIME_AS_TIMESPEC)
-
+	static struct timespec	ts_prev;	/* prior os time */
+	static l_fp		lfp_prev;	/* prior pre-residual result */
+	static l_fp		lfp_prev_w_resid;/* prior result including sys_residual */
 	struct timespec ts;	/* seconds and nanoseconds */
+	struct timespec ts_min;	/* earliest permissible */
+	struct timespec ts_lam;	/* lamport fictional increment */
+	struct timespec ts_prev_log;	/* for msyslog only */
+	double	dfuzz;
+	double	ddelta;
+	l_fp	result;
+	l_fp	lfpfuzz;
+	l_fp	lfpdelta;
+
+	get_ostime(&ts);
 
 	/*
-	 * Convert Unix timespec from seconds and nanoseconds to NTP
-	 * seconds and fraction.
+	 * After default_get_precision() has set a nonzero sys_fuzz,
+	 * ensure every reading of the OS clock advances by at least
+	 * sys_fuzz over the prior reading, thereby assuring each
+	 * fuzzed result is strictly later than the prior.  Limit the
+	 * necessary fiction to 1 second.
 	 */
-	GET_SYSTIME_AS_TIMESPEC(&ts);
-	now->l_i = (int32)ts.tv_sec + JAN_1970;
-	dtemp = 0;
-	if (sys_tick > FUZZ)
-		dtemp = ntp_random() * 2. / FRAC * sys_tick * 1e9;
-	else if (sys_tick > 0)
-		dtemp = ntp_random() * 2. / FRAC;
-	dtemp = (ts.tv_nsec + dtemp) * 1e-9 + sys_residual;
-	if (dtemp >= 1.) {
-		dtemp -= 1.;
-		now->l_i++;
-	} else if (dtemp < 0) {
-		dtemp += 1.;
-		now->l_i--;
+	if (sys_fuzz_nsec > 0 && !lamport_violated) {
+		timespec_addns(&ts_min, &ts_prev, sys_fuzz_nsec);
+		if (timespec_cmp_fast(&ts, &ts_min) < 0) {
+			timespec_sub(&ts_lam, &ts_min, &ts);
+			ts = ts_min;
+			if (ts_lam.tv_sec > 0) {
+				msyslog(LOG_ERR,
+					"get_systime Lamport advance exceeds one second (%.9f)",
+					ts_lam.tv_sec + 1e-9 * ts_lam.tv_nsec);
+				exit(1);
+			}
+		}
 	}
-	now->l_uf = (u_int32)(dtemp * FRAC);
+	ts_prev_log = ts_prev;
+	ts_prev = ts;
 
-#else /* have GETTIMEOFDAY */
+	/* convert from timespec to l_fp fixed-point */
+	timespec_abstolfp(&result, &ts);
 
-	struct timeval tv;	/* seconds and microseconds */
+	/*
+	 * Add in the fuzz.
+	 */
+	if (sys_fuzz > 0.) {
+		dfuzz = ntp_random() * 2. / FRAC * sys_fuzz;
+		DTOLFP(dfuzz, &lfpfuzz);
+		L_ADD(&result, &lfpfuzz);
+	} else {
+		dfuzz = 0;
+	}
 
 	/*
-	 * Convert Unix timeval from seconds and microseconds to NTP
-	 * seconds and fraction.
+	 * Ensure result is strictly greater than prior result (ignoring
+	 * sys_residual's effect for now) once sys_fuzz has been
+	 * determined.
 	 */
-	GETTIMEOFDAY(&tv, NULL);
-	now->l_i = tv.tv_sec + JAN_1970;
-	dtemp = 0;
-	if (sys_tick > FUZZ)
-		dtemp = ntp_random() * 2. / FRAC * sys_tick * 1e6;
-	else if (sys_tick > 0)
-		dtemp = ntp_random() * 2. / FRAC;
-	dtemp = (tv.tv_usec + dtemp) * 1e-6 + sys_residual;
-	if (dtemp >= 1.) {
-		dtemp -= 1.;
-		now->l_i++;
-	} else if (dtemp < 0) {
-		dtemp += 1.;
-		now->l_i--;
+	if (sys_fuzz > 0.) {
+		if (!L_ISZERO(&lfp_prev) && !lamport_violated) {
+			if (!L_ISGTU(&result, &lfp_prev)) {
+				msyslog(LOG_ERR,
+					"%sts_min %s ts_prev %s ts %s",
+					(lamport_violated)
+					    ? "LAMPORT "
+					    : "",
+					timespec_tostr(&ts_min),
+					timespec_tostr(&ts_prev_log),
+					timespec_tostr(&ts));
+				msyslog(LOG_ERR, "sys_fuzz %ld nsec, this fuzz %.9f",
+					sys_fuzz_nsec, dfuzz);
+				lfpdelta = lfp_prev;
+				L_SUB(&lfpdelta, &result);
+				LFPTOD(&lfpdelta, ddelta);
+				msyslog(LOG_ERR,
+					"get_systime prev result 0x%x.%08x is %.9f later than 0x%x.%08x",
+					lfp_prev.l_ui, lfp_prev.l_uf,
+					ddelta, result.l_ui, result.l_uf);
+			}
+		}
+		lfp_prev = result;
 	}
-	now->l_uf = (u_int32)(dtemp * FRAC);
+	if (lamport_violated) 
+		lamport_violated = FALSE;
 
-#endif /* have GETTIMEOFDAY */
+	*now = result;
 }
 
 
@@ -146,6 +223,7 @@ adj_systime(
 {
 	struct timeval adjtv;	/* new adjustment */
 	struct timeval oadjtv;	/* residual adjustment */
+	double	quant;		/* quantize to multiples of */
 	double	dtemp;
 	long	ticks;
 	int	isneg = 0;
@@ -175,8 +253,12 @@ adj_systime(
 	}
 	adjtv.tv_sec = (long)dtemp;
 	dtemp -= adjtv.tv_sec;
-	ticks = (long)(dtemp / sys_tick + .5);
-	adjtv.tv_usec = (long)(ticks * sys_tick * 1e6);
+	if (sys_tick > sys_fuzz)
+		quant = sys_tick;
+	else
+		quant = 1e-6;
+	ticks = (long)(dtemp / quant + .5);
+	adjtv.tv_usec = (long)(ticks * quant * 1e6);
 	dtemp -= adjtv.tv_usec / 1e6;
 	sys_residual = dtemp;
 
@@ -265,16 +347,10 @@ step_systime(
 	/* ---> time-critical path starts ---> */
 
 	/* get the current time as l_fp (without fuzz) and as struct timeval */
-#if defined(GET_SYSTIME_AS_TIMESPEC)
-	GET_SYSTIME_AS_TIMESPEC(&timets);
+	get_ostime(&timets);
 	timespec_abstolfp(&fp_sys, &timets);
 	tvlast.tv_sec = timets.tv_sec;
 	tvlast.tv_usec = (timets.tv_nsec + 500) / 1000;
-#else /* have GETTIMEOFDAY */
-	UNUSED_LOCAL(timets);
-	GETTIMEOFDAY(&tvlast, NULL);
-	timeval_abstolfp(&fp_sys, &tvlast);
-#endif
 
 	/* get the target time as l_fp */
 	L_ADD(&fp_sys, &fp_ofs);
@@ -291,6 +367,7 @@ step_systime(
 	/* <--- time-critical path ended with 'ntp_set_tod()' <--- */
 
 	sys_residual = 0;
+	lamport_violated = (step < 0);
 	if (step_callback)
 		(*step_callback)();
 

==== libntp/timespecops.c ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.7/libntp/timespecops.c	2011-08-12 13:17:51 -04:00
+++ 1.8/libntp/timespecops.c	2011-12-16 21:30:40 -05:00
@@ -277,7 +277,7 @@ timespec_test(
 }
 
 /* return LIB buffer ptr to string rep */
-const char*
+const char *
 timespec_tostr(
 	const struct timespec *x
 	)

==== ntpd/ntp_proto.c ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +57 -23
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.332/ntpd/ntp_proto.c	2011-11-29 23:00:30 -05:00
+++ 1.332.1.1/ntpd/ntp_proto.c	2011-12-16 21:30:40 -05:00
@@ -3807,9 +3807,10 @@ peer_unfit(
 /*
  * Find the precision of this particular machine
  */
-#define MINSTEP 100e-9		/* minimum clock increment (s) */
-#define MAXSTEP 20e-3		/* maximum clock increment (s) */
-#define MINLOOPS 5		/* minimum number of step samples */
+#define MINSTEP		100e-9	/* minimum clock increment (s) */
+#define MAXSTEP		1	/* maximum clock increment (s) */
+#define MINCHANGES	5	/* minimum number of step samples */
+#define MAXLOOPS	((int)(1. / MINSTEP))	/* avoid infinite loop */
 
 /*
  * This routine measures the system precision defined as the minimum of
@@ -3817,49 +3818,82 @@ peer_unfit(
  * clock. However, if a difference is less than MINSTEP, the clock has
  * been read more than once during a clock tick and the difference is
  * ignored. We set MINSTEP greater than zero in case something happens
- * like a cache miss.
+ * like a cache miss, and to tolerate underlying system clocks which
+ * ensure each reading is strictly greater than prior readings while
+ * using an underlying stepping (not interpolated) clock.
+ *
+ * sys_tick and sys_precision represent the time to read the clock for
+ * systems with high-precision clocks, and the tick interval or step
+ * size for lower-precision stepping clocks.
+ *
+ * This routine also measures the time to read the clock on stepping
+ * system clocks by counting the number of readings between changes of
+ * the underlying clock.  With either type of clock, the minimum time
+ * to read the clock is saved as sys_fuzz, and used to ensure the
+ * get_systime() readings always increase and are fuzzed below sys_fuzz.
  */
 int
 default_get_precision(void)
 {
 	l_fp	val;		/* current seconds fraction */
 	l_fp	last;		/* last seconds fraction */
-	l_fp	diff;		/* difference */
+	l_fp	ldiff;		/* difference */
 	double	tick;		/* computed tick value */
-	double	dtemp;		/* scratch */
+	double	diff;		/* scratch */
 	int	i;		/* log2 precision */
+	int	changes;
+	long	repeats;
+	long	max_repeats;
 
 	/*
-	 * Loop to find precision value in seconds.
+	 * Loop to find precision value in seconds.  With sys_fuzz set
+	 * to zero, get_systime() disables its fuzzing of low bits.
 	 */
 	tick = MAXSTEP;
-	i = 0;
+	set_sys_fuzz(0.);
 	get_systime(&last);
-	while (1) {
+	max_repeats = 0;
+	repeats = 0;
+	changes = 0;
+	for (i = 0; i < MAXLOOPS && changes < MINCHANGES; i++) {
 		get_systime(&val);
-		diff = val;
-		L_SUB(&diff, &last);
+		ldiff = val;
+		L_SUB(&ldiff, &last);
 		last = val;
-		LFPTOD(&diff, dtemp);
-		if (dtemp < MINSTEP)
-			continue;
-
-		if (dtemp < tick)
-			tick = dtemp;
-		if (++i >= MINLOOPS)
-			break;
+		LFPTOD(&ldiff, diff);
+		if (diff > MINSTEP) {
+			max_repeats = max(repeats, max_repeats);
+			repeats = 0;
+			changes++;
+			tick = min(diff, tick);
+		} else {
+			repeats++;
+		}
+	}
+	if (changes < MINCHANGES) {
+		msyslog(LOG_ERR, "Fatal error: precision could not be measured (MINSTEP too large?)");
+		exit(1);
 	}
 	sys_tick = tick;
+	if (0 == max_repeats) {
+		set_sys_fuzz(sys_tick);
+	} else {
+		set_sys_fuzz(sys_tick / max_repeats);
+		msyslog(LOG_NOTICE, "proto: fuzz beneath %.3f usec",
+			sys_fuzz * 1e6);
+	}
 
 	/*
 	 * Find the nearest power of two.
 	 */
-	msyslog(LOG_NOTICE, "proto: precision = %.3f usec", tick * 1e6);
-	for (i = 0; tick <= 1; i++)
+	for (i = 0; tick <= 1; i--)
 		tick *= 2;
 	if (tick - 1 > 1 - tick / 2)
-		i--;
-	return (-i);
+		i++;
+	msyslog(LOG_NOTICE, "proto: precision = %.3f usec (%d)",
+		sys_tick * 1e6, i);
+
+	return i;
 }
 
 

==== ntpd/refclock_arc.c ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +1 -1
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.26/ntpd/refclock_arc.c	2011-07-27 18:08:22 -04:00
+++ 1.27/ntpd/refclock_arc.c	2011-12-16 21:30:40 -05:00
@@ -402,7 +402,7 @@ Also note h<cr> command which starts a r
 				       (BITSPERCHAR * BITTIME) ) )
 
      /* Allow for UART to accept char half-way through final stop bit. */
-#define INITIALOFFSET (u_int32)(-BITTIME/2)
+#define INITIALOFFSET ((u_int32)(-BITTIME/2))
 
      /*
     charoffsets[x] is the time after the start of the second that byte

==== ports/winnt/ntpd/nt_clockstuff.c ====
2011-12-17 02:30:40+00:00, davehart at shiny.ad.hartbrothers.com +11 -2
  [Bug 2037] Fuzzed non-interpolated clock may decrease.

--- 1.53/ports/winnt/ntpd/nt_clockstuff.c	2011-09-19 21:32:34 -04:00
+++ 1.54/ports/winnt/ntpd/nt_clockstuff.c	2011-12-16 21:30:40 -05:00
@@ -559,9 +559,18 @@ adj_systime(
 
 
 	sys_residual = dtemp / 1e6;
-	DPRINTF(3, ("adj_systime: %.9f -> %.9f residual %.9f adjtime %.9f\n", 
+#if 0
+	msyslog(LOG_NOTICE, "adj_systime: %.9f -> %.9f residual %.9f", 
 		    now, 1e-6 * (TimeAdjustment * ppm_per_adjust_unit),
-		    sys_residual, adjtime_carry));
+		    sys_residual);
+#endif
+	DPRINTF(3, ("adj_systime: %.9f -> %.9f residual %.9f", 
+		    now, 1e-6 * (TimeAdjustment * ppm_per_adjust_unit),
+		    sys_residual));
+	if (0 == adjtime_carry)
+		DPRINTF(3, ("\n"));
+	else
+		DPRINTF(3, (" adjtime %.9f\n", adjtime_carry));
 
 	/* only adjust the clock if adjustment changes */
 	TimeAdjustment += wintickadj;


More information about the bk-ntp-dev-send mailing list