[Git][NTPsec/ntpsec][master] Factor out one particularly tricky l_fp field access.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Dec 25 11:00:00 UTC 2016


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


Commits:
8b76fb71 by Eric S. Raymond at 2016-12-25T05:59:19-05:00
Factor out one particularly tricky l_fp field access.

- - - - -


3 changed files:

- include/ntp_fp.h
- libparse/data_mbg.c
- libparse/mfp_mul.c


Changes:

=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -366,7 +366,7 @@ extern	char *	prettydate	(l_fp *);
 extern	char *	gmprettydate	(l_fp *);
 extern	char *	gmprettydate	(l_fp *);
 extern	char *	rfc3339date	(l_fp *);
-extern  void	mfp_mul		(int32_t *, uint32_t *, int32_t, uint32_t, int32_t, uint32_t);
+extern  l_fp	mfp_mul		(int32_t, uint32_t, int32_t, uint32_t);
 
 extern	void	set_sys_fuzz	(double);
 extern  void	get_ostime	(struct timespec *tsp);


=====================================
libparse/data_mbg.c
=====================================
--- a/libparse/data_mbg.c
+++ b/libparse/data_mbg.c
@@ -326,7 +326,7 @@ get_mbg_lla(
       else
 	if (i != ALT)
 	  {			/* convert to degrees (* 180/PI) */
-	    mfp_mul(&lla[i].l_i, &lla[i].l_uf, lla[i].l_i, lla[i].l_uf, rad2deg_i, rad2deg_f);
+	    lla[i] = mfp_mul(lla[i].l_i, lla[i].l_uf, rad2deg_i, rad2deg_f);
 	  }
     }
 }


=====================================
libparse/mfp_mul.c
=====================================
--- a/libparse/mfp_mul.c
+++ b/libparse/mfp_mul.c
@@ -26,10 +26,8 @@
  *    addition, so no storage for the 2^2n term from above is needed.
  */
 
-void
+l_fp
 mfp_mul(
-	int32_t   *o_i,
-	uint32_t *o_f,
 	int32_t    a_i,
 	uint32_t  a_f,
 	int32_t    b_i,
@@ -42,6 +40,7 @@ mfp_mul(
   unsigned long b[4];			/* operand b */
   unsigned long c[6];			/* result c - 5 items for performance - see below */
   unsigned long carry;
+  l_fp out;
   
   int neg = 0;
 
@@ -131,8 +130,8 @@ mfp_mul(
       M_NEG(i, f);
     }
 
-  *o_i = i;
-  *o_f = f;
+  setlfpsint(out, i);
+  setlfpfrac(out, f);
 
 #ifdef DEBUG
   if (debug > 6)
@@ -141,6 +140,7 @@ mfp_mul(
 	   mfptoa((unsigned long)b_i, b_f, 6),
 	   mfptoa((unsigned long)i, f, 6));
 #endif
+  return out;
 }
 
 /*



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8b76fb718582afd53c4154caae7601a78f0f3643
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161225/df19b9a0/attachment.html>


More information about the vc mailing list