From: root Date: Sun, 9 Dec 2007 02:12:43 +0000 (+0000) Subject: µ-opts X-Git-Tag: rel-1_8~16 X-Git-Url: https://git.llucax.com/software/libev.git/commitdiff_plain/c92198a5c36ea9d1b1e0fae8254eb5609553bbf9?hp=fe7222913a6e42b65bfd92bc38479714316cfaf3 µ-opts --- diff --git a/ev.c b/ev.c index 628ccf9..808e07d 100644 --- a/ev.c +++ b/ev.c @@ -420,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); @@ -455,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 @@ -751,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 @@ -1584,7 +1584,7 @@ ev_stop (EV_P_ W w) /*****************************************************************************/ -void +void noinline ev_io_start (EV_P_ ev_io *w) { int fd = w->fd; @@ -1601,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); @@ -1616,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))) @@ -1634,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); @@ -1658,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)) @@ -1679,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))) @@ -1702,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); @@ -1724,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 */ @@ -1737,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 @@ -1766,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); diff --git a/ev_epoll.c b/ev_epoll.c index 38fd304..c544a14 100644 --- a/ev_epoll.c +++ b/ev_epoll.c @@ -42,7 +42,7 @@ epoll_modify (EV_P_ int fd, int oev, int nev) (nev & EV_READ ? EPOLLIN : 0) | (nev & EV_WRITE ? EPOLLOUT : 0); - if (epoll_ctl (backend_fd, mode, fd, &ev)) + if (expect_false (epoll_ctl (backend_fd, mode, fd, &ev))) if (errno != ENOENT /* on ENOENT the fd went away, so try to do the right thing */ || (nev && epoll_ctl (backend_fd, EPOLL_CTL_ADD, fd, &ev))) fd_kill (EV_A_ fd); @@ -54,7 +54,7 @@ epoll_poll (EV_P_ ev_tstamp timeout) int i; int eventcnt = epoll_wait (backend_fd, epoll_events, epoll_eventmax, (int)ceil (timeout * 1000.)); - if (eventcnt < 0) + if (expect_false (eventcnt < 0)) { if (errno != EINTR) syserr ("(libev) epoll_wait"); diff --git a/ev_kqueue.c b/ev_kqueue.c index 4fd649f..3103db1 100644 --- a/ev_kqueue.c +++ b/ev_kqueue.c @@ -92,7 +92,7 @@ kqueue_poll (EV_P_ ev_tstamp timeout) res = kevent (backend_fd, kqueue_changes, kqueue_changecnt, kqueue_events, kqueue_eventmax, &ts); kqueue_changecnt = 0; - if (res < 0) + if (expect_false (res < 0)) { if (errno != EINTR) syserr ("(libev) kevent"); diff --git a/ev_poll.c b/ev_poll.c index 52fe42d..9ceff16 100644 --- a/ev_poll.c +++ b/ev_poll.c @@ -31,7 +31,7 @@ #include -static void +void inline_size pollidx_init (int *base, int count) { while (count--) @@ -67,7 +67,7 @@ poll_modify (EV_P_ int fd, int oev, int nev) { pollidxs [fd] = -1; - if (idx < --pollcnt) + if (expect_true (idx < --pollcnt)) { polls [idx] = polls [pollcnt]; pollidxs [polls [idx].fd] = idx; @@ -81,7 +81,7 @@ poll_poll (EV_P_ ev_tstamp timeout) int i; int res = poll (polls, pollcnt, (int)ceil (timeout * 1000.)); - if (res < 0) + if (expect_false (res < 0)) { if (errno == EBADF) fd_ebadf (EV_A); @@ -94,7 +94,7 @@ poll_poll (EV_P_ ev_tstamp timeout) } for (i = 0; i < pollcnt; ++i) - if (polls [i].revents & POLLNVAL) + if (expect_false (polls [i].revents & POLLNVAL)) fd_kill (EV_A_ polls [i].fd); else fd_event ( diff --git a/ev_select.c b/ev_select.c index 1df0953..f899a79 100644 --- a/ev_select.c +++ b/ev_select.c @@ -90,7 +90,7 @@ select_modify (EV_P_ int fd, int oev, int nev) int word = fd / NFDBITS; int mask = 1UL << (fd % NFDBITS); - if (vec_max < word + 1) + if (expect_false (vec_max < word + 1)) { int new_max = word + 1; @@ -134,7 +134,7 @@ select_poll (EV_P_ ev_tstamp timeout) res = select (vec_max * NFDBITS, (fd_set *)vec_ro, (fd_set *)vec_wo, 0, &tv); - if (res < 0) + if (expect_false (res < 0)) { #if EV_SELECT_IS_WINSOCKET errno = WSAGetLastError (); @@ -168,7 +168,7 @@ select_poll (EV_P_ ev_tstamp timeout) if (FD_ISSET (handle, (fd_set *)vec_ro)) events |= EV_READ; if (FD_ISSET (handle, (fd_set *)vec_wo)) events |= EV_WRITE; - if (events) + if (expect_true (events)) fd_event (EV_A_ fd, events); } } @@ -191,7 +191,7 @@ select_poll (EV_P_ ev_tstamp timeout) events |= word_r & mask ? EV_READ : 0; events |= word_w & mask ? EV_WRITE : 0; - if (events) + if (expect_true (events)) fd_event (EV_A_ word * NFDBITS + bit, events); } }