#include <stdbool.h>
#include "uloop.h"
+#include "utils.h"
#ifdef USE_KQUEUE
#include <sys/event.h>
#endif
#include <sys/wait.h>
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
#define ULOOP_MAX_EVENTS 10
static struct list_head timeouts = LIST_HEAD_INIT(timeouts);
static int tv_diff(struct timeval *t1, struct timeval *t2)
{
- if (t1->tv_sec != t2->tv_sec)
- return (t1->tv_sec - t2->tv_sec) * 1000;
- else
- return (t1->tv_usec - t2->tv_usec) / 1000;
+ return
+ (t1->tv_sec - t2->tv_sec) * 1000 +
+ (t1->tv_usec - t2->tv_usec) / 1000;
}
int uloop_timeout_add(struct uloop_timeout *timeout)
if (time->tv_usec > 1000000) {
time->tv_sec++;
- time->tv_usec %= 100000;
+ time->tv_usec %= 1000000;
}
return uloop_timeout_add(timeout);