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

Comparing libev/ev.c (file contents):
Revision 1.264 by root, Mon Oct 13 23:20:12 2008 UTC vs.
Revision 1.265 by root, Thu Oct 23 04:56:49 2008 UTC

449typedef struct 449typedef 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
668void inline_size
669anfds_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
681void inline_speed 673void inline_speed
682fd_event (EV_P_ int fd, int revents) 674fd_event (EV_P_ int fd, int revents)
683{ 675{
684 ANFD *anfd = anfds + fd; 676 ANFD *anfd = anfds + fd;
975static ANSIG *signals; 967static ANSIG *signals;
976static int signalmax; 968static int signalmax;
977 969
978static EV_ATOMIC_T gotsig; 970static EV_ATOMIC_T gotsig;
979 971
980void inline_size
981signals_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
994void inline_speed 974void inline_speed
995fd_intern (int fd) 975fd_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 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines