From bd87ae9346503cb13ab1d12ff6f135b77fa0b473 Mon Sep 17 00:00:00 2001 From: Bert Date: Tue, 28 Jun 2011 13:45:57 +0200 Subject: All timeouts in milliseconds --- util.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index c1e08a6..9e08bac 100644 --- a/util.h +++ b/util.h @@ -28,14 +28,21 @@ #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define LEN(a) (sizeof(a) / sizeof(a[0])) -#define TV_TO_DOUBLE(x) ((double) ((x).tv_sec) + 0.000001 * \ - (double) ((x).tv_usec)) +#define TIMEDIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec) * 1000 + \ + ((t1)->tv_usec - (t2)->tv_usec) / 1000) -#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ - (tv)->tv_sec = (ts)->tv_sec; \ - (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +#define MSEC_TO_TIMEVAL(t,tv) { \ + (tv)->tv_sec = (t) / 1000; \ + (tv)->tv_usec = (t) % 1000 * 1000; \ } +#ifndef TIMESPEC_TO_TIMEVAL +#define TIMESPEC_TO_TIMEVAL(tv,ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} +#endif + typedef struct { DIR *dir; char *name; -- cgit v1.2.3