[Git][NTPsec/ntpsec][master] Refactoring step: replace ad-hoc timestamp conversion.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Jan 3 00:35:18 UTC 2017
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
cd5a6a0f by Eric S. Raymond at 2017-01-02T19:35:05-05:00
Refactoring step: replace ad-hoc timestamp conversion.
- - - - -
1 changed file:
- ntpd/refclock_oncore.c
Changes:
=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -152,6 +152,7 @@
#include "ntp_refclock.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
+#include "timespecops.h"
#include <stdio.h>
#include <stdarg.h>
@@ -1678,26 +1679,6 @@ oncore_get_timestamp(
instance->ev_serial = pps_i.clear_sequence;
}
- /* convert timespec -> ntp l_fp */
- dmy = tsp->tv_nsec;
- dmy /= 1e9;
- setlfpfrac(ts, dmy * 4294967296.0);
- setlfpuint(ts, tsp->tv_sec);
-
-#if 0
- alternate code for previous 4 lines is
- dmy = 1.0e-9*tsp->tv_nsec; /* fractional part */
- DTOLFP(dmy, &ts);
- dmy = tsp->tv_sec; /* integer part */
- DTOLFP(dmy, &ts_tmp);
- L_ADD(&ts, &ts_tmp);
- or more simply
- dmy = 1.0e-9*tsp->tv_nsec; /* fractional part */
- DTOLFP(dmy, &ts);
- setlfpuint(ts, tsp->tv_sec);
-#endif /* 0 */
-
- /* now have timestamp in ts */
/* add in saw_tooth and offset, these will be ZERO if no TRAIM */
/* they will be IGNORED if the PPSAPI can't do PPS_OFFSET/ASSERT/CLEAR */
/* we just try to add them in and don't test for that here */
@@ -1757,8 +1738,7 @@ oncore_get_timestamp(
oncore_log(instance, LOG_ERR, "ONCORE: Error doing time_pps_setparams");
/* have time from UNIX origin, convert to NTP origin. */
-
- bumplfpuint(ts, JAN_1970);
+ ts = tspec_stamp_to_lfp(*tsp);
instance->pp->lastrec = ts;
/* print out information about this timestamp (long line) */
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/cd5a6a0f1bf976c92ed202f6efcfb7663f151f4a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170103/f8026dad/attachment.html>
More information about the vc
mailing list