summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorBert Münnich <ber.t@gmx.com>2011-10-13 16:50:06 +0200
committerBert Münnich <ber.t@gmx.com>2011-10-13 16:50:06 +0200
commit4383a651c733ac59cd00f193c5115567f6a72f5d (patch)
tree081c4c4f13da21379e4d96a70734e945e6305ca3 /util.h
parenta09b20c5e63839b10bae306e4a23ca5a9d8ebac0 (diff)
downloadnsxiv-4383a651c733ac59cd00f193c5115567f6a72f5d.tar.zst
Strictly adhere to ANSI-C standard
Diffstat (limited to 'util.h')
-rw-r--r--util.h38
1 files changed, 15 insertions, 23 deletions
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*);