diff options
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 38 |
1 files changed, 15 insertions, 23 deletions
@@ -36,6 +36,21 @@ #define ARRLEN(a) (sizeof(a) / sizeof((a)[0])) +#define STREQ(s1,s2) (strcmp((s1), (s2)) == 0) + +#define TV_DIFF(t1,t2) (((t1)->tv_sec - (t2)->tv_sec ) * 1000 + \ + ((t1)->tv_usec - (t2)->tv_usec) / 1000) + +#define TV_SET_MSEC(tv,t) { \ + (tv)->tv_sec = (t) / 1000; \ + (tv)->tv_usec = (t) % 1000 * 1000; \ +} + +#define TV_ADD_MSEC(tv,t) { \ + (tv)->tv_sec = (t) / 1000; \ + (tv)->tv_usec = (t) % 1000 * 1000; \ +} + typedef struct { DIR *dir; char *name; @@ -46,29 +61,6 @@ typedef struct { int stlen; } r_dir_t; -static inline -bool streq(const char *a, const char *b) { - return strcmp(a, b) == 0; -} - -static inline -long tv_diff(const struct timeval *t1, const struct timeval *t2) { - return (t1->tv_sec - t2->tv_sec) * 1000 + - (t1->tv_usec - t2->tv_usec) / 1000; -} - -static inline -void tv_set_msec(struct timeval *t, int msec) { - t->tv_sec = msec / 1000; - t->tv_usec = msec % 1000 * 1000; -} - -static inline -void tv_add_msec(struct timeval *t, int msec) { - t->tv_sec += msec / 1000; - t->tv_usec += msec % 1000 * 1000; -} - void* s_malloc(size_t); void* s_realloc(void*, size_t); char* s_strdup(char*); |