#if __GNUC__ >= 3
# define expect(expr,value) __builtin_expect ((expr),(value))
-# define inline_size static inline /* inline for codesize */
-# if EV_MINIMAL
-# define noinline __attribute__ ((noinline))
-# define inline_speed static noinline
-# else
-# define noinline
-# define inline_speed static inline
-# endif
+# define noinline __attribute__ ((noinline))
#else
# define expect(expr,value) (expr)
-# define inline_speed static
-# define inline_size static
# define noinline
+# if __STDC_VERSION__ < 199901L
+# define inline
+# endif
#endif
#define expect_false(expr) expect ((expr) != 0, 0)
#define expect_true(expr) expect ((expr) != 0, 1)
+#define inline_size static inline
+
+#if EV_MINIMAL
+# define inline_speed static noinline
+#else
+# define inline_speed static inline
+#endif
#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
#define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
return ncur;
}
-inline_speed void *
+static noinline void *
array_realloc (int elem, void *base, int *cur, int cnt)
{
*cur = array_nextsize (elem, *cur, cnt);
ev_feed_event (EV_P_ void *w, int revents)
{
W w_ = (W)w;
+ int pri = ABSPRI (w_);
if (expect_false (w_->pending))
+ pendings [pri][w_->pending - 1].events |= revents;
+ else
{
- pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
- return;
+ w_->pending = ++pendingcnt [pri];
+ array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2);
+ pendings [pri][w_->pending - 1].w = w_;
+ pendings [pri][w_->pending - 1].events = revents;
}
-
- w_->pending = ++pendingcnt [ABSPRI (w_)];
- array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2);
- pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
- pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
}
void inline_size
void
ev_feed_fd_event (EV_P_ int fd, int revents)
{
- fd_event (EV_A_ fd, revents);
+ if (fd >= 0 && fd < anfdmax)
+ fd_event (EV_A_ fd, revents);
}
void inline_size
ev_feed_signal_event (EV_A_ signum + 1);
}
-void inline_size
+void inline_speed
fd_intern (int fd)
{
#ifdef _WIN32
/*****************************************************************************/
+void
+ev_invoke (EV_P_ void *w, int revents)
+{
+ EV_CB_INVOKE ((W)w, revents);
+}
+
void inline_speed
call_pending (EV_P)
{
}
else if (w->interval)
{
- ((WT)w)->at += floor ((ev_rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval;
+ ((WT)w)->at = w->offset + floor ((ev_rt_now - w->offset) / w->interval + 1.) * w->interval;
assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > ev_rt_now));
downheap ((WT *)periodics, periodiccnt, 0);
}
if (w->reschedule_cb)
((WT)w)->at = w->reschedule_cb (w, ev_rt_now);
else if (w->interval)
- ((WT)w)->at += ceil ((ev_rt_now - ((WT)w)->at) / w->interval) * w->interval;
+ ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
}
/* now rebuild the heap */
}
#endif
- /* queue check watchers (and execute them) */
+ /* queue prepare watchers (and execute them) */
if (expect_false (preparecnt))
{
queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
W w_ = (W)w;
int pending = w_->pending;
- if (!pending)
+ if (expect_true (pending))
+ {
+ ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1;
+ w_->pending = 0;
+ p->w = 0;
+ return p->events;
+ }
+ else
return 0;
-
- w_->pending = 0;
- ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1;
- p->w = 0;
-
- return p->events;
}
void inline_size
/*****************************************************************************/
-void
+void noinline
ev_io_start (EV_P_ ev_io *w)
{
int fd = w->fd;
fd_change (EV_A_ fd);
}
-void
+void noinline
ev_io_stop (EV_P_ ev_io *w)
{
clear_pending (EV_A_ (W)w);
fd_change (EV_A_ w->fd);
}
-void
+void noinline
ev_timer_start (EV_P_ ev_timer *w)
{
if (expect_false (ev_is_active (w)))
/*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/
}
-void
+void noinline
ev_timer_stop (EV_P_ ev_timer *w)
{
clear_pending (EV_A_ (W)w);
ev_stop (EV_A_ (W)w);
}
-void
+void noinline
ev_timer_again (EV_P_ ev_timer *w)
{
if (ev_is_active (w))
}
#if EV_PERIODIC_ENABLE
-void
+void noinline
ev_periodic_start (EV_P_ ev_periodic *w)
{
if (expect_false (ev_is_active (w)))
{
assert (("ev_periodic_start called with negative interval value", w->interval >= 0.));
/* this formula differs from the one in periodic_reify because we do not always round up */
- ((WT)w)->at += ceil ((ev_rt_now - ((WT)w)->at) / w->interval) * w->interval;
+ ((WT)w)->at = w->offset + ceil ((ev_rt_now - w->offset) / w->interval) * w->interval;
}
+ else
+ ((WT)w)->at = w->offset;
ev_start (EV_A_ (W)w, ++periodiccnt);
array_needsize (ev_periodic *, periodics, periodicmax, periodiccnt, EMPTY2);
/*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/
}
-void
+void noinline
ev_periodic_stop (EV_P_ ev_periodic *w)
{
clear_pending (EV_A_ (W)w);
ev_stop (EV_A_ (W)w);
}
-void
+void noinline
ev_periodic_again (EV_P_ ev_periodic *w)
{
/* TODO: use adjustheap and recalculation */
# define SA_RESTART 0
#endif
-void
+void noinline
ev_signal_start (EV_P_ ev_signal *w)
{
#if EV_MULTIPLICITY
}
}
-void
+void noinline
ev_signal_stop (EV_P_ ev_signal *w)
{
clear_pending (EV_A_ (W)w);