X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/480621758fe1687120978562a553920ed46e1b7e..c92198a5c36ea9d1b1e0fae8254eb5609553bbf9:/ev.c?ds=sidebyside diff --git a/ev.c b/ev.c index 7e9423e..808e07d 100644 --- a/ev.c +++ b/ev.c @@ -224,23 +224,24 @@ extern "C" { #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) @@ -419,7 +420,7 @@ array_nextsize (int elem, int cur, int cnt) return ncur; } -inline_speed void * +static noinline void * array_realloc (int elem, void *base, int *cur, int cnt) { *cur = array_nextsize (elem, *cur, cnt); @@ -454,17 +455,17 @@ void noinline 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 @@ -750,7 +751,7 @@ sigcb (EV_P_ ev_io *iow, int revents) ev_feed_signal_event (EV_A_ signum + 1); } -void inline_size +void inline_speed fd_intern (int fd) { #ifdef _WIN32 @@ -1415,7 +1416,7 @@ ev_loop (EV_P_ int flags) } #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); @@ -1583,7 +1584,7 @@ ev_stop (EV_P_ W w) /*****************************************************************************/ -void +void noinline ev_io_start (EV_P_ ev_io *w) { int fd = w->fd; @@ -1600,7 +1601,7 @@ ev_io_start (EV_P_ ev_io *w) fd_change (EV_A_ fd); } -void +void noinline ev_io_stop (EV_P_ ev_io *w) { clear_pending (EV_A_ (W)w); @@ -1615,7 +1616,7 @@ ev_io_stop (EV_P_ ev_io *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))) @@ -1633,7 +1634,7 @@ ev_timer_start (EV_P_ ev_timer *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); @@ -1657,7 +1658,7 @@ ev_timer_stop (EV_P_ ev_timer *w) ev_stop (EV_A_ (W)w); } -void +void noinline ev_timer_again (EV_P_ ev_timer *w) { if (ev_is_active (w)) @@ -1678,7 +1679,7 @@ ev_timer_again (EV_P_ ev_timer *w) } #if EV_PERIODIC_ENABLE -void +void noinline ev_periodic_start (EV_P_ ev_periodic *w) { if (expect_false (ev_is_active (w))) @@ -1701,7 +1702,7 @@ ev_periodic_start (EV_P_ ev_periodic *w) /*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); @@ -1723,7 +1724,7 @@ ev_periodic_stop (EV_P_ ev_periodic *w) ev_stop (EV_A_ (W)w); } -void +void noinline ev_periodic_again (EV_P_ ev_periodic *w) { /* TODO: use adjustheap and recalculation */ @@ -1736,7 +1737,7 @@ ev_periodic_again (EV_P_ ev_periodic *w) # define SA_RESTART 0 #endif -void +void noinline ev_signal_start (EV_P_ ev_signal *w) { #if EV_MULTIPLICITY @@ -1765,7 +1766,7 @@ ev_signal_start (EV_P_ ev_signal *w) } } -void +void noinline ev_signal_stop (EV_P_ ev_signal *w) { clear_pending (EV_A_ (W)w);