[Git][NTPsec/ntpsec][master] 2 commits: Abolish two macros that are obsolere following scalarization.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Jan 5 05:23:05 UTC 2017


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


Commits:
fdeafacb by Eric S. Raymond at 2017-01-04T23:13:36-05:00
Abolish two macros that are obsolere following scalarization.

- - - - -
8374c1fc by Eric S. Raymond at 2017-01-05T00:21:33-05:00
Abolish some macros that can be turbed into signedness-independent scalar ops.

- - - - -


24 changed files:

- include/ntp_fp.h
- libntp/systime.c
- libparse/clk_rawdcf.c
- libparse/clk_trimtsip.c
- libparse/data_mbg.c
- libparse/ieee754io.c
- libparse/parse.c
- ntpd/ntp_control.c
- ntpd/ntp_io.c
- ntpd/ntp_monitor.c
- ntpd/ntp_packetstamp.c
- ntpd/ntp_peer.c
- ntpd/ntp_proto.c
- ntpd/ntp_refclock.c
- ntpd/ntpd.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_jupiter.c
- ntpd/refclock_nmea.c
- ntpd/refclock_spectracom.c
- ntpd/refclock_truetime.c
- tests/libntp/lfpfunc.c
- tests/libntp/lfptest.h
- tests/libntp/timespecops.c


Changes:

=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -42,14 +42,6 @@ typedef uint64_t l_fp;
 #define setlfpuint(n, v)	(n) = (uint64_t)((((uint64_t)(v)) << 32) | ((n) & LOW32))
 #define bumplfpuint(n, i)	(n) += (i)*BUMP
 
