[Git][NTPsec/ntpsec][master] Anither step in treating l_fp like a scalar type. Pure refactoring.
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Dec 26 19:29:40 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
a0780451 by Eric S. Raymond at 2016-12-26T14:28:46-05:00
Anither step in treating l_fp like a scalar type. Pure refactoring.
- - - - -
2 changed files:
- include/ntp_fp.h
- ntpd/ntp_proto.c
Changes:
=====================================
include/ntp_fp.h
=====================================
--- a/include/ntp_fp.h
+++ b/include/ntp_fp.h
@@ -47,8 +47,8 @@ typedef struct {
#define setlfpuint(n, v) (n).l_ui = (v)
#define bumplfpuint(n, i) (n).l_ui += (i)
-static inline uint64_t lfp_to_uint64(const l_fp *lfp) {
- return (uint64_t)lfpuint(*lfp) << 32 | (uint64_t)lfpfrac(*lfp);
+static inline uint64_t lfp_to_uint64(const l_fp lfp) {
+ return (uint64_t)lfpuint(lfp) << 32 | (uint64_t)lfpfrac(lfp);
}
static inline void uint64_to_lfp(l_fp *lfp, uint64_t x) {
=====================================
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 == lfp_to_uint64(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 != lfp_to_uint64(peer->org)) {
peer->flash |= BOGON2;
peer->bogusorg++;
return;
@@ -578,15 +578,15 @@ handle_procpkt(
avoid loss of precision.
*/
- const uint64_t dst = lfp_to_uint64(&rbufp->recv_time);
+ 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);
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 >= 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);
const double theta = (t21 + t34) / 2.;
const double delta = fabs(t21 - t34);
const double epsilon = LOGTOD(sys_precision) +
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/a0780451e260d6d28c27332581e36625df10a2c6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161226/7536848c/attachment.html>
More information about the vc
mailing list