ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.170 by root, Sat Dec 8 22:11:14 2007 UTC vs.
Revision 1.171 by root, Sun Dec 9 02:12:43 2007 UTC

418 } 418 }
419 419
420 return ncur; 420 return ncur;
421} 421}
422 422
423inline_speed void * 423static noinline void *
424array_realloc (int elem, void *base, int *cur, int cnt) 424array_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
454void noinline 454void noinline
455ev_feed_event (EV_P_ void *w, int revents) 455ev_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
471void inline_size 471void inline_size
472queue_events (EV_P_ W *events, int eventcnt, int type) 472queue_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
754void inline_size 754void inline_speed
755fd_intern (int fd) 755fd_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
1587void 1587void noinline
1588ev_io_start (EV_P_ ev_io *w) 1588ev_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
1604void 1604void noinline
1605ev_io_stop (EV_P_ ev_io *w) 1605ev_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
1619void 1619void noinline
1620ev_timer_start (EV_P_ ev_timer *w) 1620ev_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
1637void 1637void noinline
1638ev_timer_stop (EV_P_ ev_timer *w) 1638ev_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
1661void 1661void noinline
1662ev_timer_again (EV_P_ ev_timer *w) 1662ev_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
1682void 1682void noinline
1683ev_periodic_start (EV_P_ ev_periodic *w) 1683ev_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
1705void 1705void noinline
1706ev_periodic_stop (EV_P_ ev_periodic *w) 1706ev_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
1727void 1727void noinline
1728ev_periodic_again (EV_P_ ev_periodic *w) 1728ev_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
1740void 1740void noinline
1741ev_signal_start (EV_P_ ev_signal *w) 1741ev_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
1769void 1769void noinline
1770ev_signal_stop (EV_P_ ev_signal *w) 1770ev_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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines