[Git][NTPsec/ntpsec][deglobal] De-globalled system variables.

Ian Bruene gitlab at mg.gitlab.com
Sun May 20 19:46:24 UTC 2018


Ian Bruene pushed to branch deglobal at NTPsec / ntpsec


Commits:
6a50a53f by Ian Bruene at 2018-05-20T19:44:21Z
De-globalled system variables.

- - - - -


12 changed files:

- include/ntpd.h
- ntpd/ntp_control.c
- ntpd/ntp_loopfilter.c
- ntpd/ntp_peer.c
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/ntp_timer.c
- ntpd/refclock_generic.c
- ntpd/refclock_local.c
- ntpd/refclock_modem.c
- ntpd/refclock_nmea.c
- ntpd/refclock_pps.c


Changes:

=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -317,16 +317,19 @@ extern int	peer_associations;	/* mobilized associations */
  * System variables are declared here.	See Section 3.2 of the
  * specification.
  */
-extern uint8_t	sys_leap;		/* system leap indicator */
-extern uint8_t	sys_stratum;		/* system stratum */
-extern int8_t	sys_precision;		/* local clock precision */
-extern double	sys_rootdelay;		/* roundtrip delay to primary source */
-extern double	sys_rootdisp;		/* dispersion to primary source */
-extern double	sys_rootdist;		/* distance to primary source */
-extern uint32_t	sys_refid;		/* reference id */
-extern l_fp	sys_reftime;		/* last update time */
-extern struct peer *sys_peer;		/* current peer */
-extern int	sys_maxclock;		/* maximum candidates */
+int	sys_maxclock;		/* maximum candidates */
+struct system_variables {
+    uint8_t	sys_leap;		/* system leap indicator */
+    uint8_t	sys_stratum;		/* system stratum */
+    int8_t	sys_precision;		/* local clock precision */
+    double	sys_rootdelay;		/* roundtrip delay to primary source */
+    double	sys_rootdisp;		/* dispersion to primary source */
+    double	sys_rootdist;		/* distance to primary source */
+    uint32_t	sys_refid;		/* reference id */
+    l_fp	sys_reftime;		/* last update time */
+    struct peer *sys_peer;		/* current peer */
+};
+extern struct system_variables sys_vars;
 
 /*
  * Nonspecified system state variables.


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -820,7 +820,7 @@ process_control(
 	 * Pull enough data from the packet to make intelligent
 	 * responses
 	 */
-	rpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, res_version,
+	rpkt.li_vn_mode = PKT_LI_VN_MODE(sys_vars.sys_leap, res_version,
 					 MODE_CONTROL);
 	res_opcode = pkt->r_m_e_op;
 	rpkt.sequence = pkt->sequence;
@@ -963,15 +963,15 @@ ctlsysstatus(void)
 
 	this_clock = CTL_SST_TS_UNSPEC;
 #ifdef REFCLOCK
