From 4383a651c733ac59cd00f193c5115567f6a72f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Thu, 13 Oct 2011 16:50:06 +0200 Subject: Strictly adhere to ANSI-C standard --- util.h | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index 7bd6a61..7065a1b 100644 --- a/util.h +++ b/util.h @@ -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*); -- cgit v1.2.3