[Git][NTPsec/ntpsec][master] Eliminate struct timeval operations from parse library.
Eric S. Raymond
gitlab at mg.gitlab.com
Wed Oct 5 09:08:23 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
96fff4a5 by Eric S. Raymond at 2016-10-05T05:05:21-04:00
Eliminate struct timeval operations from parse library.
Untested. If the parse driver begins throwing spurious timeouts, this
is the change to suspect.
- - - - -
3 changed files:
- include/parse.h
- include/timespecops.h
- libparse/parse.c
Changes:
=====================================
include/parse.h
=====================================
--- a/include/parse.h
+++ b/include/parse.h
@@ -305,7 +305,7 @@ extern void syn_simple (parse_t *, timestamp_t *, struct format *, unsigned long
extern parse_pps_fnc_t pps_simple;
extern parse_pps_fnc_t pps_one;
extern parse_pps_fnc_t pps_zero;
-extern bool parse_timedout (parse_t *, timestamp_t *, struct timeval *);
+extern bool parse_timedout (parse_t *, timestamp_t *, struct timespec *);
#endif
=====================================
include/timespecops.h
=====================================
--- a/include/timespecops.h
+++ b/include/timespecops.h
@@ -215,6 +215,10 @@ abs_tspec(
* compare previously-normalised a and b
* return 1 / 0 / -1 if a < / == / > b
*/
+#define TIMESPEC_LESS_THAN 1
+#define TIMESPEC_EQUAL 0
+#define TIMESPEC_GREATER_THAN -1
+
static inline int
cmp_tspec(
struct timespec a,
=====================================
libparse/parse.c
=====================================
--- a/libparse/parse.c
+++ b/libparse/parse.c
@@ -9,7 +9,7 @@
#include <config.h>
#include "ntp_fp.h"
-#include "timevalops.h"
+#include "timespecops.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
#include "ntp_machine.h"
@@ -28,18 +28,17 @@ bool
parse_timedout(
parse_t *parseio,
timestamp_t *tstamp,
- struct timeval *del
+ struct timespec *del
)
{
- struct timeval delta;
+ struct timespec delta;
l_fp delt;
delt = tstamp->fp;
L_SUB(&delt, &parseio->parse_lastchar.fp);
- TSTOTV(&delt, &delta);
-
- if (timercmp(&delta, del, >))
+ delta = lfp_uintv_to_tspec(delt);
+ if (cmp_tspec(delta, *del) == TIMESPEC_GREATER_THAN)
{
parseprintf(DD_PARSE, ("parse: timedout: TRUE\n"));
return true;
@@ -621,9 +620,9 @@ timepacket(
/*
* time stamp
*/
- parseio->parse_dtime.parse_time.fp.l_ui = (uint32_t) (t + JAN_1970);
- TVUTOTSF(clock_time.usecond, parseio->parse_dtime.parse_time.fp.l_uf);
-
+ struct timespec ts = {t, clock_time.usecond * 1000};
+ parseio->parse_dtime.parse_time.fp = tspec_stamp_to_lfp(ts);
+
parseio->parse_dtime.parse_format = format;
return updatetimeinfo(parseio, clock_time.flags);
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/96fff4a51779c943d02c6dbe74392d3998bc8f88
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161005/e0269e8f/attachment.html>
More information about the vc
mailing list