diff options
author | Bert <ber.t@gmx.com> | 2011-06-28 13:45:57 +0200 |
---|---|---|
committer | Bert <ber.t@gmx.com> | 2011-06-28 13:45:57 +0200 |
commit | bd87ae9346503cb13ab1d12ff6f135b77fa0b473 (patch) | |
tree | 38365a088734cafef9bcd113129627c64fc0c537 /util.h | |
parent | f52603b31a50a2e7159cc3229d36ec214c3064f0 (diff) | |
download | nsxiv-bd87ae9346503cb13ab1d12ff6f135b77fa0b473.tar.zst |
All timeouts in milliseconds
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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; |