#define NEAREST_TIMEOUT (((Timer*)timers->data)->timeout)
+static long timecompare(GTimeVal *a, GTimeVal *b)
+{
+ long r;
+
+ if ((r = b->tv_sec - a->tv_sec)) return r;
+ return b->tv_usec - a->tv_usec;
+
+}
+
static void insert_timer(Timer *self)
{
GSList *it;
for (it = timers; it != NULL; it = it->next) {
Timer *t = it->data;
- if (!timercmp(&self->timeout, &t->timeout, >)) {
+ if (timecompare(&self->timeout, &t->timeout) <= 0) {
timers = g_slist_insert_before(timers, it, self);
break;
}
/* the queue is sorted, so if this timer shouldn't fire, none are
ready */
- if (!timercmp(&now, &NEAREST_TIMEOUT, >))
+ if (timecompare(&NEAREST_TIMEOUT, &now) <= 0)
break;
/* we set the last fired time to delay msec after the previous firing,