summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-06-28 13:45:57 +0200
committerBert <ber.t@gmx.com>2011-06-28 13:45:57 +0200
commitbd87ae9346503cb13ab1d12ff6f135b77fa0b473 (patch)
tree38365a088734cafef9bcd113129627c64fc0c537 /util.h
parentf52603b31a50a2e7159cc3229d36ec214c3064f0 (diff)
downloadnsxiv-bd87ae9346503cb13ab1d12ff6f135b77fa0b473.tar.zst
All timeouts in milliseconds
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;