[Git][NTPsec/ntpsec][master] 3 commits: l_fp encapsulation - the easy parts.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Dec 25 09:08:44 UTC 2016


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


Commits:
027f91ff by Eric S. Raymond at 2016-12-24T17:16:18-05:00
l_fp encapsulation - the easy parts.

Replace most uses of l_fp structure fields with setter/getter macros.
This is a halfway step to changing the representation of the type
to a 64-bit scalar.

It's only 'most' because a few of the replacements will not be simple
substitutions.  This revision contains only the simple ones.

- - - - -
7686c385 by Eric S. Raymond at 2016-12-24T18:02:45-05:00
lfp encapsulation in ntptime.

One of the not entirely trivial bits.

- - - - -
d2b30c66 by Eric S. Raymond at 2016-12-25T04:08:09-05:00
lfp encapsulation in refidsmear.c.

Another not entirely trivial bit. Good thing there's a unit test.

- - - - -


27 changed files:

- include/ntp_fp.h
- include/timespecops.h
- libntp/atolfp.c
- libntp/hextolfp.c
- libntp/prettydate.c
- libntp/refidsmear.c
- libntp/systime.c
- libparse/clk_trimtsip.c
- libparse/gpstolfp.c
- libparse/ieee754io.c
- ntpd/ntp_control.c
- ntpd/ntp_packetstamp.c
- ntpd/ntp_refclock.c
- ntpd/refclock_generic.c
- ntpd/refclock_gpsd.c
- ntpd/refclock_jupiter.c
- ntpd/refclock_magnavox.c
- ntpd/refclock_nmea.c
- ntpd/refclock_oncore.c
- ntpd/refclock_truetime.c
- ntpfrob/jitter.c
- ntptime/ntptime.c
- tests/libntp/lfpfunc.c
- tests/libntp/lfptest.h
- tests/libntp/lfptostr.c
- tests/libntp/strtolfp.c
- tests/libntp/timespecops.c


Changes:

