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

Comparing libev/ev.c (file contents):
Revision 1.328 by root, Sun Feb 14 19:23:19 2010 UTC vs.
Revision 1.337 by root, Wed Mar 10 09:18:24 2010 UTC

184# define WIN32_LEAN_AND_MEAN 184# define WIN32_LEAN_AND_MEAN
185# include <windows.h> 185# include <windows.h>
186# ifndef EV_SELECT_IS_WINSOCKET 186# ifndef EV_SELECT_IS_WINSOCKET
187# define EV_SELECT_IS_WINSOCKET 1 187# define EV_SELECT_IS_WINSOCKET 1
188# endif 188# endif
189# undef EV_AVOID_STDIO
189#endif 190#endif
190 191
191/* this block tries to deduce configuration from header-defined symbols and defaults */ 192/* this block tries to deduce configuration from header-defined symbols and defaults */
192 193
193/* try to deduce the maximum number of signals on this platform */ 194/* try to deduce the maximum number of signals on this platform */
206#elif defined (MAXSIG) 207#elif defined (MAXSIG)
207# define EV_NSIG (MAXSIG+1) 208# define EV_NSIG (MAXSIG+1)
208#elif defined (MAX_SIG) 209#elif defined (MAX_SIG)
209# define EV_NSIG (MAX_SIG+1) 210# define EV_NSIG (MAX_SIG+1)
210#elif defined (SIGARRAYSIZE) 211#elif defined (SIGARRAYSIZE)
211# define EV_NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */ 212# define EV_NSIG (SIGARRAYSIZE) /* Assume ary[SIGARRAYSIZE] */
212#elif defined (_sys_nsig) 213#elif defined (_sys_nsig)
213# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ 214# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */
214#else 215#else
215# error "unable to find value for NSIG, please report" 216# error "unable to find value for NSIG, please report"
216/* to make it compile regardless, just remove the above line */ 217/* to make it compile regardless, just remove the above line, */
218/* but consider reporting it, too! :) */
217# define EV_NSIG 65 219# define EV_NSIG 65
218#endif 220#endif
219 221
220#ifndef EV_USE_CLOCK_SYSCALL 222#ifndef EV_USE_CLOCK_SYSCALL
221# if __linux && __GLIBC__ >= 2 223# if __linux && __GLIBC__ >= 2
403# endif 405# endif
404# endif 406# endif
405# ifdef __cplusplus 407# ifdef __cplusplus
406extern "C" { 408extern "C" {
407# endif 409# endif
408int eventfd (unsigned int initval, int flags); 410int (eventfd) (unsigned int initval, int flags);
409# ifdef __cplusplus 411# ifdef __cplusplus
410} 412}
411# endif 413# endif
412#endif 414#endif
413 415
524# include "ev_win32.c" 526# include "ev_win32.c"
525#endif 527#endif
526 528
527/*****************************************************************************/ 529/*****************************************************************************/
528 530
531#if EV_AVOID_STDIO
532static void noinline
533ev_printerr (const char *msg)
534{
535 write (STDERR_FILENO, msg, strlen (msg));
536}
537#endif
538
529static void (*syserr_cb)(const char *msg); 539static void (*syserr_cb)(const char *msg);
530 540
531void 541void
532ev_set_syserr_cb (void (*cb)(const char *msg)) 542ev_set_syserr_cb (void (*cb)(const char *msg))
533{ 543{
542 552
543 if (syserr_cb) 553 if (syserr_cb)
544 syserr_cb (msg); 554 syserr_cb (msg);
545 else 555 else
546 { 556 {
557#if EV_AVOID_STDIO
558 const char *err = strerror (errno);
559
560 ev_printerr (msg);
561 ev_printerr (": ");
562 ev_printerr (err);
563 ev_printerr ("\n");
564#else
547 perror (msg); 565 perror (msg);
566#endif
548 abort (); 567 abort ();
549 } 568 }
550} 569}
551 570
552static void * 571static void *
553ev_realloc_emul (void *ptr, long size) 572ev_realloc_emul (void *ptr, long size)
554{ 573{
574#if __GLIBC__
575 return realloc (ptr, size);
576#else
555 /* some systems, notably openbsd and darwin, fail to properly 577 /* some systems, notably openbsd and darwin, fail to properly
556 * implement realloc (x, 0) (as required by both ansi c-98 and 578 * implement realloc (x, 0) (as required by both ansi c-89 and
557 * the single unix specification, so work around them here. 579 * the single unix specification, so work around them here.
558 */ 580 */
559 581
560 if (size) 582 if (size)
561 return realloc (ptr, size); 583 return realloc (ptr, size);
562 584
563 free (ptr); 585 free (ptr);
564 return 0; 586 return 0;
587#endif
565} 588}
566 589
567static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; 590static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
568 591
569void 592void
577{ 600{
578 ptr = alloc (ptr, size); 601 ptr = alloc (ptr, size);
579 602
580 if (!ptr && size) 603 if (!ptr && size)
581 { 604 {
605#if EV_AVOID_STDIO
606 ev_printerr ("libev: memory allocation failed, aborting.\n");
607#else
582 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); 608 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size);
609#endif
583 abort (); 610 abort ();
584 } 611 }
585 612
586 return ptr; 613 return ptr;
587} 614}
864} 891}
865 892
866/*****************************************************************************/ 893/*****************************************************************************/
867 894
868inline_speed void 895inline_speed void
869fd_event_nc (EV_P_ int fd, int revents) 896fd_event_nocheck (EV_P_ int fd, int revents)
870{ 897{
871 ANFD *anfd = anfds + fd; 898 ANFD *anfd = anfds + fd;
872 ev_io *w; 899 ev_io *w;
873 900
874 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) 901 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
886fd_event (EV_P_ int fd, int revents) 913fd_event (EV_P_ int fd, int revents)
887{ 914{
888 ANFD *anfd = anfds + fd; 915 ANFD *anfd = anfds + fd;
889 916
890 if (expect_true (!anfd->reify)) 917 if (expect_true (!anfd->reify))
891 fd_event_nc (EV_A_ fd, revents); 918 fd_event_nocheck (EV_A_ fd, revents);
892} 919}
893 920
894void 921void
895ev_feed_fd_event (EV_P_ int fd, int revents) 922ev_feed_fd_event (EV_P_ int fd, int revents)
896{ 923{
897 if (fd >= 0 && fd < anfdmax) 924 if (fd >= 0 && fd < anfdmax)
898 fd_event_nc (EV_A_ fd, revents); 925 fd_event_nocheck (EV_A_ fd, revents);
899} 926}
900 927
901/* make sure the external fd watch events are in-sync */ 928/* make sure the external fd watch events are in-sync */
902/* with the kernel/libev internal state */ 929/* with the kernel/libev internal state */
903inline_size void 930inline_size void
966 ev_io_stop (EV_A_ w); 993 ev_io_stop (EV_A_ w);
967 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); 994 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
968 } 995 }
969} 996}
970 997
971/* check whether the given fd is atcually valid, for error recovery */ 998/* check whether the given fd is actually valid, for error recovery */
972inline_size int 999inline_size int
973fd_valid (int fd) 1000fd_valid (int fd)
974{ 1001{
975#ifdef _WIN32 1002#ifdef _WIN32
976 return EV_FD_TO_WIN32_HANDLE (fd) != -1; 1003 return EV_FD_TO_WIN32_HANDLE (fd) != -1;
1016 { 1043 {
1017 anfds [fd].events = 0; 1044 anfds [fd].events = 0;
1018 anfds [fd].emask = 0; 1045 anfds [fd].emask = 0;
1019 fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); 1046 fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY);
1020 } 1047 }
1048}
1049
1050/* used to prepare libev internal fd's */
1051/* this is not fork-safe */
1052inline_speed void
1053fd_intern (int fd)
1054{
1055#ifdef _WIN32
1056 unsigned long arg = 1;
1057 ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg);
1058#else
1059 fcntl (fd, F_SETFD, FD_CLOEXEC);
1060 fcntl (fd, F_SETFL, O_NONBLOCK);
1061#endif
1021} 1062}
1022 1063
1023/*****************************************************************************/ 1064/*****************************************************************************/
1024 1065
1025/* 1066/*
1179 1220
1180static ANSIG signals [EV_NSIG - 1]; 1221static ANSIG signals [EV_NSIG - 1];
1181 1222
1182/*****************************************************************************/ 1223/*****************************************************************************/
1183 1224
1184/* used to prepare libev internal fd's */ 1225#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1185/* this is not fork-safe */
1186inline_speed void
1187fd_intern (int fd)
1188{
1189#ifdef _WIN32
1190 unsigned long arg = 1;
1191 ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg);
1192#else
1193 fcntl (fd, F_SETFD, FD_CLOEXEC);
1194 fcntl (fd, F_SETFL, O_NONBLOCK);
1195#endif
1196}
1197 1226
1198static void noinline 1227static void noinline
1199evpipe_init (EV_P) 1228evpipe_init (EV_P)
1200{ 1229{
1201 if (!ev_is_active (&pipe_w)) 1230 if (!ev_is_active (&pipe_w))
1202 { 1231 {
1203#if EV_USE_EVENTFD 1232# if EV_USE_EVENTFD
1204 evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); 1233 evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
1205 if (evfd < 0 && errno == EINVAL) 1234 if (evfd < 0 && errno == EINVAL)
1206 evfd = eventfd (0, 0); 1235 evfd = eventfd (0, 0);
1207 1236
1208 if (evfd >= 0) 1237 if (evfd >= 0)
1210 evpipe [0] = -1; 1239 evpipe [0] = -1;
1211 fd_intern (evfd); /* doing it twice doesn't hurt */ 1240 fd_intern (evfd); /* doing it twice doesn't hurt */
1212 ev_io_set (&pipe_w, evfd, EV_READ); 1241 ev_io_set (&pipe_w, evfd, EV_READ);
1213 } 1242 }
1214 else 1243 else
1215#endif 1244# endif
1216 { 1245 {
1217 while (pipe (evpipe)) 1246 while (pipe (evpipe))
1218 ev_syserr ("(libev) error creating signal/async pipe"); 1247 ev_syserr ("(libev) error creating signal/async pipe");
1219 1248
1220 fd_intern (evpipe [0]); 1249 fd_intern (evpipe [0]);
1231evpipe_write (EV_P_ EV_ATOMIC_T *flag) 1260evpipe_write (EV_P_ EV_ATOMIC_T *flag)
1232{ 1261{
1233 if (!*flag) 1262 if (!*flag)
1234 { 1263 {
1235 int old_errno = errno; /* save errno because write might clobber it */ 1264 int old_errno = errno; /* save errno because write might clobber it */
1265 char dummy;
1236 1266
1237 *flag = 1; 1267 *flag = 1;
1238 1268
1239#if EV_USE_EVENTFD 1269#if EV_USE_EVENTFD
1240 if (evfd >= 0) 1270 if (evfd >= 0)
1242 uint64_t counter = 1; 1272 uint64_t counter = 1;
1243 write (evfd, &counter, sizeof (uint64_t)); 1273 write (evfd, &counter, sizeof (uint64_t));
1244 } 1274 }
1245 else 1275 else
1246#endif 1276#endif
1247 write (evpipe [1], &old_errno, 1); 1277 write (evpipe [1], &dummy, 1);
1248 1278
1249 errno = old_errno; 1279 errno = old_errno;
1250 } 1280 }
1251} 1281}
1252 1282
1353 break; 1383 break;
1354 } 1384 }
1355} 1385}
1356#endif 1386#endif
1357 1387
1388#endif
1389
1358/*****************************************************************************/ 1390/*****************************************************************************/
1359 1391
1392#if EV_CHILD_ENABLE
1360static WL childs [EV_PID_HASHSIZE]; 1393static WL childs [EV_PID_HASHSIZE];
1361
1362#ifndef _WIN32
1363 1394
1364static ev_signal childev; 1395static ev_signal childev;
1365 1396
1366#ifndef WIFCONTINUED 1397#ifndef WIFCONTINUED
1367# define WIFCONTINUED(status) 0 1398# define WIFCONTINUED(status) 0
1636 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); 1667 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags);
1637#endif 1668#endif
1638 1669
1639 ev_prepare_init (&pending_w, pendingcb); 1670 ev_prepare_init (&pending_w, pendingcb);
1640 1671
1672#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1641 ev_init (&pipe_w, pipecb); 1673 ev_init (&pipe_w, pipecb);
1642 ev_set_priority (&pipe_w, EV_MAXPRI); 1674 ev_set_priority (&pipe_w, EV_MAXPRI);
1675#endif
1643 } 1676 }
1644} 1677}
1645 1678
1646/* free up a loop structure */ 1679/* free up a loop structure */
1647static void noinline 1680static void noinline
1765 { 1798 {
1766 EV_WIN32_CLOSE_FD (evpipe [0]); 1799 EV_WIN32_CLOSE_FD (evpipe [0]);
1767 EV_WIN32_CLOSE_FD (evpipe [1]); 1800 EV_WIN32_CLOSE_FD (evpipe [1]);
1768 } 1801 }
1769 1802
1803#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1770 evpipe_init (EV_A); 1804 evpipe_init (EV_A);
1771 /* now iterate over everything, in case we missed something */ 1805 /* now iterate over everything, in case we missed something */
1772 pipecb (EV_A_ &pipe_w, EV_READ); 1806 pipecb (EV_A_ &pipe_w, EV_READ);
1807#endif
1773 } 1808 }
1774 1809
1775 postfork = 0; 1810 postfork = 0;
1776} 1811}
1777 1812
1890#if EV_ASYNC_ENABLE 1925#if EV_ASYNC_ENABLE
1891 assert (asyncmax >= asynccnt); 1926 assert (asyncmax >= asynccnt);
1892 array_verify (EV_A_ (W *)asyncs, asynccnt); 1927 array_verify (EV_A_ (W *)asyncs, asynccnt);
1893#endif 1928#endif
1894 1929
1930#if EV_PREPARE_ENABLE
1895 assert (preparemax >= preparecnt); 1931 assert (preparemax >= preparecnt);
1896 array_verify (EV_A_ (W *)prepares, preparecnt); 1932 array_verify (EV_A_ (W *)prepares, preparecnt);
1933#endif
1897 1934
1935#if EV_CHECK_ENABLE
1898 assert (checkmax >= checkcnt); 1936 assert (checkmax >= checkcnt);
1899 array_verify (EV_A_ (W *)checks, checkcnt); 1937 array_verify (EV_A_ (W *)checks, checkcnt);
1938#endif
1900 1939
1901# if 0 1940# if 0
1941#if EV_CHILD_ENABLE
1902 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1942 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
1903 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) 1943 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending)
1944#endif
1904# endif 1945# endif
1905#endif 1946#endif
1906} 1947}
1907#endif 1948#endif
1908 1949
1924 1965
1925 loop_init (EV_A_ flags); 1966 loop_init (EV_A_ flags);
1926 1967
1927 if (ev_backend (EV_A)) 1968 if (ev_backend (EV_A))
1928 { 1969 {
1929#ifndef _WIN32 1970#if EV_CHILD_ENABLE
1930 ev_signal_init (&childev, childcb, SIGCHLD); 1971 ev_signal_init (&childev, childcb, SIGCHLD);
1931 ev_set_priority (&childev, EV_MAXPRI); 1972 ev_set_priority (&childev, EV_MAXPRI);
1932 ev_signal_start (EV_A_ &childev); 1973 ev_signal_start (EV_A_ &childev);
1933 ev_unref (EV_A); /* child watcher should not keep loop alive */ 1974 ev_unref (EV_A); /* child watcher should not keep loop alive */
1934#endif 1975#endif
1947 EV_P = ev_default_loop_ptr; 1988 EV_P = ev_default_loop_ptr;
1948#endif 1989#endif
1949 1990
1950 ev_default_loop_ptr = 0; 1991 ev_default_loop_ptr = 0;
1951 1992
1952#ifndef _WIN32 1993#if EV_CHILD_ENABLE
1953 ev_ref (EV_A); /* child watcher */ 1994 ev_ref (EV_A); /* child watcher */
1954 ev_signal_stop (EV_A_ &childev); 1995 ev_signal_stop (EV_A_ &childev);
1955#endif 1996#endif
1956 1997
1957 loop_destroy (EV_A); 1998 loop_destroy (EV_A);
2269 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 2310 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
2270 EV_INVOKE_PENDING; 2311 EV_INVOKE_PENDING;
2271 } 2312 }
2272#endif 2313#endif
2273 2314
2315#if EV_PREPARE_ENABLE
2274 /* queue prepare watchers (and execute them) */ 2316 /* queue prepare watchers (and execute them) */
2275 if (expect_false (preparecnt)) 2317 if (expect_false (preparecnt))
2276 { 2318 {
2277 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2319 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
2278 EV_INVOKE_PENDING; 2320 EV_INVOKE_PENDING;
2279 } 2321 }
2322#endif
2280 2323
2281 if (expect_false (loop_done)) 2324 if (expect_false (loop_done))
2282 break; 2325 break;
2283 2326
2284 /* we might have forked, so reify kernel state if necessary */ 2327 /* we might have forked, so reify kernel state if necessary */
2357#if EV_IDLE_ENABLE 2400#if EV_IDLE_ENABLE
2358 /* queue idle watchers unless other events are pending */ 2401 /* queue idle watchers unless other events are pending */
2359 idle_reify (EV_A); 2402 idle_reify (EV_A);
2360#endif 2403#endif
2361 2404
2405#if EV_CHECK_ENABLE
2362 /* queue check watchers, to be executed first */ 2406 /* queue check watchers, to be executed first */
2363 if (expect_false (checkcnt)) 2407 if (expect_false (checkcnt))
2364 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 2408 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
2409#endif
2365 2410
2366 EV_INVOKE_PENDING; 2411 EV_INVOKE_PENDING;
2367 } 2412 }
2368 while (expect_true ( 2413 while (expect_true (
2369 activecnt 2414 activecnt
2699 2744
2700#ifndef SA_RESTART 2745#ifndef SA_RESTART
2701# define SA_RESTART 0 2746# define SA_RESTART 0
2702#endif 2747#endif
2703 2748
2749#if EV_SIGNAL_ENABLE
2750
2704void noinline 2751void noinline
2705ev_signal_start (EV_P_ ev_signal *w) 2752ev_signal_start (EV_P_ ev_signal *w)
2706{ 2753{
2707 if (expect_false (ev_is_active (w))) 2754 if (expect_false (ev_is_active (w)))
2708 return; 2755 return;
2814 } 2861 }
2815 2862
2816 EV_FREQUENT_CHECK; 2863 EV_FREQUENT_CHECK;
2817} 2864}
2818 2865
2866#endif
2867
2868#if EV_CHILD_ENABLE
2869
2819void 2870void
2820ev_child_start (EV_P_ ev_child *w) 2871ev_child_start (EV_P_ ev_child *w)
2821{ 2872{
2822#if EV_MULTIPLICITY 2873#if EV_MULTIPLICITY
2823 assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); 2874 assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
2845 wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 2896 wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
2846 ev_stop (EV_A_ (W)w); 2897 ev_stop (EV_A_ (W)w);
2847 2898
2848 EV_FREQUENT_CHECK; 2899 EV_FREQUENT_CHECK;
2849} 2900}
2901
2902#endif
2850 2903
2851#if EV_STAT_ENABLE 2904#if EV_STAT_ENABLE
2852 2905
2853# ifdef _WIN32 2906# ifdef _WIN32
2854# undef lstat 2907# undef lstat
2992 infy_wd (EV_A_ ev->wd, ev->wd, ev); 3045 infy_wd (EV_A_ ev->wd, ev->wd, ev);
2993 ofs += sizeof (struct inotify_event) + ev->len; 3046 ofs += sizeof (struct inotify_event) + ev->len;
2994 } 3047 }
2995} 3048}
2996 3049
3050inline_size unsigned int
3051ev_linux_version (void)
3052{
3053 struct utsname buf;
3054 unsigned int v;
3055 int i;
3056 char *p = buf.release;
3057
3058 if (uname (&buf))
3059 return 0;
3060
3061 for (i = 3+1; --i; )
3062 {
3063 unsigned int c = 0;
3064
3065 for (;;)
3066 {
3067 if (*p >= '0' && *p <= '9')
3068 c = c * 10 + *p++ - '0';
3069 else
3070 {
3071 p += *p == '.';
3072 break;
3073 }
3074 }
3075
3076 v = (v << 8) | c;
3077 }
3078
3079 return v;
3080}
3081
2997inline_size void 3082inline_size void
2998check_2625 (EV_P) 3083ev_check_2625 (EV_P)
2999{ 3084{
3000 /* kernels < 2.6.25 are borked 3085 /* kernels < 2.6.25 are borked
3001 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html 3086 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html
3002 */ 3087 */
3003 struct utsname buf; 3088 if (ev_linux_version () < 0x020619)
3004 int major, minor, micro;
3005
3006 if (uname (&buf))
3007 return;
3008
3009 if (sscanf (buf.release, "%d.%d.%d", &major, &minor, &micro) != 3)
3010 return;
3011
3012 if (major < 2
3013 || (major == 2 && minor < 6)
3014 || (major == 2 && minor == 6 && micro < 25))
3015 return; 3089 return;
3016 3090
3017 fs_2625 = 1; 3091 fs_2625 = 1;
3018} 3092}
3019 3093
3034 if (fs_fd != -2) 3108 if (fs_fd != -2)
3035 return; 3109 return;
3036 3110
3037 fs_fd = -1; 3111 fs_fd = -1;
3038 3112
3039 check_2625 (EV_A); 3113 ev_check_2625 (EV_A);
3040 3114
3041 fs_fd = infy_newfd (); 3115 fs_fd = infy_newfd ();
3042 3116
3043 if (fs_fd >= 0) 3117 if (fs_fd >= 0)
3044 { 3118 {
3254 3328
3255 EV_FREQUENT_CHECK; 3329 EV_FREQUENT_CHECK;
3256} 3330}
3257#endif 3331#endif
3258 3332
3333#if EV_PREPARE_ENABLE
3259void 3334void
3260ev_prepare_start (EV_P_ ev_prepare *w) 3335ev_prepare_start (EV_P_ ev_prepare *w)
3261{ 3336{
3262 if (expect_false (ev_is_active (w))) 3337 if (expect_false (ev_is_active (w)))
3263 return; 3338 return;
3289 3364
3290 ev_stop (EV_A_ (W)w); 3365 ev_stop (EV_A_ (W)w);
3291 3366
3292 EV_FREQUENT_CHECK; 3367 EV_FREQUENT_CHECK;
3293} 3368}
3369#endif
3294 3370
3371#if EV_CHECK_ENABLE
3295void 3372void
3296ev_check_start (EV_P_ ev_check *w) 3373ev_check_start (EV_P_ ev_check *w)
3297{ 3374{
3298 if (expect_false (ev_is_active (w))) 3375 if (expect_false (ev_is_active (w)))
3299 return; 3376 return;
3325 3402
3326 ev_stop (EV_A_ (W)w); 3403 ev_stop (EV_A_ (W)w);
3327 3404
3328 EV_FREQUENT_CHECK; 3405 EV_FREQUENT_CHECK;
3329} 3406}
3407#endif
3330 3408
3331#if EV_EMBED_ENABLE 3409#if EV_EMBED_ENABLE
3332void noinline 3410void noinline
3333ev_embed_sweep (EV_P_ ev_embed *w) 3411ev_embed_sweep (EV_P_ ev_embed *w)
3334{ 3412{
3663 if (types & EV_ASYNC) 3741 if (types & EV_ASYNC)
3664 for (i = asynccnt; i--; ) 3742 for (i = asynccnt; i--; )
3665 cb (EV_A_ EV_ASYNC, asyncs [i]); 3743 cb (EV_A_ EV_ASYNC, asyncs [i]);
3666#endif 3744#endif
3667 3745
3746#if EV_PREPARE_ENABLE
3668 if (types & EV_PREPARE) 3747 if (types & EV_PREPARE)
3669 for (i = preparecnt; i--; ) 3748 for (i = preparecnt; i--; )
3670#if EV_EMBED_ENABLE 3749# if EV_EMBED_ENABLE
3671 if (ev_cb (prepares [i]) != embed_prepare_cb) 3750 if (ev_cb (prepares [i]) != embed_prepare_cb)
3672#endif 3751# endif
3673 cb (EV_A_ EV_PREPARE, prepares [i]); 3752 cb (EV_A_ EV_PREPARE, prepares [i]);
3753#endif
3674 3754
3755#if EV_CHECK_ENABLE
3675 if (types & EV_CHECK) 3756 if (types & EV_CHECK)
3676 for (i = checkcnt; i--; ) 3757 for (i = checkcnt; i--; )
3677 cb (EV_A_ EV_CHECK, checks [i]); 3758 cb (EV_A_ EV_CHECK, checks [i]);
3759#endif
3678 3760
3761#if EV_SIGNAL_ENABLE
3679 if (types & EV_SIGNAL) 3762 if (types & EV_SIGNAL)
3680 for (i = 0; i < EV_NSIG - 1; ++i) 3763 for (i = 0; i < EV_NSIG - 1; ++i)
3681 for (wl = signals [i].head; wl; ) 3764 for (wl = signals [i].head; wl; )
3682 { 3765 {
3683 wn = wl->next; 3766 wn = wl->next;
3684 cb (EV_A_ EV_SIGNAL, wl); 3767 cb (EV_A_ EV_SIGNAL, wl);
3685 wl = wn; 3768 wl = wn;
3686 } 3769 }
3770#endif
3687 3771
3772#if EV_CHILD_ENABLE
3688 if (types & EV_CHILD) 3773 if (types & EV_CHILD)
3689 for (i = EV_PID_HASHSIZE; i--; ) 3774 for (i = EV_PID_HASHSIZE; i--; )
3690 for (wl = childs [i]; wl; ) 3775 for (wl = childs [i]; wl; )
3691 { 3776 {
3692 wn = wl->next; 3777 wn = wl->next;
3693 cb (EV_A_ EV_CHILD, wl); 3778 cb (EV_A_ EV_CHILD, wl);
3694 wl = wn; 3779 wl = wn;
3695 } 3780 }
3781#endif
3696/* EV_STAT 0x00001000 /* stat data changed */ 3782/* EV_STAT 0x00001000 /* stat data changed */
3697/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ 3783/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */
3698} 3784}
3699#endif 3785#endif
3700 3786

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines