[Git][NTPsec/ntpsec][master] 2 commits: Eliminate last use of refclktype.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Jun 28 22:23:21 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
3221d205 by Eric S. Raymond at 2016-06-28T13:01:31-04:00
Eliminate last use of refclktype.

- - - - -
a24d9930 by Eric S. Raymond at 2016-06-28T18:18:08-04:00
Fix refclock table formatting.

- - - - -


6 changed files:

- docs/refclock.txt
- include/ntp.h
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/refclock_conf.c
- ntpd/refclock_pps.c


Changes:

=====================================
docs/refclock.txt
=====================================
--- a/docs/refclock.txt
+++ b/docs/refclock.txt
@@ -170,7 +170,7 @@ removed because it duplicates support for the 6021 in the generic
 parse driver.
 
 [options="header"]
-[cols="10%,5%,5%,80%",options="header"]
+[cols="16%,5%,80%",options="header"]
 |====================================================================
 | Name                                  | Flags | Driver
 |link:driver_local.html[local]          | D | Undisciplined Local Clock


=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -272,7 +272,7 @@ struct peer {
 	 */
 #ifdef REFCLOCK
 	struct refclockproc *procptr; /* refclock structure pointer */
-	uint8_t	refclktype;	/* reference clock type */
+	bool	is_pps_driver;	/* is this the PPS driver? */
 	uint8_t	refclkunit;	/* reference clock unit number */
 	uint8_t	sstclktype;	/* clock type for system status word */
 #endif /* REFCLOCK */
@@ -435,13 +435,6 @@ struct peer {
 				    - CRYPTO_TO_ZERO((struct peer *)0))
 
 /*
- * Thw last remnant of knowledge of driver type numbers outside of
- * refclock_conf.c. Ratained only to avoid a string compare on
- * the name.
- */
-#define REFCLK_ATOM_PPS		22	/* 1PPS Clock Discipline */
-
-/*
  * NTP packet format.  The mac field is optional.  It isn't really
  * an l_fp either, but for now declaring it that way is convenient.
  * See Appendix A in the specification.


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -2577,8 +2577,8 @@ clock_select(void)
 	 * are required.
 	 */
 	if (typepps != NULL && fabs(sys_offset) < 0.4 &&
-	    (typepps->refclktype != REFCLK_ATOM_PPS ||
-	    (typepps->refclktype == REFCLK_ATOM_PPS && (sys_prefer !=
+	    (!typepps->is_pps_driver ||
+	    (typepps->is_pps_driver && (sys_prefer !=
 	    NULL || (typesystem == NULL && sys_minsane == 0))))) {
 		typesystem = typepps;
 		sys_clockhop = 0;


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -197,7 +197,6 @@ refclock_newpeer(
 	/*
 	 * Initialize structures
 	 */
-	peer->refclktype = clktype;
 	peer->refclkunit = (uint8_t)unit;
 	peer->flags |= FLAG_REFCLOCK;
 	peer->leap = LEAP_NOTINSYNC;
@@ -556,8 +555,8 @@ refclock_receive(
 	clock_filter(peer, pp->offset, 0., pp->jitter);
 	if (cal_enable && fabs(last_offset) < sys_mindisp && sys_peer !=
 	    NULL) {
-		if (sys_peer->refclktype == REFCLK_ATOM_PPS &&
-		    peer->refclktype != REFCLK_ATOM_PPS)
+		if (sys_peer->is_pps_driver &&
+		    !peer->is_pps_driver)
 			pp->fudgetime1 -= pp->offset * FUDGEFAC;
 	}
 }


=====================================
ntpd/refclock_conf.c
=====================================
--- a/ntpd/refclock_conf.c
+++ b/ntpd/refclock_conf.c
@@ -152,14 +152,8 @@ extern struct refclock refclock_gpsdjson;
 
 /*
  * The symbols in the comments are no longer defined, except for REFCLK_ATOM_PPS.
- * If you compact or reorder this table, two bad things will happen:
- *
- * 1. Legacy ntpq instances that think they can deduce driver types from
- *    address fields will get them wrong.
- *
- * 2. If the PPS driver entry moves and you don't fix the definition of 
- *    REFCLK_ATOM_PPS to be a corrected index into this table, 
- *    some cases of PPS-assisted time sync will break.
+ * If you compact or reorder this table, legacy ntpq instances that think they
+ * can deduce driver types from address fields will get them wrong.
  */
 struct refclock * const refclock_conf[] = {
 	&refclock_none,		/* 0 REFCLK_NONE */


=====================================
ntpd/refclock_pps.c
=====================================
--- a/ntpd/refclock_pps.c
+++ b/ntpd/refclock_pps.c
@@ -130,6 +130,7 @@ pps_start(
 	 * Allocate and initialize unit structure
 	 */
 	pp = peer->procptr;
+	peer->is_pps_driver = true;
 	peer->precision = PRECISION;
 	pp->clockname = NAME;
 	pp->clockdesc = DESCRIPTION;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/f0cf98a93d34fae8f7e3a8403c452581b6298b4d...a24d99303af174c74bbc4aa9ccf6b09ce8bb8db9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160628/73fe7631/attachment.html>


More information about the vc mailing list