From 6810422ff51834779b384dc0b0c56871b35b1392 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 24 May 2016 22:00:37 +0200 Subject: lib: fixed time difference for timevals the structure is tv->tv_usec, not tv->tv_nsec --- include/ouroboros/time_utils.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/ouroboros/time_utils.h') diff --git a/include/ouroboros/time_utils.h b/include/ouroboros/time_utils.h index 4b3f3463..320cb6f1 100644 --- a/include/ouroboros/time_utils.h +++ b/include/ouroboros/time_utils.h @@ -46,8 +46,10 @@ + ((tx)->tv_nsec - (t0)->tv_nsec) / MILLION) /* functions for timevals are the same */ -#define tv_diff_us(t0, tx) ts_diff_us(t0, tx) -#define tv_diff_ms(t0, tx) ts_diff_ms(t0, tx) +#define tv_diff_us(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * MILLION \ + + ((tx)->tv_usec - (t0)->tv_usec) / 1000L) +#define tv_diff_ms(t0, tx) (((tx)->tv_sec - (t0)->tv_sec) * 1000L \ + + ((tx)->tv_usec - (t0)->tv_usec) / MILLION) /* functions for timespecs */ int ts_add(const struct timespec * t, -- cgit v1.2.3