… | |
… | |
418 | } |
418 | } |
419 | |
419 | |
420 | return ncur; |
420 | return ncur; |
421 | } |
421 | } |
422 | |
422 | |
423 | inline_speed void * |
423 | static noinline void * |
424 | array_realloc (int elem, void *base, int *cur, int cnt) |
424 | array_realloc (int elem, void *base, int *cur, int cnt) |
425 | { |
425 | { |
426 | *cur = array_nextsize (elem, *cur, cnt); |
426 | *cur = array_nextsize (elem, *cur, cnt); |
427 | return ev_realloc (base, elem * *cur); |
427 | return ev_realloc (base, elem * *cur); |
428 | } |
428 | } |
… | |
… | |
453 | |
453 | |
454 | void noinline |
454 | void noinline |
455 | ev_feed_event (EV_P_ void *w, int revents) |
455 | ev_feed_event (EV_P_ void *w, int revents) |
456 | { |
456 | { |
457 | W w_ = (W)w; |
457 | W w_ = (W)w; |
|
|
458 | int pri = ABSPRI (w_); |
458 | |
459 | |
459 | if (expect_false (w_->pending)) |
460 | if (expect_false (w_->pending)) |
|
|
461 | pendings [pri][w_->pending - 1].events |= revents; |
|
|
462 | else |
460 | { |
463 | { |
|
|
464 | w_->pending = ++pendingcnt [pri]; |
|
|
465 | array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); |
|
|
466 | pendings [pri][w_->pending - 1].w = w_; |
461 | pendings [ABSPRI (w_)][w_->pending - 1].events |= revents; |
467 | pendings [pri][w_->pending - 1].events = revents; |
462 | return; |
|
|
463 | } |
468 | } |
464 | |
|
|
465 | w_->pending = ++pendingcnt [ABSPRI (w_)]; |
|
|
466 | array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2); |
|
|
467 | pendings [ABSPRI (w_)][w_->pending - 1].w = w_; |
|
|
468 | pendings [ABSPRI (w_)][w_->pending - 1].events = revents; |
|
|
469 | } |
469 | } |
470 | |
470 | |
471 | void inline_size |
471 | void inline_size |
472 | queue_events (EV_P_ W *events, int eventcnt, int type) |
472 | queue_events (EV_P_ W *events, int eventcnt, int type) |
473 | { |
473 | { |
… | |
… | |
749 | for (signum = signalmax; signum--; ) |
749 | for (signum = signalmax; signum--; ) |
750 | if (signals [signum].gotsig) |
750 | if (signals [signum].gotsig) |
751 | ev_feed_signal_event (EV_A_ signum + 1); |
751 | ev_feed_signal_event (EV_A_ signum + 1); |
752 | } |
752 | } |
753 | |
753 | |
754 | void inline_size |
754 | void inline_speed |
755 | fd_intern (int fd) |
755 | fd_intern (int fd) |
756 | { |
756 | { |
757 | #ifdef _WIN32 |
757 | #ifdef _WIN32 |
758 | int arg = 1; |
758 | int arg = 1; |
759 | ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg); |
759 | ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg); |
… | |
… | |
1582 | w->active = 0; |
1582 | w->active = 0; |
1583 | } |
1583 | } |
1584 | |
1584 | |
1585 | /*****************************************************************************/ |
1585 | /*****************************************************************************/ |
1586 | |
1586 | |
1587 | void |
1587 | void noinline |
1588 | ev_io_start (EV_P_ ev_io *w) |
1588 | ev_io_start (EV_P_ ev_io *w) |
1589 | { |
1589 | { |
1590 | int fd = w->fd; |
1590 | int fd = w->fd; |
1591 | |
1591 | |
1592 | if (expect_false (ev_is_active (w))) |
1592 | if (expect_false (ev_is_active (w))) |
… | |
… | |
1599 | wlist_add ((WL *)&anfds[fd].head, (WL)w); |
1599 | wlist_add ((WL *)&anfds[fd].head, (WL)w); |
1600 | |
1600 | |
1601 | fd_change (EV_A_ fd); |
1601 | fd_change (EV_A_ fd); |
1602 | } |
1602 | } |
1603 | |
1603 | |
1604 | void |
1604 | void noinline |
1605 | ev_io_stop (EV_P_ ev_io *w) |
1605 | ev_io_stop (EV_P_ ev_io *w) |
1606 | { |
1606 | { |
1607 | clear_pending (EV_A_ (W)w); |
1607 | clear_pending (EV_A_ (W)w); |
1608 | if (expect_false (!ev_is_active (w))) |
1608 | if (expect_false (!ev_is_active (w))) |
1609 | return; |
1609 | return; |
… | |
… | |
1614 | ev_stop (EV_A_ (W)w); |
1614 | ev_stop (EV_A_ (W)w); |
1615 | |
1615 | |
1616 | fd_change (EV_A_ w->fd); |
1616 | fd_change (EV_A_ w->fd); |
1617 | } |
1617 | } |
1618 | |
1618 | |
1619 | void |
1619 | void noinline |
1620 | ev_timer_start (EV_P_ ev_timer *w) |
1620 | ev_timer_start (EV_P_ ev_timer *w) |
1621 | { |
1621 | { |
1622 | if (expect_false (ev_is_active (w))) |
1622 | if (expect_false (ev_is_active (w))) |
1623 | return; |
1623 | return; |
1624 | |
1624 | |
… | |
… | |
1632 | upheap ((WT *)timers, timercnt - 1); |
1632 | upheap ((WT *)timers, timercnt - 1); |
1633 | |
1633 | |
1634 | /*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/ |
1634 | /*assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));*/ |
1635 | } |
1635 | } |
1636 | |
1636 | |
1637 | void |
1637 | void noinline |
1638 | ev_timer_stop (EV_P_ ev_timer *w) |
1638 | ev_timer_stop (EV_P_ ev_timer *w) |
1639 | { |
1639 | { |
1640 | clear_pending (EV_A_ (W)w); |
1640 | clear_pending (EV_A_ (W)w); |
1641 | if (expect_false (!ev_is_active (w))) |
1641 | if (expect_false (!ev_is_active (w))) |
1642 | return; |
1642 | return; |
… | |
… | |
1656 | ((WT)w)->at -= mn_now; |
1656 | ((WT)w)->at -= mn_now; |
1657 | |
1657 | |
1658 | ev_stop (EV_A_ (W)w); |
1658 | ev_stop (EV_A_ (W)w); |
1659 | } |
1659 | } |
1660 | |
1660 | |
1661 | void |
1661 | void noinline |
1662 | ev_timer_again (EV_P_ ev_timer *w) |
1662 | ev_timer_again (EV_P_ ev_timer *w) |
1663 | { |
1663 | { |
1664 | if (ev_is_active (w)) |
1664 | if (ev_is_active (w)) |
1665 | { |
1665 | { |
1666 | if (w->repeat) |
1666 | if (w->repeat) |
… | |
… | |
1677 | ev_timer_start (EV_A_ w); |
1677 | ev_timer_start (EV_A_ w); |
1678 | } |
1678 | } |
1679 | } |
1679 | } |
1680 | |
1680 | |
1681 | #if EV_PERIODIC_ENABLE |
1681 | #if EV_PERIODIC_ENABLE |
1682 | void |
1682 | void noinline |
1683 | ev_periodic_start (EV_P_ ev_periodic *w) |
1683 | ev_periodic_start (EV_P_ ev_periodic *w) |
1684 | { |
1684 | { |
1685 | if (expect_false (ev_is_active (w))) |
1685 | if (expect_false (ev_is_active (w))) |
1686 | return; |
1686 | return; |
1687 | |
1687 | |
… | |
… | |
1700 | upheap ((WT *)periodics, periodiccnt - 1); |
1700 | upheap ((WT *)periodics, periodiccnt - 1); |
1701 | |
1701 | |
1702 | /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/ |
1702 | /*assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));*/ |
1703 | } |
1703 | } |
1704 | |
1704 | |
1705 | void |
1705 | void noinline |
1706 | ev_periodic_stop (EV_P_ ev_periodic *w) |
1706 | ev_periodic_stop (EV_P_ ev_periodic *w) |
1707 | { |
1707 | { |
1708 | clear_pending (EV_A_ (W)w); |
1708 | clear_pending (EV_A_ (W)w); |
1709 | if (expect_false (!ev_is_active (w))) |
1709 | if (expect_false (!ev_is_active (w))) |
1710 | return; |
1710 | return; |
… | |
… | |
1722 | } |
1722 | } |
1723 | |
1723 | |
1724 | ev_stop (EV_A_ (W)w); |
1724 | ev_stop (EV_A_ (W)w); |
1725 | } |
1725 | } |
1726 | |
1726 | |
1727 | void |
1727 | void noinline |
1728 | ev_periodic_again (EV_P_ ev_periodic *w) |
1728 | ev_periodic_again (EV_P_ ev_periodic *w) |
1729 | { |
1729 | { |
1730 | /* TODO: use adjustheap and recalculation */ |
1730 | /* TODO: use adjustheap and recalculation */ |
1731 | ev_periodic_stop (EV_A_ w); |
1731 | ev_periodic_stop (EV_A_ w); |
1732 | ev_periodic_start (EV_A_ w); |
1732 | ev_periodic_start (EV_A_ w); |
… | |
… | |
1735 | |
1735 | |
1736 | #ifndef SA_RESTART |
1736 | #ifndef SA_RESTART |
1737 | # define SA_RESTART 0 |
1737 | # define SA_RESTART 0 |
1738 | #endif |
1738 | #endif |
1739 | |
1739 | |
1740 | void |
1740 | void noinline |
1741 | ev_signal_start (EV_P_ ev_signal *w) |
1741 | ev_signal_start (EV_P_ ev_signal *w) |
1742 | { |
1742 | { |
1743 | #if EV_MULTIPLICITY |
1743 | #if EV_MULTIPLICITY |
1744 | assert (("signal watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
1744 | assert (("signal watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
1745 | #endif |
1745 | #endif |
… | |
… | |
1764 | sigaction (w->signum, &sa, 0); |
1764 | sigaction (w->signum, &sa, 0); |
1765 | #endif |
1765 | #endif |
1766 | } |
1766 | } |
1767 | } |
1767 | } |
1768 | |
1768 | |
1769 | void |
1769 | void noinline |
1770 | ev_signal_stop (EV_P_ ev_signal *w) |
1770 | ev_signal_stop (EV_P_ ev_signal *w) |
1771 | { |
1771 | { |
1772 | clear_pending (EV_A_ (W)w); |
1772 | clear_pending (EV_A_ (W)w); |
1773 | if (expect_false (!ev_is_active (w))) |
1773 | if (expect_false (!ev_is_active (w))) |
1774 | return; |
1774 | return; |