=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -38,15 +38,20 @@ typedef struct {
 #define l_ui	Ul_i.Xl_ui		/* unsigned integral part */
 #define	l_i	Ul_i.Xl_i		/* signed integral part */
 
+#define lfpfrac(n)		((n).l_uf)
+#define setlfpfrac(n, v)	(n).l_uf = (v)
+#define lfpsint(n)		(n).l_i
+#define setlfpsint(n, v)	(n).l_i = (v)
+#define lfpuint(n)		(n).l_ui
+#define setlfpuint(n, v)	(n).l_ui = (v)
+
 static inline uint64_t lfp_to_uint64(const l_fp *lfp) {
-  return
-    (uint64_t)lfp->l_ui << 32 |
-    (uint64_t)lfp->l_uf;
+    return (uint64_t)lfpuint(*lfp) << 32 | (uint64_t)lfpfrac(*lfp);
 }
 
 static inline void uint64_to_lfp(l_fp *lfp, uint64_t x) {
-  lfp->l_ui = x >> 32;
-  lfp->l_uf = x & 0xFFFFFFFFUL;
+  setlfpuint(*lfp, x >> 32);
+  setlfpfrac(*lfp, x & 0xFFFFFFFFUL);
 }
 
 /*
@@ -99,16 +104,16 @@ typedef uint32_t u_fp;
 	} while (false)
 
 #define HTONL_FP(h, n)						\
-	HTONL_MFP((h)->l_ui, (h)->l_uf, (n)->l_ui, (n)->l_uf)
+	HTONL_MFP(lfpuint(*h), lfpfrac(*h), lfpuint(*n), lfpfrac(*n))
 
 #define NTOHL_FP(n, h)						\
-	NTOHL_MFP((n)->l_ui, (n)->l_uf, (h)->l_ui, (h)->l_uf)
+	NTOHL_MFP(lfpuint(*n), lfpfrac(*n), lfpuint(*h), lfpfrac(*h))
 
 /* Convert unsigned ts fraction to net order ts */
 #define	HTONL_UF(uf, nts)					\
 	do {							\
-		(nts)->l_ui = 0;				\
-		(nts)->l_uf = htonl(uf);			\
+		setlfpuint(*nts, 0);					\
+		setlfpfrac(*nts, htonl(uf));			\
 	} while (false)
 
 /*
@@ -117,13 +122,13 @@ typedef uint32_t u_fp;
 #define	MFPTOFP(x_i, x_f)	(((x_i) >= 0x00010000) ? 0x7fffffff : \
 				(((x_i) <= -0x00010000) ? 0x80000000 : \
 				(((x_i)<<16) | (((x_f)>>16)&0xffff))))
-#define	LFPTOFP(v)		MFPTOFP((v)->l_i, (v)->l_uf)
+#define	LFPTOFP(v)		MFPTOFP(lfpsint(*v), lfprac(*v))
 
-#define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16)
-#define FPTOLFP(x, v)  (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0)
+#define UFPTOLFP(x, v) (setlfpuint(*v, (u_fp)(x)>>16), setlfpfrac(*v, (x)<<16))
+#define FPTOLFP(x, v)  (UFPTOLFP((x), (v)), (x) < 0 ? setlfpuint(*v, getlfpuint(*v) - 0x10000) : 0)
 
-#define MAXLFP(v) ((v)->l_ui = 0x7fffffffu, (v)->l_uf = 0xffffffffu)
-#define MINLFP(v) ((v)->l_ui = 0x80000000u, (v)->l_uf = 0u)
+#define MAXLFP(v) (setlfpuint(*v, 0x7fffffffu), setlfpfrac(*v, 0xffffffffu))
+#define MINLFP(v) (selfpuint(*v, 0x80000000u), setlfpfrac(*v, 0u))
 
 /*
  * Primitive operations on long fixed point values.  If these are
@@ -235,26 +240,27 @@ typedef uint32_t u_fp;
 
 /*
  * Operations on the long fp format
+ * FIXME: Using lfpuint(x) as rvalue, this will fail when rpresentation changes 
  */
-#define	L_ADD(r, a)	M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
-#define	L_SUB(r, a)	M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
-#define	L_NEG(v)	M_NEG((v)->l_ui, (v)->l_uf)
-#define L_ADDUF(r, uf)	M_ADDUF((r)->l_ui, (r)->l_uf, (uf))
-#define L_SUBUF(r, uf)	M_SUBUF((r)->l_ui, (r)->l_uf, (uf))
-#define	L_ADDF(r, f)	M_ADDF((r)->l_ui, (r)->l_uf, (f))
-#define	L_RSHIFT(v)	M_RSHIFT((v)->l_i, (v)->l_uf)
-#define	L_RSHIFTU(v)	M_RSHIFTU((v)->l_ui, (v)->l_uf)
-#define	L_LSHIFT(v)	M_LSHIFT((v)->l_ui, (v)->l_uf)
-#define	L_CLR(v)	((v)->l_ui = (v)->l_uf = 0)
-
-#define	L_ISNEG(v)	M_ISNEG((v)->l_ui)
-#define L_ISZERO(v)	(((v)->l_ui | (v)->l_uf) == 0)
-#define	L_ISGT(a, b)	M_ISGT((a)->l_i, (a)->l_uf, (b)->l_i, (b)->l_uf)
-#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_ADD(r, a)	M_ADD(lfpuint(*r), lfpfrac(*r), lfpuint(*a), lfpfrac(*a))
+#define	L_SUB(r, a)	M_SUB(lfpuint(*r), lfpfrac(*r), lfpuint(*a), lfpfrac(*a))
+#define	L_NEG(v)	M_NEG(lfpuint(*v), lfpfrac(*v))
+#define L_ADDUF(r, uf)	M_ADDUF(lfpuint(*r), lfpfrac(*r), (uf))
+#define L_SUBUF(r, uf)	M_SUBUF(lfpuint(*r), lfpfrac(*r), (uf))
+#define	L_ADDF(r, f)	M_ADDF(lfpuint(*r), lfpfrac(*r), (f))
+#define	L_RSHIFT(v)	M_RSHIFT(lfpsint(*v), lfpfrac(*v))
+#define	L_RSHIFTU(v)	M_RSHIFTU(lfpuint(*v), lfpfrac(*v))
+#define	L_LSHIFT(v)	M_LSHIFT(lfpuint(*v), lfpfrac(*v))
+
+#define	L_CLR(v)	(setlfpuint(*v, 0), setlfpfrac(*v, 0))
+#define	L_ISNEG(v)	M_ISNEG(lfpuint(*v))
+#define L_ISZERO(v)	((lfpuint(*v) | lfpfrac(*v)) == 0)
+#define	L_ISGT(a, b)	M_ISGT(lfpsint(*a), lfpfrac(*a), lfpsint(*b), lfpfrac(*b))
+#define	L_ISGTU(a, b)	M_ISGTU(lfpuint(*a), lfpfrac(*a), lfpuint(*b), lfpfrac(*b))
+#define	L_ISHIS(a, b)	M_ISHIS(lfpuint(*a), lfpfrac(*a), lfpuint(*b), lfpfrac(*b))
+#define	L_ISGEQ(a, b)	M_ISGEQ(lfpuint(*a), lfpfrac(*a), lfpuint(*b), lfpfrac(*b))
 #define L_ISGEQU(a, b)  L_ISHIS(a, b)
-#define	L_ISEQU(a, b)	M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
+#define	L_ISEQU(a, b)	M_ISEQU(lfpuint(*a), lfpfrac(*a), lfpuint(*b), lfpfrac(*b))
 
 /*
  * s_fp/double and u_fp/double conversions
@@ -341,8 +347,8 @@ typedef uint32_t u_fp;
 	} while (0)
 #endif
 
-#define DTOLFP(d, v) 	M_DTOLFP((d), (v)->l_ui, (v)->l_uf)
-#define LFPTOD(v, d) 	M_LFPTOD((v)->l_ui, (v)->l_uf, (d))
+#define DTOLFP(d, v) 	M_DTOLFP((d), lfpuint(*v), lfpfrac(*v))
+#define LFPTOD(v, d) 	M_LFPTOD(lfpuint(*v), lfpfrac(*v), (d))
 
 /*
  * Prototypes
@@ -369,13 +375,13 @@ extern	void	get_systime	(l_fp *);
 extern	bool	step_systime	(double, int (*settime)(struct timespec *));
 extern	bool	adj_systime	(double, int (*adjtime)(const struct timeval *, struct timeval *));
 
-#define	lfptoa(fpv, ndec)	mfptoa((fpv)->l_ui, (fpv)->l_uf, (ndec))
-#define	lfptoms(fpv, ndec)	mfptoms((fpv)->l_ui, (fpv)->l_uf, (ndec))
+#define	lfptoa(fpv, ndec)	mfptoa(lfpuint(*fpv), lfpfrac(*fpv), (ndec))
+#define	lfptoms(fpv, ndec)	mfptoms(lfpuint(*fpv), lfpfrac(*fpv), (ndec))
 
 #define	ufptoa(fpv, ndec)	dofptoa((fpv), false, (ndec), false)
 #define	ufptoms(fpv, ndec)	dofptoa((fpv), false, (ndec), true)
-#define	ulfptoa(fpv, ndec)	dolfptoa((fpv)->l_ui, (fpv)->l_uf, 0, (ndec), 0)
-#define	ulfptoms(fpv, ndec)	dolfptoa((fpv)->l_ui, (fpv)->l_uf, 0, (ndec), 1)
+#define	ulfptoa(fpv, ndec)	dolfptoa(lfpuint(*fpv), lfpfrac(*fpv), 0, (ndec), 0)
+#define	ulfptoms(fpv, ndec)	dolfptoa(lfpuint(*fpv), lfpfrac(*fpv), 0, (ndec), 1)
 #define	umfptoa(fpi, fpf, ndec) dolfptoa((fpi), (fpf), 0, (ndec), 0)
 
 /*


=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -301,8 +301,8 @@ tspec_intv_to_lfp(
 	l_fp		y;
 	
 	v = normalize_tspec(x);
-	y.l_uf = TVNTOF(v.tv_nsec);
-	y.l_i = (int32_t)v.tv_sec;
+	setlfpfrac(y, TVNTOF(v.tv_nsec));
+	setlfpsint(y, (int32_t)v.tv_sec);
 
 	return y;
 }
@@ -316,7 +316,7 @@ tspec_stamp_to_lfp(
 	l_fp		y;
 
 	y = tspec_intv_to_lfp(x);
-	y.l_ui += JAN_1970;
+	lfpuint(y) += JAN_1970;
 
 	return y;
 }
@@ -336,7 +336,7 @@ lfp_intv_to_tspec(
 	if (neg) {
 		L_NEG(&absx);	
 	}
-	out.tv_nsec = FTOTVN(absx.l_uf);
+	out.tv_nsec = FTOTVN(lfpfrac(absx));
 	out.tv_sec = absx.l_i;
 	if (neg) {
 		out.tv_sec = -out.tv_sec;
@@ -354,8 +354,8 @@ lfp_uintv_to_tspec(
 {
 	struct timespec	out;
 	
-	out.tv_nsec = FTOTVN(x.l_uf);
-	out.tv_sec = x.l_ui;
+	out.tv_nsec = FTOTVN(lfpfrac(x));
+	out.tv_sec = lfpuint(x);
 
 	return out;
 }
@@ -374,8 +374,8 @@ lfp_stamp_to_tspec(
 	struct timespec	out;
 	time64_t		sec;
 
-	sec = ntpcal_ntp_to_time(x.l_ui, p);
-	out.tv_nsec = FTOTVN(x.l_uf);
+	sec = ntpcal_ntp_to_time(lfpuint(x), p);
+	out.tv_nsec = FTOTVN(lfpfrac(x));
 
 	/* copying a time64_t to a time_t needs some care... */
 #if NTP_SIZEOF_TIME_T <= 4


=====================================
libntp/atolfp.c
=====================================
--- a/libntp/atolfp.c
+++ b/libntp/atolfp.c
@@ -116,7 +116,7 @@ atolfp(
 	if (isneg)
 	    M_NEG(dec_i, dec_f);
 	
-	lfp->l_ui = dec_i;
-	lfp->l_uf = dec_f;
+	setlfpuint(*lfp, dec_i);
+	setlfpfrac(*lfp, dec_f);
 	return true;
 }


=====================================
libntp/hextolfp.c
=====================================
--- a/libntp/hextolfp.c
+++ b/libntp/hextolfp.c
@@ -62,7 +62,7 @@ hextolfp(
 	if (*cp != '\0' && !isspace((unsigned char)*cp))
 	    return false;
 
-	lfp->l_ui = dec_i;
-	lfp->l_uf = dec_f;
+	setlfpuint(*lfp, dec_i);
+	setlfpfrac(*lfp, dec_f);
 	return true;
 }


=====================================
libntp/prettydate.c
=====================================
--- a/libntp/prettydate.c
+++ b/libntp/prettydate.c
@@ -132,8 +132,8 @@ common_prettydate(
 	LIB_GETBUF(bp);
 
 	/* get & fix milliseconds */
-	ntps = ts->l_ui;
-	msec = ts->l_uf / 4294967;	/* fract / (2 ** 32 / 1000) */
+	ntps = lfpuint(*ts);
+	msec = lfpfrac(*ts) / 4294967;	/* fract / (2 ** 32 / 1000) */
 	if (msec >= 1000u) {
 		msec -= 1000u;
 		ntps++;
@@ -148,13 +148,13 @@ common_prettydate(
 		struct calendar jd;
 		ntpcal_time_to_date(&jd, sec);
 		snprintf(bp, LIB_BUFLENGTH, pfmt,
-			 (u_long)ts->l_ui, (u_long)ts->l_uf,
+			 (u_long)lfpuint(*ts), (u_long)lfpfrac(*ts),
 			 jd.year, jd.month, jd.monthday,
 			 jd.hour, jd.minute, jd.second, msec);
 		strncat(bp, "Z",  LIB_BUFLENGTH);
 	} else {
 		snprintf(bp, LIB_BUFLENGTH, pfmt,
-			 (u_long)ts->l_ui, (u_long)ts->l_uf,
+			 (u_long)lfpuint(*ts), (u_long)lfpfrac(*ts),
 			 1900 + tm->tm_year, tm->tm_mon+1, tm->tm_mday,
 			 tm->tm_hour, tm->tm_min, tm->tm_sec, msec);
 		if (!local)


=====================================
libntp/refidsmear.c
=====================================
--- a/libntp/refidsmear.c
+++ b/libntp/refidsmear.c
@@ -23,10 +23,11 @@ convertRefIDToLFP(uint32_t r)
 
 	// printf("%03d %08x: ", (r >> 24) & 0xFF, (r & 0x00FFFFFF) );
 
-	temp.l_uf = (r << 10);	/* 22 fractional bits */
+	setlfpfrac(temp, r << 10);	/* 22 fractional bits */
 
-	temp.l_ui = (r >> 22) & 0x3;
-	temp.l_ui |= ~(temp.l_ui & 2) + 1;
+	r = (r >> 22) & 0x3;
+	r |= ~(r & 2) + 1;
+	setlfpuint(temp, r);
 
 	return temp;
 }
@@ -43,11 +44,10 @@ convertLFPToRefID(l_fp num)
 	 * TODO: check for overflows; should we clamp/saturate or just
 	 * complain?
 	 */
-	L_ADDUF(&num, 0x200);
-	num.l_ui &= 3;
+	setlfpfrac(num, lfpfrac(num) + 0x200);
 
 	/* combine integral and fractional part to 24 bits */
-	temp  = (num.l_ui << 22) | (num.l_uf >> 10);
+	temp  = ((lfpuint(num) & 3) << 22) | (lfpfrac(num) >> 10);
 
 	/* put in the leading 254.0.0.0 */
 	temp |= UINT32_C(0xFE000000);


=====================================
libntp/systime.c
=====================================
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -211,8 +211,8 @@ normalize_time(
 			LFPTOD(&lfpdelta, ddelta);
 			msyslog(LOG_ERR,
 				"prev get_systime 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);
+				lfpuint(lfp_prev), lfpfrac(lfp_prev),
+				ddelta, lfpuint(result), lfpfrac(result));
 		}
 	}
 	lfp_prev = result;


=====================================
libparse/clk_trimtsip.c
=====================================
--- a/libparse/clk_trimtsip.c
+++ b/libparse/clk_trimtsip.c
@@ -246,7 +246,7 @@ cvt_trimtsip(
 				    gpstolfp((unsigned short)week, (unsigned short)0,
 					     secs.l_ui, &gpstime);
 
-				    gpstime.l_uf = secs.l_uf;
+				    setlfpfrac(gpstime, lfpfrac(secs));
 
 				    clock_time->utctime = gpstime.l_ui - JAN_1970;
 


=====================================
libparse/gpstolfp.c
=====================================
--- a/libparse/gpstolfp.c
+++ b/libparse/gpstolfp.c
@@ -23,8 +23,8 @@ gpstolfp(
       weeks += GPSWEEKS;
     }
 
-  lfp->l_ui = (uint32_t)(weeks * SECSPERWEEK + days * SECSPERDAY + seconds + GPSORIGIN); /* convert to NTP time */
-  lfp->l_uf = 0;
+  setlfpuint(*lfp, (uint32_t)(weeks * SECSPERWEEK + days * SECSPERDAY + seconds + GPSORIGIN)); /* convert to NTP time */
+  setlfpfrac(*lfp, 0);
 }
 
 /*


=====================================
libparse/ieee754io.c
=====================================
--- a/libparse/ieee754io.c
+++ b/libparse/ieee754io.c
@@ -451,10 +451,10 @@ put_ieee754(
        * find number of significant integer bits
        */
       mask = 0x80000000;
-      if (outlfp.l_ui)
+      if (lfpuint(outlfp))
 	{
 	  msb = 63;
-	  while (mask && ((outlfp.l_ui & mask) == 0))
+	  while (mask && ((lfpuint(outlfp) & mask) == 0))
 	    {
 	      mask >>= 1;
 	      msb--;
@@ -463,7 +463,7 @@ put_ieee754(
       else
 	{
 	  msb = 31;
-	  while (mask && ((outlfp.l_uf & mask) == 0))
+	  while (mask && ((lfpfrac(outlfp) & mask) == 0))
 	    {
 	      mask >>= 1;
 	      msb--;
@@ -476,28 +476,28 @@ put_ieee754(
 	  mantissa_high = 0;
 	  if (msb >= 32)
 	    {
-	      mantissa_low  = (outlfp.l_ui & ((1 << (msb - 32)) - 1)) << (mbits - (msb - 32));
-	      mantissa_low |=  outlfp.l_uf >> (mbits - (msb - 32));
+	      mantissa_low  = (lfpuint(outlfp) & ((1 << (msb - 32)) - 1)) << (mbits - (msb - 32));
+	      mantissa_low |=  lfpfrac(outlfp) >> (mbits - (msb - 32));
 	    }
 	  else
 	    {
-	      mantissa_low  = (outlfp.l_uf << (mbits - msb)) & ((1 << mbits) - 1);
+	      mantissa_low  = (lfpfrac(outlfp) << (mbits - msb)) & ((1 << mbits) - 1);
 	    }
 	  break;
 	  
 	case IEEE_DOUBLE:
 	  if (msb >= 32)
 	    {
-	      mantissa_high  = (outlfp.l_ui << (mbits - msb)) & ((1 << (mbits - 32)) - 1);
-	      mantissa_high |=  outlfp.l_uf >> (32 - (mbits - msb));
-	      mantissa_low   = (outlfp.l_ui & ((1 << (msb - mbits)) - 1)) << (32 - (msb - mbits));
+	      mantissa_high  = (lfpuint(outlfp) << (mbits - msb)) & ((1 << (mbits - 32)) - 1);
+	      mantissa_high |=  lfpfrac(outlfp) >> (32 - (mbits - msb));
+	      mantissa_low   = (lfpuint(outlfp) & ((1 << (msb - mbits)) - 1)) << (32 - (msb - mbits));
 	      /* coverity[negative_shift] */
-	      mantissa_low  |=  outlfp.l_uf >> (msb - mbits);
+	      mantissa_low  |=  lfpfrac(outlfp) >> (msb - mbits);
 	    }
 	  else
 	    {
-	      mantissa_high  = outlfp.l_uf << (mbits - 32 - msb);
-	      mantissa_low   = outlfp.l_uf << (mbits - 32);
+	      mantissa_high  = lfpfrac(outlfp) << (mbits - 32 - msb);
+	      mantissa_low   = lfpfrac(outlfp) << (mbits - 32);
 	    }
 	}
 
@@ -537,7 +537,7 @@ int main(
   
   printf("double: %s %s\n", fmt_blong(*(unsigned long *)&f, 32), fmt_blong(*(unsigned long *)((char *)(&f)+4), 32));
   printf("fetch from %f = %d\n", f, fetch_ieee754((void *)&f_p, IEEE_DOUBLE, &fp, native_off));
-  printf("fp [%s %s] = %s\n", fmt_blong(fp.l_ui, 32), fmt_blong(fp.l_uf, 32), mfptoa(fp.l_ui, fp.l_uf, 15));
+  printf("fp [%s %s] = %s\n", fmt_blong(lfpuint(fp), 32), fmt_blong(lfpfrac(fp), 32), mfptoa(lfpuint(fp), lfpfrac(fp), 15));
   f_p = &f;
   put_ieee754((void *)&f_p, IEEE_DOUBLE, &fp, native_off);
   


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -1278,7 +1278,7 @@ ctl_putts(
 	*cp++ = '=';
 	NTP_INSIST((size_t)(cp - buffer) < sizeof(buffer));
 	snprintf(cp, sizeof(buffer) - (cp - buffer), "0x%08x.%08x",
-		 (u_int)ts->l_ui, (u_int)ts->l_uf);
+		 (u_int)lfpuint(*ts), (u_int)lfpfrac(*ts));
 	cp += strlen(cp);
 	ctl_putdata(buffer, (unsigned)( cp - buffer ), false);
 }
@@ -3017,10 +3017,10 @@ static void generate_nonce(
 	uint32_t derived;
 
 	derived = derive_nonce(&rbufp->recv_srcadr,
-			       rbufp->recv_time.l_ui,
-			       rbufp->recv_time.l_uf);
+			       lfpuint(rbufp->recv_time),
+			       lfpfrac(rbufp->recv_time));
 	snprintf(nonce, nonce_octets, "%08x%08x%08x",
-		 rbufp->recv_time.l_ui, rbufp->recv_time.l_uf, derived);
+		 lfpuint(rbufp->recv_time), lfpfrac(rbufp->recv_time), derived);
 }
 
 
@@ -3045,13 +3045,13 @@ static int validate_nonce(
 	if (3 != sscanf(pnonce, "%08x%08x%08x", &ts_i, &ts_f, &supposed))
 		return false;
 
-	ts.l_ui = (uint32_t)ts_i;
-	ts.l_uf = (uint32_t)ts_f;
-	derived = derive_nonce(&rbufp->recv_srcadr, ts.l_ui, ts.l_uf);
+	setlfpuint(ts, (uint32_t)ts_i);
+	setlfpfrac(ts, (uint32_t)ts_f);
+	derived = derive_nonce(&rbufp->recv_srcadr, lfpuint(ts), lfpfrac(ts));
 	get_systime(&now_delta);
 	L_SUB(&now_delta, &ts);
 
-	return (supposed == derived && now_delta.l_ui < NONCE_TIMEOUT);
+	return (supposed == derived && lfpuint(now_delta) < NONCE_TIMEOUT);
 }
 
 
@@ -3413,15 +3413,15 @@ static void read_mru_list(
 			   (size_t)si < COUNTOF(last)) {
 			if (2 != sscanf(val, "0x%08x.%08x", &ui, &uf))
 				goto blooper;
-			last[si].l_ui = ui;
-			last[si].l_uf = uf;
+			setlfpuint(last[si], ui);
+			setlfpfrac(last[si], uf);
 			if (!SOCK_UNSPEC(&addr[si]) && si == priors)
 				priors++;
 		} else if (1 == sscanf(v->text, addr_fmt, &si) &&
 			   (size_t)si < COUNTOF(addr)) {
 			if (!decodenetnum(val, &addr[si]))
 				goto blooper;
-			if (last[si].l_ui && last[si].l_uf && si == priors)
+			if (lfpuint(last[si]) && lfpfrac(last[si]) && si == priors)
 				priors++;
 		} else {
 			DPRINTF(1, ("read_mru_list: invalid key item: '%s' (ignored)\n",
@@ -3522,7 +3522,7 @@ static void read_mru_list(
 			continue;
 		if (resany && !(resany & mon->flags))
 			continue;
-		if (maxlstint > 0 && now.l_ui - mon->last.l_ui >
+		if (maxlstint > 0 && lfpuint(now) - lfpuint(mon->last) >
 		    maxlstint)
 			continue;
 		if (lcladr != NULL && mon->lcladr != lcladr)


=====================================
ntpd/ntp_packetstamp.c
=====================================
--- a/ntpd/ntp_packetstamp.c
+++ b/ntpd/ntp_packetstamp.c
@@ -147,15 +147,15 @@ fetch_packetstamp(
 				/*
 				 * bintime documentation is at http://phk.freebsd.dk/pubs/timecounter.pdf
 				 */
-				nts.l_i = btp->sec + JAN_1970;
-				nts.l_uf = (uint32_t)(btp->frac >> 32);
+				setlfpuint(nts, btp->sec + JAN_1970);
+				setlfpfrac(nts, (uint32_t)(btp->frac >> 32));
 				if (sys_tick > measured_tick &&
 				    sys_tick > 1e-9) {
-					ticks = (unsigned long)(nts.l_uf / (unsigned long)(sys_tick * FRAC));
-					nts.l_uf = (unsigned long)(ticks * (unsigned long)(sys_tick * FRAC));
+				    ticks = (unsigned long)(lfpfrac(nts) / (unsigned long)(sys_tick * FRAC));
+				    setlfpfrac(nts, (unsigned long)(ticks * (unsigned long)(sys_tick * FRAC)));
 				}
                                 DPRINTF(4, ("fetch_timestamp: system bintime network time stamp: %ld.%09lu\n",
-                                            (long)btp->sec, (unsigned long)((nts.l_uf / FRAC) * 1e9)));
+                                            (long)btp->sec, (unsigned long)((lfpfrac(nts) / FRAC) * 1e9)));
 				break;
 #endif  /* USE_SCM_BINTIME */
 #ifdef USE_SCM_TIMESTAMPNS


=====================================
ntpd/ntp_refclock.c
=====================================
--- a/ntpd/ntp_refclock.c
+++ b/ntpd/ntp_refclock.c
@@ -405,7 +405,7 @@ refclock_process_f(
 		pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui))
 		return false;
 
-	offset.l_uf = 0;
+	setlfpfrac(offset, 0);
 	DTOLFP(pp->nsec / 1e9, &ltemp);
 	L_ADD(&offset, &ltemp);
 	refclock_process_offset(pp, offset, pp->lastrec, fudge);
@@ -1084,9 +1084,9 @@ refclock_catcher(
 	/*
 	 * Convert to signed fraction offset and stuff in median filter.
 	 */
-	pp->lastrec.l_ui = (uint32_t)ap->ts.tv_sec + JAN_1970;
+	setlfpuint(pp->lastrec, (uint32_t)ap->ts.tv_sec + JAN_1970);
 	dtemp = ap->ts.tv_nsec / 1e9;
-	pp->lastrec.l_uf = (uint32_t)(dtemp * FRAC);
+	setlfpfrac(pp->lastrec, (uint32_t)(dtemp * FRAC));
 	if (dtemp > .5)
 		dtemp -= 1.;
 	SAMPLE(-dtemp + pp->fudgetime1);


=====================================
ntpd/refclock_generic.c
=====================================
--- a/ntpd/refclock_generic.c
+++ b/ntpd/refclock_generic.c
@@ -1861,7 +1861,7 @@ local_input(
 								dtemp -= 1;
 								parse->parseio.parse_dtime.parse_ptime.fp.l_ui++;
 							}
-							parse->parseio.parse_dtime.parse_ptime.fp.l_uf = (uint32_t)(dtemp * FRAC);
+							setlfpfrac(parse->parseio.parse_dtime.parse_ptime.fp, (uint32_t)(dtemp * FRAC));
 
 							parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
 #ifdef DEBUG
@@ -1974,12 +1974,12 @@ local_receive(
 		   parse->peer->refclkunit,
 		   (unsigned int)parsetime.parse_status,
 		   (unsigned int)parsetime.parse_state,
-		   (unsigned long)parsetime.parse_time.fp.l_ui,
-		   (unsigned long)parsetime.parse_time.fp.l_uf,
-		   (unsigned long)parsetime.parse_stime.fp.l_ui,
-		   (unsigned long)parsetime.parse_stime.fp.l_uf,
-		   (unsigned long)parsetime.parse_ptime.fp.l_ui,
-		   (unsigned long)parsetime.parse_ptime.fp.l_uf);
+		   (unsigned long)lfpuint(parsetime.parse_time.fp),
+		   (unsigned long)lfpfrac(parsetime.parse_time.fp),
+		   (unsigned long)lfpuint(parsetime.parse_stime.fp),
+		   (unsigned long)lfpfrac(parsetime.parse_stime.fp),
+		   (unsigned long)lfpuint(parsetime.parse_ptime.fp),
+		   (unsigned long)lfpfrac(parsetime.parse_ptime.fp));
 	  }
 #endif
 
@@ -3052,7 +3052,7 @@ parse_control(
 		start = tt = add_var(&out->kv_list, 128, RO|DEF);
 		tt = ap(start, 128, tt, "refclock_time=\"");
 
-		if (parse->timedata.parse_time.fp.l_ui == 0)
+		if (lfpuint(parse->timedata.parse_time.fp) == 0)
 		{
 			ap(start, 128, tt, "<UNDEFINED>\"");
 		}
@@ -3509,8 +3509,8 @@ parse_process(
 #endif
 		if (PARSE_TIMECODE(parsetime->parse_state))
 		{
-			if (M_ISGEQ(off.l_i, off.l_uf, -1, 0x80000000) &&
-			    M_ISGEQ(0, 0x7fffffff, off.l_i, off.l_uf))
+			if (M_ISGEQ(off.l_i, lfpfrac(off), -1, 0x80000000) &&
+			    M_ISGEQ(0, 0x7fffffff, off.l_i, lfpfrac(off)))
 			{
 				fudge = ppsphaseadjust; /* pick PPS fudge factor */
 
@@ -3521,9 +3521,9 @@ parse_process(
 				if (parse->parse_type->cl_flags & PARSE_F_PPSONSECOND)
 				{
 					reftime = off = offset;
-					if (reftime.l_uf & 0x80000000)
+					if (lfpfrac(reftime) & 0x80000000)
 						reftime.l_ui++;
-					reftime.l_uf = 0;
+					setlfpfrac(reftime, 0);
 
 
 					/*
@@ -3880,9 +3880,9 @@ gps16x_message(
 
 					get_mbg_xyz(&bufp, xyz);
 					snprintf(buffer, sizeof(buffer), "gps_position(XYZ)=\"%s m, %s m, %s m\"",
-						mfptoa(xyz[XP].l_ui, xyz[XP].l_uf, 1),
-						mfptoa(xyz[YP].l_ui, xyz[YP].l_uf, 1),
-						mfptoa(xyz[ZP].l_ui, xyz[ZP].l_uf, 1));
+						 mfptoa(lfpuint(xyz[XP]), lfpfrac(xyz[XP]), 1),
+						 mfptoa(lfpuint(xyz[YP]), lfpfrac(xyz[YP]), 1),
+						 mfptoa(lfpuint(xyz[ZP]), lfpfrac(xyz[ZP]), 1));
 
 					set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
 				}
@@ -3896,9 +3896,9 @@ gps16x_message(
 					get_mbg_lla(&bufp, lla);
 
 					snprintf(buffer, sizeof(buffer), "gps_position(LLA)=\"%s deg, %s deg, %s m\"",
-						mfptoa(lla[LAT].l_ui, lla[LAT].l_uf, 4),
-						mfptoa(lla[LON].l_ui, lla[LON].l_uf, 4),
-						mfptoa(lla[ALT].l_ui, lla[ALT].l_uf, 1));
+						 mfptoa(lfpuint(lla[LAT]), lfpfrac(lla[LAT]), 4),
+						 mfptoa(lfpuint(lla[LON]), lfpfrac(lla[LON]), 4),
+						 mfptoa(lfpuint(lla[ALT]), lfpfrac(lla[ALT]), 1));
 
 					set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
 				}


=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -1649,7 +1649,7 @@ process_pps(
 	 */
 	up->pps_stamp = up->pps_recvt;
 	L_ADDUF(&up->pps_stamp, 0x80000000u);
-	up->pps_stamp.l_uf = 0;
+	setlfpfrac(up->pps_stamp, 0);
 
 	if (NULL != up->pps_peer)
 		save_ltc(up->pps_peer->procptr,


=====================================
ntpd/refclock_jupiter.c
=====================================
--- a/ntpd/refclock_jupiter.c
+++ b/ntpd/refclock_jupiter.c
@@ -643,9 +643,9 @@ jupiter_pps(struct instance *instance)
 		return true;
 	instance->ts = ts;
 
-	tstmp.l_ui = (uint32_t)ts.tv_sec + JAN_1970;
+	setlfpuint(tstmp, (uint32_t)ts.tv_sec + JAN_1970);
 	dtemp = ts.tv_nsec * FRAC / 1e9;
-	tstmp.l_uf = (uint32_t)dtemp;
+	setlfpfrac(tstmp, (uint32_t)dtemp);
 	instance->peer->procptr->lastrec = tstmp;
 	return false;
 }
@@ -840,8 +840,8 @@ jupiter_receive(struct recvbuf *rbufp)
 				break;
 
 			/* Add the new sample to a median filter */
-			tstamp.l_ui = JAN_1970 + (uint32_t)last_timecode;
-			tstamp.l_uf = 0;
+			setlfpuint(tstamp, JAN_1970 + (uint32_t)last_timecode);
+			setlfpfrac(tstamp, 0);
 
 			refclock_process_offset(pp, tstamp, pp->lastrec, pp->fudgetime1);
 


=====================================
ntpd/refclock_magnavox.c
=====================================
--- a/ntpd/refclock_magnavox.c
+++ b/ntpd/refclock_magnavox.c
@@ -1520,10 +1520,10 @@ mx4200_pps(
 	 * Return the timestamp in pp->lastrec
 	 */
 
-	pp->lastrec.l_ui = up->pps_i.assert_timestamp.tv_sec +
-			   (uint32_t) JAN_1970;
-	pp->lastrec.l_uf = ((double)(up->pps_i.assert_timestamp.tv_nsec) *
-			   4.2949672960) + 0.5;
+	setlfpuint(pp->lastrec, up->pps_i.assert_timestamp.tv_sec +
+		   (uint32_t) JAN_1970);
+	setlfpfrac(pp->lastrec, ((double)(up->pps_i.assert_timestamp.tv_nsec) *
+				 4.2949672960) + 0.5);
 
 	return false;
 }


=====================================
ntpd/refclock_nmea.c
=====================================
--- a/ntpd/refclock_nmea.c
+++ b/ntpd/refclock_nmea.c
@@ -862,7 +862,7 @@ nmea_receive(
 	/* Eventually output delay measurement now. */
 	if (peer->ttl & NMEA_DELAYMEAS_MASK) {
 		mprintf_clock_stats(peer, "delay %0.6f %.*s",
-			 ldexp(rd_timestamp.l_uf, -32),
+			 ldexp(lfpfrac(rd_timestamp), -32),
 			 (int)(strchr(rd_lastcode, ',') - rd_lastcode),
 			 rd_lastcode);
 	}
@@ -1844,7 +1844,7 @@ eval_gps_time(
 	 * fractional day of the receive time, we shift the base day for
 	 * the unfold by 1. */
 	if (   gps_sec  < rcv_sec
-	   || (gps_sec == rcv_sec && retv.l_uf < xrecv->l_uf))
+	       || (gps_sec == rcv_sec && lfpfrac(retv) < lfpfrac(*xrecv)))
 		rcv_day += 1;
 
 	/* - don't warp ahead of GPS invention! */


=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -1679,11 +1679,10 @@ oncore_get_timestamp(
 	}
 
 	/* convert timespec -> ntp l_fp */
-
 	dmy = tsp->tv_nsec;
 	dmy /= 1e9;
-	ts.l_uf = dmy * 4294967296.0;
-	ts.l_ui = tsp->tv_sec;
+	setlfpfrac(ts, dmy * 4294967296.0);
+	setlfpuint(ts, tsp->tv_sec);
 
 #if 0
      alternate code for previous 4 lines is


=====================================
ntpd/refclock_truetime.c
=====================================
--- a/ntpd/refclock_truetime.c
+++ b/ntpd/refclock_truetime.c
@@ -497,12 +497,12 @@ true_receive(
 				refclock_report(peer, CEVNT_BADTIME);
 				return;
 			}
-			off.l_uf = 0;
+			setlfpfrac(off, 0);
 #endif
 
 			pp->usec = true_sample720();
 #ifdef CLOCK_PPS
-			TVUTOTSF(pp->usec, off.l_uf);
+			TVUTOTSF(pp->usec, lfpfrac(off));
 #endif
 
 			/*


=====================================
ntpfrob/jitter.c
=====================================
--- a/ntpfrob/jitter.c
+++ b/ntpfrob/jitter.c
@@ -44,7 +44,7 @@ get_clocktime(
 	 * Convert Unix clock from seconds and nanoseconds to seconds.
 	 */
 	clock_gettime(CLOCK_REALTIME, &ts);
-	now->l_i = ts.tv_sec + JAN_1970;
+	setlfpsint(*now, ts.tv_sec + JAN_1970);
 	dtemp = ts.tv_nsec / 1e9;
 
 	/*
@@ -59,7 +59,7 @@ get_clocktime(
 		now->l_i--;
 	}
 	dtemp *= FRAC;
-	now->l_uf = (uint32_t)dtemp;
+	setlfpfrac(*now, (uint32_t)dtemp);
 }
 
 static int doublecmp(const void *a, const void *b)


=====================================
ntptime/ntptime.c
=====================================
--- a/ntptime/ntptime.c
+++ b/ntptime/ntptime.c
@@ -32,18 +32,16 @@
 /*
  * Convert usec to a time stamp fraction.
  */
-# define TVUTOTSF(tvu, tsf)						\
-	((tsf) = (uint32_t)						\
-		 ((((uint64_t)(tvu) << 32) + MICROSECONDS / 2) /		\
-		  MICROSECONDS))
+# define TVUTOTSF(tvu)	\
+	(uint32_t)((((uint64_t)(tvu) << 32) + MICROSECONDS / 2) / MICROSECONDS)
 
 /*
  * Convert a struct timeval to a time stamp.
  */
 #define TVTOTS(tv, ts) \
 	do { \
-		(ts)->l_ui = (u_long)(tv)->tv_sec; \
-		TVUTOTSF((tv)->tv_usec, (ts)->l_uf); \
+		setlfpuint(*ts, (u_long)(tv)->tv_sec);   \
+		setlfpfrac(*ts, TVUTOTSF((tv)->tv_usec)); \
 	} while (false)
 
 #define NS_PER_MS_FLOAT	1000.0
@@ -341,14 +339,14 @@ main(
 		tv.tv_sec = ntv.time.tv_sec;
 		tv.tv_usec = ntv.time.tv_frac_sec;
 		TVTOTS(&tv, &ts);
-		ts.l_ui += JAN_1970;
-		ts.l_uf += ts_roundbit;
-		ts.l_uf &= ts_mask;
+		setlfpuint(ts, lfpuint(ts) + JAN_1970);
+		setlfpfrac(ts, lfpfrac(ts) + ts_roundbit);
+		setlfpfrac(ts, lfpfrac(ts) & ts_mask);
 		printf(json ? jfmt2 : ofmt2,  json ? rfc3339date(&ts) : prettydate(&ts), fdigits, (int)time_frac);
 		printf(json ? jfmt3 : ofmt3,  (u_long)ntv.maxerror, (u_long)ntv.esterror);
 		if (rawtime)
 			printf(json ? jfmt4 : ofmt4,
-			       (u_int)ts.l_ui, (u_int)ts.l_uf,
+			       (u_int)lfpuint(ts), (u_int)lfpfrac(ts),
 			       (int)ntv.time.tv_sec, fdigits,
 			       (int)time_frac,
 


=====================================
tests/libntp/lfpfunc.c
=====================================
--- a/tests/libntp/lfpfunc.c
+++ b/tests/libntp/lfpfunc.c
@@ -22,8 +22,8 @@ TEST_TEAR_DOWN(lfpfunc) {}
    aren't initiated with memset (due to padding bytes).
 */
 #define TEST_ASSERT_EQUAL_l_fp(a, b) {					\
-	TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i");		\
-	TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf");	\
+	TEST_ASSERT_EQUAL_MESSAGE(lfpsint(a), lfpsint(b), "Integer part");		\
+	TEST_ASSERT_EQUAL_UINT_MESSAGE(lfpfrac(a), lfpfrac(b), "Fractional part");	\
 }
 
 typedef struct  {
@@ -57,11 +57,11 @@ static int l_fp_scmp(const l_fp first, const l_fp second)
 	const l_fp op1 = first;
 	const l_fp op2 = second;
 
-	a[0] = op1.l_uf; a[1] = op1.l_ui; a[2] = 0;
-	b[0] = op2.l_uf; b[1] = op2.l_ui; b[2] = 0;
+	a[0] = lfpfrac(op1); a[1] = lfpuint(op1); a[2] = 0;
+	b[0] = lfpfrac(op2); b[1] = lfpuint(op2); b[2] = 0;
 
-	a[2] -= (op1.l_i < 0);
-	b[2] -= (op2.l_i < 0);
+	a[2] -= (lfpsint(op1) < 0);
+	b[2] -= (lfpsint(op2) < 0);
 
 	return cmp_work(a,b);
 }
@@ -72,8 +72,8 @@ static int l_fp_ucmp(const l_fp first, l_fp second)
 	const l_fp op1 = first; 
 	const l_fp op2 = second;
 
-	a[0] = op1.l_uf; a[1] = op1.l_ui; a[2] = 0;
-	b[0] = op2.l_uf; b[1] = op2.l_ui; b[2] = 0;
+	a[0] = lfpfrac(op1); a[1] = lfpuint(op1); a[2] = 0;
+	b[0] = lfpfrac(op2); b[1] = lfpuint(op2); b[2] = 0;
 
 	return cmp_work(a,b);
 }
@@ -86,8 +86,8 @@ static int l_fp_ucmp(const l_fp first, l_fp second)
 static l_fp l_fp_init(int32_t i, uint32_t f)
 {
 	l_fp temp;
-	temp.l_i  = i;
-	temp.l_uf = f;
+	setlfpsint(temp, i);
+	setlfpfrac(temp, f);
 
 	return temp;
 }
@@ -126,9 +126,9 @@ static l_fp l_fp_abs(const l_fp first)
 
 static int l_fp_signum(const l_fp first)
 {
-	if (first.l_ui & 0x80000000u)
+	if (lfpuint(first) & 0x80000000u)
 		return -1;
-	return (first.l_ui || first.l_uf);
+	return (lfpuint(first) || lfpfrac(first));
 }
 
 static double l_fp_convert_to_double(const l_fp first)
@@ -401,9 +401,9 @@ TEST(lfpfunc, SignedRelOps) {
 
 		switch (cmp) {
 		case -1:
-			//printf("op1:%d %d, op2:%d %d\n",op1.l_uf,op1.l_ui,op2.l_uf,op2.l_ui);
+			//printf("op1:%d %d, op2:%d %d\n",lfpfrac(op1),lfpuint(op1),lfpfrac(op2),lfpuint(op2));
 			l_fp_swap(&op1, &op2);
-			//printf("op1:%d %d, op2:%d %d\n",op1.l_uf,op1.l_ui,op2.l_uf,op2.l_ui);
+			//printf("op1:%d %d, op2:%d %d\n",lfpfrac(op1),lfpuint(op1),lfpfrac(op2),lfpuint(op2));
 		case 1:
 			TEST_ASSERT_TRUE (l_isgt(op1, op2));
 			TEST_ASSERT_FALSE(l_isgt(op2, op1));
@@ -443,9 +443,9 @@ TEST(lfpfunc, UnsignedRelOps) {
 
 		switch (cmp) {
 		case -1:
-			//printf("op1:%d %d, op2:%d %d\n",op1.l_uf,op1.l_ui,op2.l_uf,op2.l_ui);
+			//printf("op1:%d %d, op2:%d %d\n",lfpfrac(op1),lfpuint(op1),lfpfrac(op2),lfpuint(op2));
 			l_fp_swap(&op1, &op2);
-			//printf("op1:%d %d, op2:%d %d\n",op1.l_uf,op1.l_ui,op2.l_uf,op2.l_ui);
+			//printf("op1:%d %d, op2:%d %d\n",lfpfrac(op1),lfpuint(op1),lfpfrac(op2),lfpuint(op2));
 		case 1:
 			TEST_ASSERT_TRUE (l_isgtu(op1, op2));
 			TEST_ASSERT_FALSE(l_isgtu(op2, op1));


=====================================
tests/libntp/lfptest.h
=====================================
--- a/tests/libntp/lfptest.h
+++ b/tests/libntp/lfptest.h
@@ -7,7 +7,7 @@ static bool IsEqual(const l_fp *expected, const l_fp *actual) {
 	if (L_ISEQU(expected, actual)) {
 		return true;
 	} else {
-		printf("Expected: %s (%d.%d) but was: %s (%d.%d)\n", lfptoa(expected, FRACTION_PREC), expected->l_ui, expected->l_uf, lfptoa(actual, FRACTION_PREC), actual->l_ui, actual->l_uf);
+		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));
 		return false;
 	}
 }


=====================================
tests/libntp/lfptostr.c
=====================================
--- a/tests/libntp/lfptostr.c
+++ b/tests/libntp/lfptostr.c
@@ -32,8 +32,8 @@ static const int HALF_PROMILLE_DOWN = 2147483; // slightly less than 0.0005
 TEST(lfptostr, PositiveInteger) {
 	l_fp test = {{200}, 0}; // exact 200.0000000000
 
-	TEST_ASSERT_EQUAL_STRING("200.0000000000", mfptoa(test.l_ui, test.l_uf, LFP_MAX_PRECISION));
-	TEST_ASSERT_EQUAL_STRING("200000.0000000", mfptoms(test.l_ui, test.l_uf, LFP_MAX_PRECISION_MS));
+	TEST_ASSERT_EQUAL_STRING("200.0000000000", mfptoa(lfpuint(test), lfpfrac(test), LFP_MAX_PRECISION));
+	TEST_ASSERT_EQUAL_STRING("200000.0000000", mfptoms(lfpuint(test), lfpfrac(test), LFP_MAX_PRECISION_MS));
 }
 
 TEST(lfptostr, NegativeInteger) {


=====================================
tests/libntp/strtolfp.c
=====================================
--- a/tests/libntp/strtolfp.c
+++ b/tests/libntp/strtolfp.c
@@ -34,8 +34,8 @@ TEST(strtolfp, NegativeInteger) {
 	const char *str_ms = "-300000";
 
 	l_fp expected;
-	expected.l_i = -300;
-	expected.l_uf = 0;
+	setlfpsint(expected, -300);
+	setlfpfrac(expected, 0);
 
 	l_fp actual, actual_ms;
 
@@ -65,8 +65,8 @@ TEST(strtolfp, NegativeFraction) {
 	const char *str_ms = "-300750";
 
 	l_fp expected;
-	expected.l_i = -301;
-	expected.l_uf = QUARTER;
+	setlfpsint(expected, -301);
+	setlfpfrac(expected, QUARTER);
 
 	l_fp actual, actual_ms;
 
@@ -96,8 +96,8 @@ TEST(strtolfp, NegativeMsFraction) {
 	const char *str_ms = "-199999.75";
 
 	l_fp expected;
-	expected.l_i = -200;
-	expected.l_uf = QUARTER_PROMILLE_APPRX;
+	setlfpsint(expected, -200);
+	setlfpfrac(expected, QUARTER_PROMILLE_APPRX);
 
 	l_fp actual, actual_ms;
 


=====================================
tests/libntp/timespecops.c
=====================================
--- a/tests/libntp/timespecops.c
+++ b/tests/libntp/timespecops.c
@@ -18,8 +18,8 @@
 
 
 #define TEST_ASSERT_EQUAL_l_fp(a, b) {					\
-    TEST_ASSERT_EQUAL_MESSAGE(a.l_i, b.l_i, "Field l_i");		\
-    TEST_ASSERT_EQUAL_UINT_MESSAGE(a.l_uf, b.l_uf, "Field l_uf");	\
+    TEST_ASSERT_EQUAL_MESSAGE(lfpsint(a), lfpsint(b), "Integral part"); \
+    TEST_ASSERT_EQUAL_UINT_MESSAGE(lfpfrac(a), lfpfrac(b), "Fractional part"); \
 }
 
 
@@ -61,8 +61,8 @@ static l_fp l_fp_init(int32_t i, uint32_t f)
 {
 	l_fp temp;
 
-	temp.l_i  = i;
-	temp.l_uf = f;
+	setlfpsint(temp, i);
+	setlfpfrac(temp, f);
 
 	return temp;
 }



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/23de9eca1230d87e42904b546f842fa04ffd9f40...d2b30c66beaacbfe4a2631a5181777cc288d4006
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161225/1a2f8b8e/attachment.html>


More information about the vc mailing list