}
}
+#if (EVLIST_INTERNAL >> 4) != 1
+#error "Mismatch for value of EVLIST_INTERNAL"
+#endif
+/* These are a fancy way to spell
+ if (~ev->ev_flags & EVLIST_INTERNAL)
+ base->event_count--/++;
+*/
+#define DECR_EVENT_COUNT(base,ev) \
+ ((base)->event_count -= (~((ev)->ev_flags >> 4) & 1))
+#define INCR_EVENT_COUNT(base, ev) \
+ ((base)->event_count += (~((ev)->ev_flags >> 4) & 1))
+
static void
event_queue_remove_inserted(struct event_base *base, struct event *ev)
{
ev, ev->ev_fd, EVLIST_INSERTED);
return;
}
- if (~ev->ev_flags & EVLIST_INTERNAL)
- base->event_count--;
+ DECR_EVENT_COUNT(base, ev);
ev->ev_flags &= ~EVLIST_INSERTED;
TAILQ_REMOVE(&base->eventqueue, ev, ev_next);
}
ev, ev->ev_fd, EVLIST_ACTIVE);
return;
}
- if (~ev->ev_flags & EVLIST_INTERNAL)
- base->event_count--;
+ DECR_EVENT_COUNT(base, ev);
ev->ev_flags &= ~EVLIST_ACTIVE;
base->event_count_active--;
TAILQ_REMOVE(&base->activequeues[ev->ev_pri],
ev, ev->ev_fd, EVLIST_TIMEOUT);
return;
}
- if (~ev->ev_flags & EVLIST_INTERNAL)
- base->event_count--;
+ DECR_EVENT_COUNT(base, ev);
ev->ev_flags &= ~EVLIST_TIMEOUT;
if (is_common_timeout(&ev->ev_timeout, base)) {
return;
}
- if (~ev->ev_flags & EVLIST_INTERNAL)
- base->event_count++;
+ INCR_EVENT_COUNT(base, ev);
ev->ev_flags |= EVLIST_INSERTED;
return;
}
- if (~ev->ev_flags & EVLIST_INTERNAL)
- base->event_count++;
+ INCR_EVENT_COUNT(base, ev);
ev->ev_flags |= EVLIST_ACTIVE;
return;
}
- if (~ev->ev_flags & EVLIST_INTERNAL)
- base->event_count++;
+ INCR_EVENT_COUNT(base, ev);
ev->ev_flags |= EVLIST_TIMEOUT;