-	if (sys_peer != NULL) {
-		if (CTL_SST_TS_UNSPEC != sys_peer->sstclktype)
-			this_clock = sys_peer->sstclktype;
+	if (sys_vars.sys_peer != NULL) {
+		if (CTL_SST_TS_UNSPEC != sys_vars.sys_peer->sstclktype)
+			this_clock = sys_vars.sys_peer->sstclktype;
 	}
 #else /* REFCLOCK */
-	if (sys_peer != 0)
+	if (sys_vars.sys_peer != 0)
 		this_clock = CTL_SST_TS_NTP;
 #endif /* REFCLOCK */
-	return CTL_SYS_STATUS(sys_leap, this_clock, ctl_sys_num_events,
+	return CTL_SYS_STATUS(sys_vars.sys_leap, this_clock, ctl_sys_num_events,
 			      ctl_sys_last_event);
 }
 
@@ -1483,35 +1483,35 @@ ctl_putsys(
 	switch (varid) {
 
 	case CS_LEAP:
-		ctl_putuint(sys_var[CS_LEAP].text, sys_leap);
+		ctl_putuint(sys_var[CS_LEAP].text, sys_vars.sys_leap);
 		break;
 
 	case CS_STRATUM:
-		ctl_putuint(sys_var[CS_STRATUM].text, sys_stratum);
+		ctl_putuint(sys_var[CS_STRATUM].text, sys_vars.sys_stratum);
 		break;
 
 	case CS_PRECISION:
-		ctl_putint(sys_var[CS_PRECISION].text, sys_precision);
+		ctl_putint(sys_var[CS_PRECISION].text, sys_vars.sys_precision);
 		break;
 
 	case CS_ROOTDELAY:
-		ctl_putdbl(sys_var[CS_ROOTDELAY].text, sys_rootdelay * MS_PER_S);
+		ctl_putdbl(sys_var[CS_ROOTDELAY].text, sys_vars.sys_rootdelay * MS_PER_S);
 		break;
 
 	case CS_ROOTDISPERSION:
 		ctl_putdbl(sys_var[CS_ROOTDISPERSION].text,
-			   sys_rootdisp * MS_PER_S);
+			   sys_vars.sys_rootdisp * MS_PER_S);
 		break;
 
 	case CS_REFID:
-		if (sys_stratum > 1 && sys_stratum < STRATUM_UNSPEC)
-			ctl_putadr(sys_var[varid].text, sys_refid, NULL);
+		if (sys_vars.sys_stratum > 1 && sys_vars.sys_stratum < STRATUM_UNSPEC)
+			ctl_putadr(sys_var[varid].text, sys_vars.sys_refid, NULL);
 		else
-			ctl_putrefid(sys_var[varid].text, sys_refid);
+			ctl_putrefid(sys_var[varid].text, sys_vars.sys_refid);
 		break;
 
 	case CS_REFTIME:
-		ctl_putts(sys_var[CS_REFTIME].text, &sys_reftime);
+		ctl_putts(sys_var[CS_REFTIME].text, &sys_vars.sys_reftime);
 		break;
 
 	case CS_POLL:
@@ -1519,16 +1519,16 @@ ctl_putsys(
 		break;
 
 	case CS_PEERID:
-		if (sys_peer == NULL)
+		if (sys_vars.sys_peer == NULL)
 			ctl_putuint(sys_var[CS_PEERID].text, 0);
 		else
 			ctl_putuint(sys_var[CS_PEERID].text,
-				    sys_peer->associd);
+				    sys_vars.sys_peer->associd);
 		break;
 
 	case CS_PEERADR:
-		if (sys_peer != NULL && sys_peer->dstadr != NULL)
-			ss = sockporttoa(&sys_peer->srcadr);
+		if (sys_vars.sys_peer != NULL && sys_vars.sys_peer->dstadr != NULL)
+			ss = sockporttoa(&sys_vars.sys_peer->srcadr);
 		else
 			ss = "0.0.0.0:0";
 		ctl_putunqstr(sys_var[CS_PEERADR].text, ss, strlen(ss));
@@ -1536,8 +1536,8 @@ ctl_putsys(
 
 	case CS_PEERMODE: {
 		uint64_t u;
-		u = (sys_peer != NULL)
-			? sys_peer->hmode
+		u = (sys_vars.sys_peer != NULL)
+			? sys_vars.sys_peer->hmode
 			: MODE_UNSPEC;
 		ctl_putuint(sys_var[CS_PEERMODE].text, u);
 		break;
@@ -2037,7 +2037,7 @@ ctl_putsys(
 
 	case CS_ROOTDISTANCE:
 		ctl_putdbl(sys_var[CS_ROOTDISTANCE].text,
-			   sys_rootdist * MS_PER_S);
+			   sys_vars.sys_rootdist * MS_PER_S);
 		break;
 
         default:
@@ -4083,9 +4083,9 @@ read_clockstatus(
 		 * Find a clock for this jerk.	If the system peer
 		 * is a clock use it, else search peer_list for one.
 		 */
-		if (sys_peer != NULL && (FLAG_REFCLOCK &
-		    sys_peer->cfg.flags))
-			peer = sys_peer;
+		if (sys_vars.sys_peer != NULL && (FLAG_REFCLOCK &
+		    sys_vars.sys_peer->cfg.flags))
+			peer = sys_vars.sys_peer;
 		else
 			for (peer = peer_list;
 			     peer != NULL;


=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -224,7 +224,7 @@ init_loopfilter(void)
 	 * Initialize state variables.
 	 */
 	sys_poll = ntp_minpoll;
-	clock_jitter = LOGTOD(sys_precision);
+	clock_jitter = LOGTOD(sys_vars.sys_precision);
 	freq_cnt = (int)clock_minstep;
 }
 
@@ -636,7 +636,7 @@ local_clock(
 			step_systime(fp_offset, ntp_set_tod);
 			reinit_timer();
 			tc_counter = 0;
-			clock_jitter = LOGTOD(sys_precision);
+			clock_jitter = LOGTOD(sys_vars.sys_precision);
 			rval = 2;
 			if (state == EVNT_NSET) {
 				rstclock(EVNT_FREQ, 0);
@@ -772,8 +772,8 @@ local_clock(
 				ntv.constant = 0;
 
 			ntv.esterror = (long)(clock_jitter * US_PER_S);
-			ntv.maxerror = (long)((sys_rootdelay / 2 +
-			    sys_rootdisp) * US_PER_S);
+			ntv.maxerror = (long)((sys_vars.sys_rootdelay / 2 +
+			    sys_vars.sys_rootdisp) * US_PER_S);
 			ntv.status = STA_PLL;
 
 			/*
@@ -792,9 +792,9 @@ local_clock(
 						pll_status,
 						ntv.status);
 			}
-			if (sys_leap == LEAP_ADDSECOND)
+			if (sys_vars.sys_leap == LEAP_ADDSECOND)
 				ntv.status |= STA_INS;
-			else if (sys_leap == LEAP_DELSECOND) ntv.status |= STA_DEL;
+			else if (sys_vars.sys_leap == LEAP_DELSECOND) ntv.status |= STA_DEL;
 		}
 
 		/*
@@ -933,7 +933,7 @@ adj_host_clock(
 	 * would be counterproductive. During the startup clamp period, the
 	 * time constant is clamped at 2.
 	 */
-	sys_rootdisp += clock_phi;
+	sys_vars.sys_rootdisp += clock_phi;
 #ifndef ENABLE_LOCKCLOCK
 	if (!ntp_enable || mode_ntpdate)
 		return;


=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -656,7 +656,7 @@ newpeer(
 	if ((MDF_BCAST & cast_flags) && peer->dstadr != NULL)
 		enable_broadcast(peer->dstadr, srcadr);
 
-	peer->precision = sys_precision;
+	peer->precision = sys_vars.sys_precision;
 	peer->hpoll = peer->cfg.minpoll;
 	if (cast_flags & MDF_POOL)
 		peer_clear(peer, "POOL", initializing1);


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -97,16 +97,8 @@ typedef struct peer_select_tag {
  * System variables are declared here. Unless specified otherwise, all
  * times are in seconds.
  */
-uint8_t	sys_leap;		/* system leap indicator */
+struct system_variables sys_vars;
 static uint8_t	xmt_leap;		/* leap indicator sent in client requests */
-uint8_t	sys_stratum;		/* system stratum */
-int8_t	sys_precision;		/* local clock precision (log2 s) */
-double	sys_rootdelay;		/* roundtrip delay to primary source */
-double	sys_rootdisp;		/* dispersion to primary source */
-double	sys_rootdist;		/* only used fror Mode 6 export */
-uint32_t sys_refid;		/* reference id (network byte order) */
-l_fp	sys_reftime;		/* last update time */
-struct	peer *sys_peer;		/* current peer */
 
 #ifdef ENABLE_LEAP_SMEAR
 struct leap_smear_info leap_smear;
@@ -173,8 +165,8 @@ static	double	root_distance	(struct peer *);
 
 void
 set_sys_leap(unsigned char new_sys_leap) {
-	sys_leap = new_sys_leap;
-	xmt_leap = sys_leap;
+	sys_vars.sys_leap = new_sys_leap;
+	xmt_leap = sys_vars.sys_leap;
 
 	/*
 	 * Under certain conditions we send faked leap bits to clients, so
@@ -589,7 +581,7 @@ handle_procpkt(
 	    -scalbn((double)(peer->org - rbufp->pkt.rec), -32);
 	const double theta = (t21 + t34) / 2.;
 	const double delta = fabs(t21 - t34);
-	const double epsilon = LOGTOD(sys_precision) +
+	const double epsilon = LOGTOD(sys_vars.sys_precision) +
 	    LOGTOD(peer->precision) +
 	    clock_phi * delta;
 
@@ -828,7 +820,7 @@ transmit(
 	 */
 	if (peer->cast_flags & MDF_BCAST) {
 		peer->outdate = current_time;
-		if (sys_leap != LEAP_NOTINSYNC)
+		if (sys_vars.sys_leap != LEAP_NOTINSYNC)
 			peer_xmit(peer);
 		poll_update(peer, hpoll);
 		return;
@@ -986,19 +978,19 @@ clock_update(
 	 * Update the system state variables. We do this very carefully,
 	 * as the poll interval might need to be clamped differently.
 	 */
-	sys_peer = peer;
+	sys_vars.sys_peer = peer;
 	sys_epoch = peer->epoch;
 	if (sys_poll < peer->cfg.minpoll)
 		sys_poll = peer->cfg.minpoll;
 	if (sys_poll > peer->cfg.maxpoll)
 		sys_poll = peer->cfg.maxpoll;
 	poll_update(peer, sys_poll);
-	sys_stratum = min(peer->stratum + 1, STRATUM_UNSPEC);
+	sys_vars.sys_stratum = min(peer->stratum + 1, STRATUM_UNSPEC);
 	if (peer->stratum == STRATUM_REFCLOCK ||
 	    peer->stratum == STRATUM_UNSPEC)
-		sys_refid = peer->refid;
+		sys_vars.sys_refid = peer->refid;
 	else
-		sys_refid = addr2refid(&peer->srcadr);
+		sys_vars.sys_refid = addr2refid(&peer->srcadr);
 	/*
 	 * Root Dispersion (E) is defined (in RFC 5905) as:
 	 *
@@ -1024,11 +1016,11 @@ clock_update(
 		+ fabs(sys_offset);
 
 	if (dtemp > sys_mindisp)
-		sys_rootdisp = dtemp;
+		sys_vars.sys_rootdisp = dtemp;
 	else
-		sys_rootdisp = sys_mindisp;
-	sys_rootdelay = peer->delay + peer->rootdelay;
-	sys_reftime = peer->dst;
+		sys_vars.sys_rootdisp = sys_mindisp;
+	sys_vars.sys_rootdelay = peer->delay + peer->rootdelay;
+	sys_vars.sys_reftime = peer->dst;
 
 	DPRINT(1, ("clock_update: at %u sample %u associd %d\n",
 		   current_time, peer->epoch, peer->associd));
@@ -1070,12 +1062,12 @@ clock_update(
 	case 2:
 		clear_all();
 		set_sys_leap(LEAP_NOTINSYNC);
-		sys_stratum = STRATUM_UNSPEC;
-		memcpy(&sys_refid, "STEP", REFIDLEN);
-		sys_rootdelay = 0;
-		sys_rootdisp = 0;
-		sys_reftime = 0;
-		sys_jitter = LOGTOD(sys_precision);
+		sys_vars.sys_stratum = STRATUM_UNSPEC;
+		memcpy(&sys_vars.sys_refid, "STEP", REFIDLEN);
+		sys_vars.sys_rootdelay = 0;
+		sys_vars.sys_rootdisp = 0;
+		sys_vars.sys_reftime = 0;
+		sys_jitter = LOGTOD(sys_vars.sys_precision);
 		leapsec_reset_frame();
 		break;
 
@@ -1089,7 +1081,7 @@ clock_update(
 		 * leap bits. If crypto, the timer will goose the setup
 		 * process.
 		 */
-		if (sys_leap == LEAP_NOTINSYNC) {
+		if (sys_vars.sys_leap == LEAP_NOTINSYNC) {
 			set_sys_leap(LEAP_NOWARNING);
 			/*
 			 * If our parent process is waiting for the
@@ -1250,7 +1242,7 @@ peer_clear(
 	peer->hpoll = peer->cfg.minpoll;
 	peer->disp = sys_maxdisp;
 	peer->flash = peer_unfit(peer);
-	peer->jitter = LOGTOD(sys_precision);
+	peer->jitter = LOGTOD(sys_vars.sys_precision);
 
 	for (u = 0; u < NTP_SHIFT; u++) {
 		peer->filter_order[u] = u;
@@ -1474,7 +1466,7 @@ clock_filter(
 	DPRINT(1, ("clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f\n",
 		   m, peer->offset, peer->delay, peer->disp,
 		   peer->jitter));
-	if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC)
+	if (peer->burst == 0 || sys_vars.sys_leap == LEAP_NOTINSYNC)
 		clock_select();
 }
 
@@ -1522,12 +1514,12 @@ clock_select(void)
 	 * Initialize and create endpoint, index and peer lists big
 	 * enough to handle all associations.
 	 */
-	osys_peer = sys_peer;
+	osys_peer = sys_vars.sys_peer;
 	sys_survivors = 0;
 #ifdef ENABLE_LOCKCLOCK
 	set_sys_leap(LEAP_NOTINSYNC);
-	sys_stratum = STRATUM_UNSPEC;
-	memcpy(&sys_refid, "DOWN", REFIDLEN);
+	sys_vars.sys_stratum = STRATUM_UNSPEC;
+	memcpy(&sys_vars.sys_refid, "DOWN", REFIDLEN);
 #endif /* ENABLE_LOCKCLOCK */
 
 	/*
@@ -1948,7 +1940,7 @@ clock_select(void)
 			typesystem->new_status = CTL_PST_SEL_SYSPEER;
 			sys_offset = typesystem->offset;
 			sys_jitter = typesystem->jitter;
-			sys_rootdist = root_distance(typesystem);
+			sys_vars.sys_rootdist = root_distance(typesystem);
 		}
 		DPRINT(1, ("select: combine offset %.9f jitter %.9f\n",
 			   sys_offset, sys_jitter));
@@ -1970,7 +1962,7 @@ clock_select(void)
 		typesystem->new_status = CTL_PST_SEL_PPS;
 		sys_offset = typesystem->offset;
 		sys_jitter = typesystem->jitter;
-		sys_rootdist = root_distance(typesystem);
+		sys_vars.sys_rootdist = root_distance(typesystem);
 		DPRINT(1, ("select: pps offset %.9f jitter %.9f\n",
 			   sys_offset, sys_jitter));
 	} else if ( typepps &&
@@ -1991,7 +1983,7 @@ clock_select(void)
 			    orphwait = current_time + (unsigned long)sys_orphwait;
 			report_event(EVNT_NOPEER, NULL, NULL);
 		}
-		sys_peer = NULL;
+		sys_vars.sys_peer = NULL;
 		for (peer = peer_list; peer != NULL; peer = peer->p_link)
 			peer->status = peer->new_status;
 		return;
@@ -2035,7 +2027,7 @@ clock_combine(
 	}
 	sys_offset = z / y;
 	sys_jitter = SQRT(w / y + SQUARE(peers[syspeer].seljit));
-	sys_rootdist = peers[syspeer].synch;
+	sys_vars.sys_rootdist = peers[syspeer].synch;
 }
 
 
@@ -2069,7 +2061,7 @@ root_distance(
 	 */
 	dtemp = (peer->delay + peer->rootdelay) / 2
 		+ LOGTOD(peer->precision)
-		  + LOGTOD(sys_precision)
+		  + LOGTOD(sys_vars.sys_precision)
 		  + clock_phi * (current_time - peer->update)
 		+ peer->rootdisp
 		+ peer->jitter;
@@ -2102,15 +2094,15 @@ peer_xmit(
 	if (!peer->dstadr)	/* drop peers without interface */
 		return;
 
-	xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, peer->cfg.version,
+	xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_vars.sys_leap, peer->cfg.version,
 	    peer->hmode);
-	xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
+	xpkt.stratum = STRATUM_TO_PKT(sys_vars.sys_stratum);
 	xpkt.ppoll = peer->hpoll;
-	xpkt.precision = sys_precision;
-	xpkt.refid = sys_refid;
-	xpkt.rootdelay = HTONS_FP(DTOUFP(sys_rootdelay));
-	xpkt.rootdisp =	 HTONS_FP(DTOUFP(sys_rootdisp));
-	xpkt.reftime = htonl_fp(sys_reftime);
+	xpkt.precision = sys_vars.sys_precision;
+	xpkt.refid = sys_vars.sys_refid;
+	xpkt.rootdelay = HTONS_FP(DTOUFP(sys_vars.sys_rootdelay));
+	xpkt.rootdisp =	 HTONS_FP(DTOUFP(sys_vars.sys_rootdisp));
+	xpkt.reftime = htonl_fp(sys_vars.sys_reftime);
 	xpkt.org = htonl_fp(peer->xmt);
 	xpkt.rec = htonl_fp(peer->dst);
 
@@ -2257,17 +2249,17 @@ fast_xmit(
 		 * reftime to make sure the reftime isn't later than
 		 * the transmit/receive times.
 		 */
-		xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap,
+		xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_vars.sys_leap,
 		    PKT_VERSION(rbufp->pkt.li_vn_mode), xmode);
-		xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
+		xpkt.stratum = STRATUM_TO_PKT(sys_vars.sys_stratum);
 		xpkt.ppoll = max(rbufp->pkt.ppoll, ntp_minpoll);
-		xpkt.precision = sys_precision;
-		xpkt.refid = sys_refid;
-		xpkt.rootdelay = HTONS_FP(DTOUFP(sys_rootdelay));
-		xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
+		xpkt.precision = sys_vars.sys_precision;
+		xpkt.refid = sys_vars.sys_refid;
+		xpkt.rootdelay = HTONS_FP(DTOUFP(sys_vars.sys_rootdelay));
+		xpkt.rootdisp = HTONS_FP(DTOUFP(sys_vars.sys_rootdisp));
 
 #ifdef ENABLE_LEAP_SMEAR
-		this_ref_time = sys_reftime;
+		this_ref_time = sys_vars.sys_reftime;
 		if (leap_smear.in_progress) {
 			leap_smear_add_offs(&this_ref_time, NULL);
 			xpkt.refid = convertLFPToRefID(leap_smear.offset);
@@ -2278,7 +2270,7 @@ fast_xmit(
 		}
 		xpkt.reftime = htonl_fp(this_ref_time);
 #else
-		xpkt.reftime = htonl_fp(sys_reftime);
+		xpkt.reftime = htonl_fp(sys_vars.sys_reftime);
 #endif
 
 		xpkt.org.l_ui = htonl(rbufp->pkt.xmt >> 32);
@@ -2633,7 +2625,7 @@ measure_precision(const bool verbose)
 	set_sys_tick_precision(measured_tick);
 	if (verbose) {
 		msyslog(LOG_INFO, "INIT: precision = %.3f usec (%d)",
-			sys_tick * US_PER_S, sys_precision);
+			sys_tick * US_PER_S, sys_vars.sys_precision);
 		if (sys_fuzz < sys_tick) {
 			msyslog(LOG_NOTICE, "INIT: fuzz beneath %.3f usec",
 				sys_fuzz * US_PER_S);
@@ -2732,7 +2724,7 @@ set_sys_tick_precision(
 	if (tick - 1 > 1 - tick / 2)
 		i++;
 
-	sys_precision = (int8_t)i;
+	sys_vars.sys_precision = (int8_t)i;
 }
 
 
@@ -2748,13 +2740,13 @@ init_proto(const bool verbose)
 	 * Fill in the sys_* stuff.  Default is don't listen to
 	 * broadcasting, require authentication.
 	 */
-	sys_leap = LEAP_NOTINSYNC;
-	sys_stratum = STRATUM_UNSPEC;
-	memcpy(&sys_refid, "INIT", REFIDLEN);
-	sys_peer = NULL;
-	sys_rootdelay = 0;
-	sys_rootdisp = 0;
-	sys_reftime = 0;
+	sys_vars.sys_leap = LEAP_NOTINSYNC;
+	sys_vars.sys_stratum = STRATUM_UNSPEC;
+	memcpy(&sys_vars.sys_refid, "INIT", REFIDLEN);
+	sys_vars.sys_peer = NULL;
+	sys_vars.sys_rootdelay = 0;
+	sys_vars.sys_rootdisp = 0;
+	sys_vars.sys_reftime = 0;
 	sys_jitter = 0;
 	measure_precision(verbose);
 	get_systime(&dummy);


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -539,9 +539,9 @@ refclock_receive(
 		return;
 
 	clock_filter(peer, pp->offset, 0., pp->jitter);
-	if (cal_enable && fabs(last_offset) < sys_mindisp && sys_peer !=
+	if (cal_enable && fabs(last_offset) < sys_mindisp && sys_vars.sys_peer !=
 	    NULL) {
-		if (sys_peer->is_pps_driver &&
+		if (sys_vars.sys_peer->is_pps_driver &&
 		    !peer->is_pps_driver)
 			pp->fudgetime1 -= pp->offset * FUDGEFAC;
 	}
@@ -1027,7 +1027,7 @@ refclock_catcher(
 	if (ap->handle == 0)
 		return PPS_SETUP;
 
-	if (ap->pps_params.mode == 0 && sys_leap != LEAP_NOTINSYNC) {
+	if (ap->pps_params.mode == 0 && sys_vars.sys_leap != LEAP_NOTINSYNC) {
 		if (refclock_params(pp->sloppyclockflag, ap) < 1)
 			return PPS_SETUP;
 	}


=====================================
ntpd/ntp_timer.c
=====================================
--- a/ntpd/ntp_timer.c
+++ b/ntpd/ntp_timer.c
@@ -228,19 +228,19 @@ timer(void)
 	 * synchronization source is an orphan. It shows offset zero and
 	 * reference ID the loopback address.
 	 */
-	if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL &&
+	if (sys_orphan < STRATUM_UNSPEC && sys_vars.sys_peer == NULL &&
 	    current_time > orphwait) {
-		if (sys_leap == LEAP_NOTINSYNC) {
-			sys_leap = LEAP_NOWARNING;
+		if (sys_vars.sys_leap == LEAP_NOTINSYNC) {
+			sys_vars.sys_leap = LEAP_NOWARNING;
 		}
-		sys_stratum = (uint8_t)sys_orphan;
-		if (sys_stratum > 1)
-			sys_refid = htonl(LOOPBACKADR);
+		sys_vars.sys_stratum = (uint8_t)sys_orphan;
+		if (sys_vars.sys_stratum > 1)
+			sys_vars.sys_refid = htonl(LOOPBACKADR);
 		else
-			memcpy(&sys_refid, "LOOP", REFIDLEN);
+			memcpy(&sys_vars.sys_refid, "LOOP", REFIDLEN);
 		sys_offset = 0;
-		sys_rootdelay = 0;
-		sys_rootdisp = 0;
+		sys_vars.sys_rootdelay = 0;
+		sys_vars.sys_rootdisp = 0;
 	}
 
 	time(&now);
@@ -250,15 +250,15 @@ timer(void)
 	 * is imminent or every 8th second.
 	 */
 	if (leapsec > LSPROX_NOWARN || 0 == (current_time & 7))
-		check_leapsec(now, (sys_leap == LEAP_NOTINSYNC));
-	if (sys_leap != LEAP_NOTINSYNC) {
+		check_leapsec(now, (sys_vars.sys_leap == LEAP_NOTINSYNC));
+	if (sys_vars.sys_leap != LEAP_NOTINSYNC) {
 		if (leapsec >= LSPROX_ANNOUNCE && leapdif) {
 			if (leapdif > 0)
-				sys_leap = LEAP_ADDSECOND;
+				sys_vars.sys_leap = LEAP_ADDSECOND;
 			else
-				sys_leap = LEAP_DELSECOND;
+				sys_vars.sys_leap = LEAP_DELSECOND;
 		} else {
-			sys_leap = LEAP_NOWARNING;
+			sys_vars.sys_leap = LEAP_NOWARNING;
 		}
 	}
 
@@ -351,7 +351,7 @@ check_leap_sec_in_progress( const leap_result_t *lsdata ) {
 
 	/* if changed we may have to update the leap status sent to clients */
 	if (leap_sec_in_progress != prv_leap_sec_in_progress)
-		set_sys_leap(sys_leap);
+		set_sys_leap(sys_vars.sys_leap);
 }
 
 static void
@@ -492,7 +492,7 @@ check_leapsec(
 		if (  leapsec < LSPROX_SCHEDULE
 		   && lsprox >= LSPROX_SCHEDULE) {
 			if (lsdata.dynamic)
-				report_event(PEVNT_ARMED, sys_peer, NULL);
+				report_event(PEVNT_ARMED, sys_vars.sys_peer, NULL);
 			else
 				report_event(EVNT_ARMED, NULL, NULL);
 		}


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -2604,7 +2604,7 @@ parse_start(
 
 	peer->rootdelay       = parse->parse_type->cl_rootdelay;
 	peer->sstclktype      = parse->parse_type->cl_type;
-	peer->precision       = sys_precision;
+	peer->precision       = sys_vars.sys_precision;
 
 	peer->stratum         = STRATUM_REFCLOCK;
 


=====================================
ntpd/refclock_local.c
=====================================
--- a/ntpd/refclock_local.c
+++ b/ntpd/refclock_local.c
@@ -100,7 +100,7 @@ local_start(
 	/*
 	 * Initialize miscellaneous variables
 	 */
-	peer->precision = sys_precision;
+	peer->precision = sys_vars.sys_precision;
 	pp->leap = LEAP_NOTINSYNC;
 	peer->stratum = STRATUM;
 	pp->stratum = STRATUM;
@@ -138,7 +138,7 @@ local_poll(
 	/*
 	 * Do no evil unless the house is dark or lit with our own lamp.
 	 */
-	if (!(sys_peer == NULL || sys_peer == peer))
+	if (!(sys_vars.sys_peer == NULL || sys_vars.sys_peer == peer))
 		return;
 
 	pp = peer->procptr;


=====================================
ntpd/refclock_modem.c
=====================================
--- a/ntpd/refclock_modem.c
+++ b/ntpd/refclock_modem.c
@@ -678,7 +678,7 @@ modem_poll(
 	 * as either no peers are available or this peer is selected.
 	 */
 	case MODE_BACKUP:
-		if (!(sys_peer == NULL || sys_peer == peer))
+		if (!(sys_vars.sys_peer == NULL || sys_vars.sys_peer == peer))
 			return;
 
 		break;


=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -761,7 +761,7 @@ refclock_ppsrelate(
 	*rd_fudge = pp_fudge;
 
 	/* if whole system out-of-sync, do not try to PLL */
-	if (sys_leap == LEAP_NOTINSYNC)
+	if (sys_vars.sys_leap == LEAP_NOTINSYNC)
 		return PPS_RELATE_EDGE; /* cannot PLL with pps code */
 
 	/* check against reftime if PPS PLL can be used */


=====================================
ntpd/refclock_pps.c
=====================================
--- a/ntpd/refclock_pps.c
+++ b/ntpd/refclock_pps.c
@@ -240,7 +240,7 @@ pps_poll(
 	 * Don't wiggle the clock until some other driver has numbered
 	 * the seconds.
 	 */
-	if (sys_leap == LEAP_NOTINSYNC) {
+	if (sys_vars.sys_leap == LEAP_NOTINSYNC) {
 		pp->codeproc = pp->coderecv;  // xxx ??
 		up->pcount = up->scount = up->kcount = up->rcount = 0;
 		return;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6a50a53fb6dd1a87e3d0bd3769f9d15abc0535b3

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6a50a53fb6dd1a87e3d0bd3769f9d15abc0535b3
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180520/8eaa4c6c/attachment.html>


More information about the vc mailing list