-static inline uint64_t lfp_to_uint64(const l_fp lfp) {
-    return lfp;
-}
-
-static inline l_fp uint64_to_lfp(uint64_t x) {
-    return x;
-}
-
 static inline l_fp lfpinit(int32_t hi, uint32_t lo)
 {
     l_fp tmp = 0;
@@ -105,7 +97,6 @@ static inline l_fp_w htonl_fp(l_fp lfp) {
     lfpw.l_ui = htonl(lfpuint(lfp));
     lfpw.l_uf = htonl(lfpfrac(lfp));
     return lfpw;
-//  return lfpinit(htonl(lfpuint(lfp)), htonl(lfpfrac(lfp)));
 }
 
 static inline l_fp ntohl_fp(l_fp_w lfpw) {
@@ -145,22 +136,19 @@ static inline l_fp ntohl_fp(l_fp_w lfpw) {
 	(((v_i) & 0x80000000) != 0)
 
 /*
- * Operations on the long fp format
+ * Operations on the long fp format.  The only reason these aren't
+ * native operations is to be independent of whether the l_fp
+ * type is signed ot unsigned.
  */
-#define	L_ADD(r, a)	(*r) = uint64_to_lfp(lfp_to_uint64(*r)+lfp_to_uint64(*a))
-#define	L_SUB(r, a)	(*r) = uint64_to_lfp(lfp_to_uint64(*r)-lfp_to_uint64(*a))
-#define	L_NEG(v)	(*v) = uint64_to_lfp(-1 * (int64_t)lfp_to_uint64(*v))
-#define L_ADDUF(r, uf)	(*r) = uint64_to_lfp(lfp_to_uint64(*r) + (uf))
-#define L_SUBUF(r, uf)	(*r) = uint64_to_lfp(lfp_to_uint64(*r) - (uf))
-#define	L_ADDF(r, f)	(*r) = uint64_to_lfp((int64_t)lfp_to_uint64(*r) + (int64_t)(uf))
-#define	L_CLR(v)	*v = lfpinit(0, 0)
+#define	L_NEG(v)	(*v) = (-1 * (int64_t)(*v))
+#define L_ADDUF(r, uf)	(*r) = ((*r) + (uf))
+#define L_SUBUF(r, uf)	(*r) = ((*r) - (uf))
+#define	L_ADDF(r, f)	(*r) = ((int64_t)(*r) + (int64_t)(uf))
 #define	L_ISNEG(v)	M_ISNEG(lfpuint(*v))
-#define L_ISZERO(v)	((lfpuint(*v) | lfpfrac(*v)) == 0)
-#define	L_ISGT(a, b)	((int64_t)lfp_to_uint64(*a) > (int64_t)lfp_to_uint64(*b))
-#define	L_ISGTU(a, b)	(lfp_to_uint64(*a) > lfp_to_uint64(*b))
-#define	L_ISGEQ(a, b)	((int64_t)lfp_to_uint64(*a) >= (int64_t)lfp_to_uint64(*b))
-#define L_ISGEQU(a, b)  (lfp_to_uint64(*a) >= lfp_to_uint64(*b))
-#define	L_ISEQU(a, b)	(lfp_to_uint64(*a) == lfp_to_uint64(*b))
+#define	L_ISGT(a, b)	((int64_t)(*a) > (int64_t)(*b))
+#define	L_ISGTU(a, b)	((*a) > (*b))
+#define	L_ISGEQ(a, b)	((int64_t)(*a) >= (int64_t)(*b))
+#define L_ISGEQU(a, b)  ((*a) >= (*b))
 
 /*
  * s_fp/double and u_fp/double conversions


=====================================
libntp/systime.c
=====================================
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -188,14 +188,14 @@ normalize_time(
 	 */
 	dfuzz = rand * 2. / FRAC * sys_fuzz;
 	lfpfuzz = dtolfp(dfuzz);
-	L_ADD(&result, &lfpfuzz);
+	result += lfpfuzz;
 
 	/*
 	 * Ensure result is strictly greater than prior result (ignoring
 	 * sys_residual's effect for now) once sys_fuzz has been
 	 * determined.
 	 */
-	if (!L_ISZERO(&lfp_prev) && !lamport_violated) {
+	if (lfp_prev != 0 && !lamport_violated) {
 		if (!L_ISGTU(&result, &lfp_prev) &&
 		    sys_fuzz > 0.) {
 			msyslog(LOG_ERR, "ts_prev %s ts_min %s",
@@ -207,7 +207,7 @@ normalize_time(
 			msyslog(LOG_ERR, "this fuzz %.9f",
 				dfuzz);
 			lfpdelta = lfp_prev;
-			L_SUB(&lfpdelta, &result);
+			lfpdelta -= result;
 			ddelta = lfptod(lfpdelta);
 			msyslog(LOG_ERR,
 				"prev get_systime 0x%x.%08x is %.9f later than 0x%x.%08x",
@@ -364,7 +364,7 @@ step_systime(
 	/* get the complete jump distance as l_fp */
 	fp_sys = dtolfp(sys_residual);
 	fp_ofs = dtolfp(step);
-	L_ADD(&fp_ofs, &fp_sys);
+	fp_ofs += fp_sys;
 
 	/* ---> time-critical path starts ---> */
 
@@ -377,7 +377,7 @@ step_systime(
 	tslast.tv_nsec = timets.tv_nsec;
 
 	/* get the target time as l_fp */
-	L_ADD(&fp_sys, &fp_ofs);
+	fp_sys += fp_ofs;
 
 	/* unfold the new system time */
 	timets = lfp_stamp_to_tspec(fp_sys, &pivot);


=====================================
libparse/clk_rawdcf.c
=====================================
--- a/libparse/clk_rawdcf.c
+++ b/libparse/clk_rawdcf.c
@@ -510,7 +510,7 @@ calc_usecdiff(
 
 	delt = ref->fp;
 	setlfpsint(delt, lfpsint(delt) + offset);
-	L_SUB(&delt, &base->fp);
+	delt -= base->fp;
 	delta = lfp_stamp_to_tspec(delt, NULL);
 
 	delta_usec = 1000000 * (int32_t)delta.tv_sec + delta.tv_nsec/1000;


=====================================
libparse/clk_trimtsip.c
=====================================
--- a/libparse/clk_trimtsip.c
+++ b/libparse/clk_trimtsip.c
@@ -241,7 +241,7 @@ cvt_trimtsip(
 				    if (fetch_ieee754(&bp, IEEE_SINGLE, &utcoffset, trim_offsets) != IEEE_OK)
 					    return CVT_FAIL|CVT_BADFMT;
 
-				    L_SUB(&secs, &utcoffset); /* adjust GPS time to UTC time */
+				    secs -= utcoffset; /* adjust GPS time to UTC time */
 
 				    gpstolfp((unsigned short)week, (unsigned short)0,
 					     lfpuint(secs), &gpstime);


=====================================
libparse/data_mbg.c
=====================================
--- a/libparse/data_mbg.c
+++ b/libparse/data_mbg.c
@@ -295,12 +295,12 @@ get_mbg_utc(
 
   if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A0, mbg_double) != IEEE_OK)
     {
-      L_CLR(&utcp->A0);
+      utcp->A0 = 0;
     }
 
   if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A1, mbg_double) != IEEE_OK)
     {
-      L_CLR(&utcp->A1);
+      utcp->A1 = 0;
     }
 
   utcp->WNlsf      = get_lsb_uint16(buffpp);
@@ -321,7 +321,7 @@ get_mbg_lla(
     {
       if  (fetch_ieee754(buffpp, IEEE_DOUBLE, &lla[i], mbg_double) != IEEE_OK)
 	{
-	  L_CLR(&lla[i]);
+	  lla[i] = 0;
 	}
       else
 	if (i != ALT)
@@ -343,7 +343,7 @@ get_mbg_xyz(
     {
       if  (fetch_ieee754(buffpp, IEEE_DOUBLE, &xyz[i], mbg_double) != IEEE_OK)
 	{
-	  L_CLR(&xyz[i]);
+	  xyz[i] = 0;
 	}
     }
 }
@@ -385,7 +385,7 @@ get_mbg_portparam(
 #define FETCH_DOUBLE(src, addr)							\
 	if  (fetch_ieee754(src, IEEE_DOUBLE, addr, mbg_double) != IEEE_OK)	\
 	{									\
-	  L_CLR(addr);								\
+	  *addr = 0;								\
 	}
 
 void


=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -275,7 +275,7 @@ fetch_ieee754(
        * collect real numbers
        */
 
-      L_CLR(lfpp);
+      *lfpp = 0;
 
       /*
        * check for overflows
@@ -439,7 +439,7 @@ put_ieee754(
 #endif
     }
 
-  if (L_ISZERO(&outlfp))
+  if (outlfp == 0)
     {
 #ifdef DEBUG_PARSELIB
       exponent = mantissa_high = mantissa_low = 0; /* true zero */


=====================================
libparse/parse.c
=====================================
--- a/libparse/parse.c
+++ b/libparse/parse.c
@@ -36,7 +36,7 @@ parse_timedout(
 	l_fp delt;
 
 	delt = tstamp->fp;
-	L_SUB(&delt, &parseio->parse_lastchar.fp);
+	delt -= parseio->parse_lastchar.fp;
 	delta = lfp_uintv_to_tspec(delt);
 	if (cmp_tspec(delta, *del) == TIMESPEC_GREATER_THAN)
 	{


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -3091,7 +3091,7 @@ static int validate_nonce(
 	ts = lfpinit((uint32_t)ts_i, (uint32_t)ts_f);
 	derived = derive_nonce(&rbufp->recv_srcadr, lfpuint(ts), lfpfrac(ts));
 	get_systime(&now_delta);
-	L_SUB(&now_delta, &ts);
+	now_delta -= ts;
 
 	return (supposed == derived && lfpuint(now_delta) < NONCE_TIMEOUT);
 }
@@ -3515,7 +3515,7 @@ static void read_mru_list(
 			if (ADDR_PORT_EQ(&mon->rmtadr, &addr[i]))
 				break;
 		if (mon != NULL) {
-			if (L_ISEQU(&mon->last, &last[i]))
+			if (mon->last == last[i])
 				break;
 			mon = NULL;
 		}


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -2582,7 +2582,7 @@ input_handler(
 	 * (ts_e - ts) is the amount of time we spent processing this
 	 * gob of file descriptors.  Log it.
 	 */
-	L_SUB(&ts_e, &ts);
+	ts_e -= ts;
 	collect_timing(NULL, "input handler", 1, &ts_e);
 	if (debug > 3)
 		msyslog(LOG_DEBUG,


=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -292,7 +292,7 @@ int mon_get_oldest_age(l_fp now)
     if (mru_entries == 0)
 	return 0;
     oldest = TAIL_DLIST(mon_mru_list, mru);
-    L_SUB(&now, &oldest->last);
+    now -= oldest->last;
     /* add one-half second to round up */
     L_ADDUF(&now, 0x80000000);
     return lfpsint(now);
@@ -353,7 +353,7 @@ ntp_monitor(
 	if (mon != NULL) {
 		mru_exists++;
 		interval_fp = rbufp->recv_time;
-		L_SUB(&interval_fp, &mon->last);
+		interval_fp -= mon->last;
 		/* add one-half second to round up */
 		L_ADDUF(&interval_fp, 0x80000000);
 		interval = lfpsint(interval_fp);


=====================================
ntpd/ntp_packetstamp.c
=====================================
--- a/ntpd/ntp_packetstamp.c
+++ b/ntpd/ntp_packetstamp.c
@@ -191,10 +191,10 @@ fetch_packetstamp(
 			}
 			fuzz = ntp_random() * 2. / FRAC * sys_fuzz;
 			lfpfuzz = dtolfp(fuzz);
-			L_ADD(&nts, &lfpfuzz);
+			nts += lfpfuzz;
 #ifdef ENABLE_DEBUG_TIMING
 			dts = ts;
-			L_SUB(&dts, &nts);
+			dts -= nts;
 			collect_timing(rb, "input processing delay", 1,
 				       &dts);
 			DPRINTF(4, ("fetch_timestamp: timestamp delta: %s (incl. fuzz)\n",


=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -306,8 +306,7 @@ findpeer(
                 if (MODE_SERVER == pkt_mode && AM_PROCPKT == *action) {
                         pkt = &rbufp->recv_pkt;
                         pkt_org = ntohl_fp(pkt->org);
-                        if (!L_ISEQU(&p->org, &pkt_org) &&
-                            findmanycastpeer(rbufp))
+                        if (p->org != pkt_org && findmanycastpeer(rbufp))
                                 *action = AM_ERR;
                 }
 
@@ -859,7 +858,7 @@ findmanycastpeer(
 	for (peer = peer_list; peer != NULL; peer = peer->p_link)
 		if (MDF_SOLICIT_MASK & peer->cast_flags) {
 			p_org = ntohl_fp(pkt->org);
-			if (L_ISEQU(&p_org, &peer->org))
+			if (p_org == peer->org)
 				break;
 		}
 


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -510,7 +510,7 @@ handle_procpkt(
 	peer->flash &= ~PKT_BOGON_MASK;
 
 	/* Duplicate detection */
-	if(pkt->xmt == lfp_to_uint64(peer->xmt)) {
+	if(pkt->xmt == peer->xmt) {
 		peer->flash |= BOGON1;
 		peer->oldpkt++;
 		return;
@@ -527,7 +527,7 @@ handle_procpkt(
 			peer->flash |= BOGON3;
 			peer->bogusorg++;
 			return;
-		} else if(pkt->org != lfp_to_uint64(peer->org)) {
+		} else if(pkt->org != peer->org) {
 			peer->flash |= BOGON2;
 			peer->bogusorg++;
 			return;
@@ -578,15 +578,14 @@ handle_procpkt(
 	   avoid loss of precision.
 	*/
 
-	const uint64_t dst = lfp_to_uint64(rbufp->recv_time);
 	const double t34 =
-	    (pkt->xmt >= dst) ?
-	    scalbn((double)(pkt->xmt - dst), -32) :
-	    -scalbn((double)(dst - pkt->xmt), -32);
+	    (pkt->xmt >= rbufp->recv_time) ?
+	    scalbn((double)(pkt->xmt - rbufp->recv_time), -32) :
+	    -scalbn((double)(rbufp->recv_time - pkt->xmt), -32);
 	const double t21 =
-	    (pkt->rec >= lfp_to_uint64(peer->org)) ?
-	    scalbn((double)(pkt->rec - lfp_to_uint64(peer->org)), -32) :
-	    -scalbn((double)(lfp_to_uint64(peer->org) - pkt->rec), -32);
+	    (pkt->rec >= peer->org) ?
+	    scalbn((double)(pkt->rec - peer->org), -32) :
+	    -scalbn((double)(peer->org - pkt->rec), -32);
 	const double theta = (t21 + t34) / 2.;
 	const double delta = fabs(t21 - t34);
 	const double epsilon = LOGTOD(sys_precision) +
@@ -618,9 +617,9 @@ handle_procpkt(
 	peer->rootdelay = scalbn((double)pkt->rootdelay, -16);
 	peer->rootdisp = scalbn((double)pkt->rootdisp, -16);
 	memcpy(&peer->refid, pkt->refid, REFIDLEN);
-	peer->reftime = uint64_to_lfp(pkt->reftime);
-	peer->rec = uint64_to_lfp(pkt->rec);
-	peer->xmt = uint64_to_lfp(pkt->xmt);
+	peer->reftime = pkt->reftime;
+	peer->rec = pkt->rec;
+	peer->xmt = pkt->xmt;
 	peer->dst = rbufp->recv_time;
 
 	record_raw_stats(&peer->srcadr,
@@ -1093,7 +1092,7 @@ clock_update(
 		memcpy(&sys_refid, "STEP", REFIDLEN);
 		sys_rootdelay = 0;
 		sys_rootdisp = 0;
-		L_CLR(&sys_reftime);
+		sys_reftime = 0;
 		sys_jitter = LOGTOD(sys_precision);
 		leapsec_reset_frame();
 		break;
@@ -2216,7 +2215,7 @@ peer_xmit(
 static void
 leap_smear_add_offs(l_fp *t, l_fp *t_recv) {
 	UNUSED_ARG(t_recv);
-	L_ADD(t, &leap_smear.offset);
+	t += leap_smear.offset;
 }
 
 #endif	/* ENABLE_LEAP_SMEAR */
@@ -2368,7 +2367,7 @@ fast_xmit(
 	sendlen += authencrypt(xkeyid, (uint32_t *)&xpkt, sendlen);
 	sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, 0, &xpkt, sendlen);
 	get_systime(&xmt_ty);
-	L_SUB(&xmt_ty, &xmt_tx);
+	xmt_ty -= xmt_tx;
 	sys_authdelay = xmt_ty;
 #ifdef DEBUG
 	if (debug)
@@ -2675,7 +2674,7 @@ measure_tick_fuzz(void)
 	for (i = 0; i < MAXLOOPS && changes < MINCHANGES; i++) {
 		get_systime(&val);
 		ldiff = val;
-		L_SUB(&ldiff, &last);
+		ldiff -= last;
 		last = val;
 		if (L_ISGT(&ldiff, &minstep)) {
 			max_repeats = max(repeats, max_repeats);
@@ -2758,7 +2757,7 @@ init_proto(const bool verbose)
 	sys_peer = NULL;
 	sys_rootdelay = 0;
 	sys_rootdisp = 0;
-	L_CLR(&sys_reftime);
+	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
@@ -363,7 +363,7 @@ refclock_process_offset(
 
 	pp->lastrec = lastrec;
 	lftemp = lasttim;
-	L_SUB(&lftemp, &lastrec);
+	lftemp -= lastrec;
 	doffset = lfptod(lftemp);
 	SAMPLE(doffset + fudge);
 }
@@ -391,7 +391,7 @@ refclock_process_f(
 	double fudge
 	)
 {
-	l_fp offset, ltemp;
+	l_fp offset = 0, ltemp = 0;
 	uint32_t sec;
 
 	/*
@@ -409,7 +409,7 @@ refclock_process_f(
 	setlfpuint(offset, sec);
 	setlfpfrac(offset, 0);
 	ltemp = dtolfp(pp->nsec / 1e9);
-	L_ADD(&offset, &ltemp);
+	offset += ltemp;
 	refclock_process_offset(pp, offset, pp->lastrec, fudge);
 	return true;
 }


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -924,7 +924,7 @@ static void mainloop(void)
 # ifdef ENABLE_DEBUG_TIMING
 					l_fp dts = pts;
 
-					L_SUB(&dts, &rbuf->recv_time);
+					dts -= rbuf->recv_time;
 					DPRINTF(2, ("processing timestamp delta %s (with prec. fuzz)\n", lfptoa(&dts, 9)));
 					collect_timing(rbuf, "buffer processing delay", 1, &dts);
 					bufcount++;
@@ -940,7 +940,7 @@ static void mainloop(void)
 			}
 # ifdef ENABLE_DEBUG_TIMING
 			get_systime(&tsb);
-			L_SUB(&tsb, &tsa);
+			tsb -= tsa;
 			if (bufcount) {
 				collect_timing(NULL, "processing", bufcount, &tsb);
 				DPRINTF(2, ("processing time for %d buffers %s\n", bufcount, lfptoa(&tsb, 9)));


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -3037,7 +3037,7 @@ parse_control(
 				 * WARNING: assumes on TIMECODE == PULSE (timecode after pulse)
 				 */
 				off = parse->timedata.parse_stime.fp;
-				L_SUB(&off, &parse->timedata.parse_ptime.fp); /* true offset */
+				off -= parse->timedata.parse_ptime.fp; /* true offset */
 				tt = add_var(&out->kv_list, 80, RO);
 				snprintf(tt, 80, "refclock_ppsskew=%s", lfptoms(off, 6));
 			}
@@ -3469,7 +3469,7 @@ parse_process(
 		rectime = parsetime->parse_stime.fp;
 		off = reftime = parsetime->parse_time.fp;
 
-		L_SUB(&off, &rectime); /* prepare for PPS adjustments logic */
+		off -= rectime; /* prepare for PPS adjustments logic */
 
 #ifdef DEBUG
 		if (debug > 3)
@@ -3542,7 +3542,7 @@ parse_process(
 					 */
 					reftime = off = parsetime->parse_time.fp;
 
-					L_SUB(&off, &offset); /* true offset */
+					off -= offset; /* true offset */
 				}
 			}
 			/*
@@ -3593,7 +3593,7 @@ parse_process(
 
 
 	rectime = reftime;
-	L_SUB(&rectime, &off);	/* just to keep the ntp interface happy */
+	rectime -= off;	/* just to keep the ntp interface happy */
 
 #ifdef DEBUG
 	if (debug > 3)


=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -1565,7 +1565,7 @@ process_tpv(
 			 */
 			up->ibt_local = *rtime;
 			up->ibt_recvt = *rtime;
-			L_SUB(&up->ibt_recvt, &up->ibt_fudge);
+			up->ibt_recvt -= up->ibt_fudge;
 			up->fl_ibt = -1;
 		} else {
 			++up->tc_breply;
@@ -1640,8 +1640,8 @@ process_pps(
 	
 	/* Get fudged receive times for primary & secondary unit */
 	up->pps_recvt = up->pps_recvt2;
-	L_SUB(&up->pps_recvt , &up->pps_fudge );
-	L_SUB(&up->pps_recvt2, &up->pps_fudge2);
+	up->pps_recvt -= up->pps_fudge;
+	up->pps_recvt2 -= up->pps_fudge2;
 	pp->lastrec = up->pps_recvt;
 
 	/* Map to nearest full second as reference time stamp for the
@@ -1696,7 +1696,7 @@ process_toff(
 	if ( ! get_binary_time(&up->ibt_stamp, jctx,
 			       "real_sec", "real_nsec", 1))
 			goto fail;
-	L_SUB(&up->ibt_recvt, &up->ibt_fudge);
+	up->ibt_recvt -= up->ibt_fudge;
 	up->ibt_local = *rtime;
 	up->fl_ibt    = -1;
 
@@ -1772,7 +1772,7 @@ gpsd_parse(
 	if (up->fl_pps && up->fl_ibt) {
 		l_fp diff;
 		diff = up->ibt_local;
-		L_SUB(&diff, &up->pps_local);
+		diff -= up->pps_local;
 		if (lfpsint(diff) > 0)
 			up->fl_pps = 0; /* pps too old */
 		else if (lfpsint(diff) < 0)


=====================================
ntpd/refclock_jupiter.c
=====================================
--- a/ntpd/refclock_jupiter.c
+++ b/ntpd/refclock_jupiter.c
@@ -819,7 +819,7 @@ jupiter_receive(struct recvbuf *rbufp)
 			 * (i.e. before limit, a.k.a. fudgetime2) in
 			 * the second.
 			 */
-			L_SUB(&tstamp, &pp->lastrec);
+			tstamp -= pp->lastrec;
 			if (!L_ISGEQ(&tstamp, &instance->limit))
 				bumplfpuint(pp->lastrec, 1);
 


=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -720,7 +720,7 @@ refclock_ppsrelate(
 	/* get delta between receive time and PPS time */
 	pp_stamp = tspec_stamp_to_lfp(timeout);
 	pp_delta = *rd_stamp;
-	L_SUB(&pp_delta, &pp_stamp);
+	pp_delta -= pp_stamp;
 	delta = lfptod(pp_delta);
 	delta += pp_fudge - *rd_fudge;
 	if (fabs(delta) > 1.5)
@@ -743,7 +743,7 @@ refclock_ppsrelate(
 
 	/* check against reftime if PPS PLL can be used */
 	pp_delta = *reftime;
-	L_SUB(&pp_delta, &pp_stamp);
+	pp_delta-= pp_stamp;
 	delta = lfptod(pp_delta);
 	delta += pp_fudge;
 	if (fabs(delta) > 0.45)
@@ -1026,7 +1026,7 @@ nmea_receive(
 	 * Discard sentence if reference time did not change.
 	 */
 	rd_reftime = eval_gps_time(peer, &date, &tofs, &rd_timestamp);
-	if (L_ISEQU(&up->last_reftime, &rd_reftime)) {
+	if (up->last_reftime == rd_reftime) {
 		/* Do not touch pp->a_lastcode on purpose! */
 		up->tally.filtered++;
 		return;


=====================================
ntpd/refclock_spectracom.c
=====================================
--- a/ntpd/refclock_spectracom.c
+++ b/ntpd/refclock_spectracom.c
@@ -299,7 +299,7 @@ spectracom_receive(
 	DPRINTF(2, ("wwvb: code @ %s\n"
 		    "       using %s minus one char\n",
 		    prettydate(&trtmp), prettydate(&pp->lastrec)));
-	if (L_ISZERO(&pp->lastrec))
+	if (pp->lastrec == 0)
 		return;
 
 	/*


=====================================
ntpd/refclock_truetime.c
=====================================
--- a/ntpd/refclock_truetime.c
+++ b/ntpd/refclock_truetime.c
@@ -517,7 +517,7 @@ true_receive(
 			/*
 			 * Create a true offset for feeding to pps_sample()
 			 */
-			L_SUB(&off, &pp->lastrec);
+			off -= pp->lastrec;
 
 			pps_sample(peer, &off);
 #endif


=====================================
tests/libntp/lfpfunc.c
=====================================
--- a/tests/libntp/lfpfunc.c
+++ b/tests/libntp/lfpfunc.c
@@ -86,7 +86,7 @@ static int l_fp_ucmp(const l_fp first, l_fp second)
 static l_fp l_fp_add(const l_fp first, const l_fp second)
 {
 	l_fp temp = first;
-	L_ADD(&temp, &second);
+	temp += second;
 
 	return temp;
 }
@@ -94,7 +94,7 @@ static l_fp l_fp_add(const l_fp first, const l_fp second)
 static l_fp l_fp_subtract(const l_fp first, const l_fp second)
 {
 	l_fp temp = first;
-	L_SUB(&temp, &second);
+	temp -= second;
 
 	return temp;
 }
@@ -161,7 +161,7 @@ static bool l_isgeq(const l_fp first, const l_fp second)
 
 static bool l_isequ(const l_fp first, const l_fp second)
 {
-	return L_ISEQU(&first, &second);
+	return first == second;
 }
 
 


=====================================
tests/libntp/lfptest.h
=====================================
--- a/tests/libntp/lfptest.h
+++ b/tests/libntp/lfptest.h
@@ -4,7 +4,7 @@
 #include "ntp_fp.h"
 
 static bool IsEqual(const l_fp *expected, const l_fp *actual) {
-	if (L_ISEQU(expected, actual)) {
+	if (expected == actual) {
 		return true;
 	} else {
 		printf("Expected: %s (%d.%d) but was: %s (%d.%d)\n", lfptoa(*expected, FRACTION_PREC), lfpuint(*expected), lfpfrac(*expected), lfptoa(*actual, FRACTION_PREC), lfpuint(*actual), lfpfrac(*actual));


=====================================
tests/libntp/timespecops.c
=====================================
--- a/tests/libntp/timespecops.c
+++ b/tests/libntp/timespecops.c
@@ -63,10 +63,10 @@ static bool AssertFpClose(const l_fp m, const l_fp n, const l_fp limit)
 
 	if (L_ISGEQ(&m, &n)) {
 		diff = m;
-		L_SUB(&diff, &n);
+		diff -= n;
 	} else {
 		diff = n;
-		L_SUB(&diff, &m);
+		diff -= m;
 	}
 	if (L_ISGEQ(&limit, &diff)) {
 		return true;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/d4c2a76b06248734103f886916bf4cf7a1f5724d...8374c1fc7350afc1e33309bb1553b16abbb6f547
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170105/b27934f0/attachment.html>


More information about the vc mailing list