summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h17
1 files changed, 12 insertions, 5 deletions
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;