… | |
… | |
449 | typedef struct |
449 | typedef struct |
450 | { |
450 | { |
451 | WL head; |
451 | WL head; |
452 | unsigned char events; |
452 | unsigned char events; |
453 | unsigned char reify; |
453 | unsigned char reify; |
|
|
454 | unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ |
|
|
455 | unsigned char unused; /* currently unused padding */ |
454 | #if EV_SELECT_IS_WINSOCKET |
456 | #if EV_SELECT_IS_WINSOCKET |
455 | SOCKET handle; |
457 | SOCKET handle; |
456 | #endif |
458 | #endif |
457 | } ANFD; |
459 | } ANFD; |
458 | |
460 | |
… | |
… | |
611 | { |
613 | { |
612 | *cur = array_nextsize (elem, *cur, cnt); |
614 | *cur = array_nextsize (elem, *cur, cnt); |
613 | return ev_realloc (base, elem * *cur); |
615 | return ev_realloc (base, elem * *cur); |
614 | } |
616 | } |
615 | |
617 | |
|
|
618 | #define array_init_zero(base,count) \ |
|
|
619 | memset ((void *)(base), 0, sizeof (*(base)) * (count)) |
|
|
620 | |
616 | #define array_needsize(type,base,cur,cnt,init) \ |
621 | #define array_needsize(type,base,cur,cnt,init) \ |
617 | if (expect_false ((cnt) > (cur))) \ |
622 | if (expect_false ((cnt) > (cur))) \ |
618 | { \ |
623 | { \ |
619 | int ocur_ = (cur); \ |
624 | int ocur_ = (cur); \ |
620 | (base) = (type *)array_realloc \ |
625 | (base) = (type *)array_realloc \ |
… | |
… | |
662 | for (i = 0; i < eventcnt; ++i) |
667 | for (i = 0; i < eventcnt; ++i) |
663 | ev_feed_event (EV_A_ events [i], type); |
668 | ev_feed_event (EV_A_ events [i], type); |
664 | } |
669 | } |
665 | |
670 | |
666 | /*****************************************************************************/ |
671 | /*****************************************************************************/ |
667 | |
|
|
668 | void inline_size |
|
|
669 | anfds_init (ANFD *base, int count) |
|
|
670 | { |
|
|
671 | while (count--) |
|
|
672 | { |
|
|
673 | base->head = 0; |
|
|
674 | base->events = EV_NONE; |
|
|
675 | base->reify = 0; |
|
|
676 | |
|
|
677 | ++base; |
|
|
678 | } |
|
|
679 | } |
|
|
680 | |
672 | |
681 | void inline_speed |
673 | void inline_speed |
682 | fd_event (EV_P_ int fd, int revents) |
674 | fd_event (EV_P_ int fd, int revents) |
683 | { |
675 | { |
684 | ANFD *anfd = anfds + fd; |
676 | ANFD *anfd = anfds + fd; |
… | |
… | |
975 | static ANSIG *signals; |
967 | static ANSIG *signals; |
976 | static int signalmax; |
968 | static int signalmax; |
977 | |
969 | |
978 | static EV_ATOMIC_T gotsig; |
970 | static EV_ATOMIC_T gotsig; |
979 | |
971 | |
980 | void inline_size |
|
|
981 | signals_init (ANSIG *base, int count) |
|
|
982 | { |
|
|
983 | while (count--) |
|
|
984 | { |
|
|
985 | base->head = 0; |
|
|
986 | base->gotsig = 0; |
|
|
987 | |
|
|
988 | ++base; |
|
|
989 | } |
|
|
990 | } |
|
|
991 | |
|
|
992 | /*****************************************************************************/ |
972 | /*****************************************************************************/ |
993 | |
973 | |
994 | void inline_speed |
974 | void inline_speed |
995 | fd_intern (int fd) |
975 | fd_intern (int fd) |
996 | { |
976 | { |
… | |
… | |
2139 | |
2119 | |
2140 | if (expect_false (ev_is_active (w))) |
2120 | if (expect_false (ev_is_active (w))) |
2141 | return; |
2121 | return; |
2142 | |
2122 | |
2143 | assert (("ev_io_start called with negative fd", fd >= 0)); |
2123 | assert (("ev_io_start called with negative fd", fd >= 0)); |
|
|
2124 | assert (("ev_io start called with illegal event mask", !(w->events & ~(EV_IOFDSET | EV_READ | EV_WRITE)))); |
2144 | |
2125 | |
2145 | EV_FREQUENT_CHECK; |
2126 | EV_FREQUENT_CHECK; |
2146 | |
2127 | |
2147 | ev_start (EV_A_ (W)w, 1); |
2128 | ev_start (EV_A_ (W)w, 1); |
2148 | array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); |
2129 | array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); |
2149 | wlist_add (&anfds[fd].head, (WL)w); |
2130 | wlist_add (&anfds[fd].head, (WL)w); |
2150 | |
2131 | |
2151 | fd_change (EV_A_ fd, w->events & EV_IOFDSET | 1); |
2132 | fd_change (EV_A_ fd, w->events & EV_IOFDSET | 1); |
2152 | w->events &= ~EV_IOFDSET; |
2133 | w->events &= ~EV_IOFDSET; |
2153 | |
2134 | |
… | |
… | |
2345 | sigset_t full, prev; |
2326 | sigset_t full, prev; |
2346 | sigfillset (&full); |
2327 | sigfillset (&full); |
2347 | sigprocmask (SIG_SETMASK, &full, &prev); |
2328 | sigprocmask (SIG_SETMASK, &full, &prev); |
2348 | #endif |
2329 | #endif |
2349 | |
2330 | |
2350 | array_needsize (ANSIG, signals, signalmax, w->signum, signals_init); |
2331 | array_needsize (ANSIG, signals, signalmax, w->signum, array_init_zero); |
2351 | |
2332 | |
2352 | #ifndef _WIN32 |
2333 | #ifndef _WIN32 |
2353 | sigprocmask (SIG_SETMASK, &prev, 0); |
2334 | sigprocmask (SIG_SETMASK, &prev, 0); |
2354 | #endif |
2335 | #endif |
2355 | } |
2336 | } |