[Git][NTPsec/ntpsec][master] 3 commits: lfpint/lfpuint calls are no longer used as rvalues.

Eric S. Raymond gitlab at mg.gitlab.com
Tue Dec 27 02:03:32 UTC 2016


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


Commits:
cc92151e by Eric S. Raymond at 2016-12-26T20:43:25-05:00
lfpint/lfpuint calls are no longer used as rvalues.

This prepares the way for the l_fp representation to be changed to
a real scalar.

- - - - -
0fd21287 by Eric S. Raymond at 2016-12-26T20:55:36-05:00
Catch one more rvalue use of lfp getter.

- - - - -
f58f03f9 by Eric S. Raymond at 2016-12-26T21:03:08-05:00
Dead-code removal.

- - - - -


1 changed file:

- include/ntp_fp.h


Changes:

=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -146,12 +146,6 @@ typedef uint32_t u_fp;
 		(v_i) = ~(v_i) + ((v_f) == 0); \
 	} while (false)
 
-#define	M_NEGM(r_i, r_f, a_i, a_f)	/* r = -a */ \
-	do { \
-		(r_f) = ~(a_f) + 1u; \
-		(r_i) = ~(a_i) + ((r_f) == 0); \
-	} while (false)
-
 #define M_ADD(r_i, r_f, a_i, a_f)	/* r += a */ \
 	do { \
 		uint32_t add_t = (r_f); \
@@ -165,28 +159,18 @@ typedef uint32_t u_fp;
 		(v_f) = ((uint32_t)(v_f) << 1); \
 	} while (false)
 
-#define	M_ADDF(r_i, r_f, f)		/* r += f, f is a int32_t fraction */ \
-	do { \
-		int32_t add_f = (int32_t)(f); \
-		if (add_f >= 0) \
-			M_ADD((r_i), (r_f), 0, (uint32)( add_f)); \
-		else \
-			M_SUB((r_i), (r_f), 0, (uint32)(-add_f)); \
-	} while(0)
-
 #define	M_ISNEG(v_i)			/* v < 0 */ \
 	(((v_i) & 0x80000000) != 0)
 
 /*
  * Operations on the long fp format
- * FIXME: Using lfpuint(x) as rvalue, this will fail when representation changes.
  */
 #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)	M_NEG(lfpuint(*v), lfpfrac(*v))
+#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)	M_ADDF(lfpuint(*r), lfpfrac(*r), (f))
+#define	L_ADDF(r, f)	(*r) = uint64_to_lfp((int64_t)lfp_to_uint64(*r) + (int64_t)(uf))
 #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)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/28de04aec8d3d37fcb35c399d8ef4e52ba154da6...f58f03f9edff86344e5338a002e585fbf756a762
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161227/3dcc7881/attachment.html>


More information about the vc mailing list