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

Comparing libev/ev.c (file contents):
Revision 1.334 by root, Tue Mar 9 09:00:59 2010 UTC vs.
Revision 1.341 by root, Tue Mar 16 20:48:29 2010 UTC

79# endif 79# endif
80# endif 80# endif
81 81
82# ifndef EV_USE_NANOSLEEP 82# ifndef EV_USE_NANOSLEEP
83# if HAVE_NANOSLEEP 83# if HAVE_NANOSLEEP
84# define EV_USE_NANOSLEEP 1 84# define EV_USE_NANOSLEEP EV_FEATURE_OS
85# else 85# else
86# define EV_USE_NANOSLEEP 0 86# define EV_USE_NANOSLEEP 0
87# endif 87# endif
88# endif 88# endif
89 89
90# ifndef EV_USE_SELECT 90# ifndef EV_USE_SELECT
91# if HAVE_SELECT && HAVE_SYS_SELECT_H 91# if HAVE_SELECT && HAVE_SYS_SELECT_H
92# define EV_USE_SELECT 1 92# define EV_USE_SELECT EV_FEATURE_BACKENDS
93# else 93# else
94# define EV_USE_SELECT 0 94# define EV_USE_SELECT 0
95# endif 95# endif
96# endif 96# endif
97 97
98# ifndef EV_USE_POLL 98# ifndef EV_USE_POLL
99# if HAVE_POLL && HAVE_POLL_H 99# if HAVE_POLL && HAVE_POLL_H
100# define EV_USE_POLL 1 100# define EV_USE_POLL EV_FEATURE_BACKENDS
101# else 101# else
102# define EV_USE_POLL 0 102# define EV_USE_POLL 0
103# endif 103# endif
104# endif 104# endif
105 105
106# ifndef EV_USE_EPOLL 106# ifndef EV_USE_EPOLL
107# if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H 107# if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H
108# define EV_USE_EPOLL 1 108# define EV_USE_EPOLL EV_FEATURE_BACKENDS
109# else 109# else
110# define EV_USE_EPOLL 0 110# define EV_USE_EPOLL 0
111# endif 111# endif
112# endif 112# endif
113 113
114# ifndef EV_USE_KQUEUE 114# ifndef EV_USE_KQUEUE
115# if HAVE_KQUEUE && HAVE_SYS_EVENT_H 115# if HAVE_KQUEUE && HAVE_SYS_EVENT_H
116# define EV_USE_KQUEUE 1 116# define EV_USE_KQUEUE EV_FEATURE_BACKENDS
117# else 117# else
118# define EV_USE_KQUEUE 0 118# define EV_USE_KQUEUE 0
119# endif 119# endif
120# endif 120# endif
121 121
122# ifndef EV_USE_PORT 122# ifndef EV_USE_PORT
123# if HAVE_PORT_H && HAVE_PORT_CREATE 123# if HAVE_PORT_H && HAVE_PORT_CREATE
124# define EV_USE_PORT 1 124# define EV_USE_PORT EV_FEATURE_BACKENDS
125# else 125# else
126# define EV_USE_PORT 0 126# define EV_USE_PORT 0
127# endif 127# endif
128# endif 128# endif
129 129
130# ifndef EV_USE_INOTIFY 130# ifndef EV_USE_INOTIFY
131# if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H 131# if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H
132# define EV_USE_INOTIFY 1 132# define EV_USE_INOTIFY EV_FEATURE_OS
133# else 133# else
134# define EV_USE_INOTIFY 0 134# define EV_USE_INOTIFY 0
135# endif 135# endif
136# endif 136# endif
137 137
138# ifndef EV_USE_SIGNALFD 138# ifndef EV_USE_SIGNALFD
139# if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H 139# if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H
140# define EV_USE_SIGNALFD 1 140# define EV_USE_SIGNALFD EV_FEATURE_OS
141# else 141# else
142# define EV_USE_SIGNALFD 0 142# define EV_USE_SIGNALFD 0
143# endif 143# endif
144# endif 144# endif
145 145
146# ifndef EV_USE_EVENTFD 146# ifndef EV_USE_EVENTFD
147# if HAVE_EVENTFD 147# if HAVE_EVENTFD
148# define EV_USE_EVENTFD 1 148# define EV_USE_EVENTFD EV_FEATURE_OS
149# else 149# else
150# define EV_USE_EVENTFD 0 150# define EV_USE_EVENTFD 0
151# endif 151# endif
152# endif 152# endif
153 153
207#elif defined (MAXSIG) 207#elif defined (MAXSIG)
208# define EV_NSIG (MAXSIG+1) 208# define EV_NSIG (MAXSIG+1)
209#elif defined (MAX_SIG) 209#elif defined (MAX_SIG)
210# define EV_NSIG (MAX_SIG+1) 210# define EV_NSIG (MAX_SIG+1)
211#elif defined (SIGARRAYSIZE) 211#elif defined (SIGARRAYSIZE)
212# define EV_NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */ 212# define EV_NSIG (SIGARRAYSIZE) /* Assume ary[SIGARRAYSIZE] */
213#elif defined (_sys_nsig) 213#elif defined (_sys_nsig)
214# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ 214# define EV_NSIG (_sys_nsig) /* Solaris 2.5 */
215#else 215#else
216# error "unable to find value for NSIG, please report" 216# error "unable to find value for NSIG, please report"
217/* 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! :) */
218# define EV_NSIG 65 219# define EV_NSIG 65
219#endif 220#endif
220 221
221#ifndef EV_USE_CLOCK_SYSCALL 222#ifndef EV_USE_CLOCK_SYSCALL
222# if __linux && __GLIBC__ >= 2 223# if __linux && __GLIBC__ >= 2
223# define EV_USE_CLOCK_SYSCALL 1 224# define EV_USE_CLOCK_SYSCALL EV_FEATURE_OS
224# else 225# else
225# define EV_USE_CLOCK_SYSCALL 0 226# define EV_USE_CLOCK_SYSCALL 0
226# endif 227# endif
227#endif 228#endif
228 229
229#ifndef EV_USE_MONOTONIC 230#ifndef EV_USE_MONOTONIC
230# if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 231# if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
231# define EV_USE_MONOTONIC 1 232# define EV_USE_MONOTONIC EV_FEATURE_OS
232# else 233# else
233# define EV_USE_MONOTONIC 0 234# define EV_USE_MONOTONIC 0
234# endif 235# endif
235#endif 236#endif
236 237
238# define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL 239# define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL
239#endif 240#endif
240 241
241#ifndef EV_USE_NANOSLEEP 242#ifndef EV_USE_NANOSLEEP
242# if _POSIX_C_SOURCE >= 199309L 243# if _POSIX_C_SOURCE >= 199309L
243# define EV_USE_NANOSLEEP 1 244# define EV_USE_NANOSLEEP EV_FEATURE_OS
244# else 245# else
245# define EV_USE_NANOSLEEP 0 246# define EV_USE_NANOSLEEP 0
246# endif 247# endif
247#endif 248#endif
248 249
249#ifndef EV_USE_SELECT 250#ifndef EV_USE_SELECT
250# define EV_USE_SELECT 1 251# define EV_USE_SELECT EV_FEATURE_BACKENDS
251#endif 252#endif
252 253
253#ifndef EV_USE_POLL 254#ifndef EV_USE_POLL
254# ifdef _WIN32 255# ifdef _WIN32
255# define EV_USE_POLL 0 256# define EV_USE_POLL 0
256# else 257# else
257# define EV_USE_POLL 1 258# define EV_USE_POLL EV_FEATURE_BACKENDS
258# endif 259# endif
259#endif 260#endif
260 261
261#ifndef EV_USE_EPOLL 262#ifndef EV_USE_EPOLL
262# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) 263# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4))
263# define EV_USE_EPOLL 1 264# define EV_USE_EPOLL EV_FEATURE_BACKENDS
264# else 265# else
265# define EV_USE_EPOLL 0 266# define EV_USE_EPOLL 0
266# endif 267# endif
267#endif 268#endif
268 269
274# define EV_USE_PORT 0 275# define EV_USE_PORT 0
275#endif 276#endif
276 277
277#ifndef EV_USE_INOTIFY 278#ifndef EV_USE_INOTIFY
278# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) 279# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4))
279# define EV_USE_INOTIFY 1 280# define EV_USE_INOTIFY EV_FEATURE_OS
280# else 281# else
281# define EV_USE_INOTIFY 0 282# define EV_USE_INOTIFY 0
282# endif 283# endif
283#endif 284#endif
284 285
285#ifndef EV_PID_HASHSIZE 286#ifndef EV_PID_HASHSIZE
286# if EV_MINIMAL 287# define EV_PID_HASHSIZE EV_FEATURE_DATA ? 16 : 1
287# define EV_PID_HASHSIZE 1
288# else
289# define EV_PID_HASHSIZE 16
290# endif
291#endif 288#endif
292 289
293#ifndef EV_INOTIFY_HASHSIZE 290#ifndef EV_INOTIFY_HASHSIZE
294# if EV_MINIMAL 291# define EV_INOTIFY_HASHSIZE EV_FEATURE_DATA ? 16 : 1
295# define EV_INOTIFY_HASHSIZE 1
296# else
297# define EV_INOTIFY_HASHSIZE 16
298# endif
299#endif 292#endif
300 293
301#ifndef EV_USE_EVENTFD 294#ifndef EV_USE_EVENTFD
302# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) 295# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
303# define EV_USE_EVENTFD 1 296# define EV_USE_EVENTFD EV_FEATURE_OS
304# else 297# else
305# define EV_USE_EVENTFD 0 298# define EV_USE_EVENTFD 0
306# endif 299# endif
307#endif 300#endif
308 301
309#ifndef EV_USE_SIGNALFD 302#ifndef EV_USE_SIGNALFD
310# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) 303# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
311# define EV_USE_SIGNALFD 1 304# define EV_USE_SIGNALFD EV_FEATURE_OS
312# else 305# else
313# define EV_USE_SIGNALFD 0 306# define EV_USE_SIGNALFD 0
314# endif 307# endif
315#endif 308#endif
316 309
319# define EV_USE_4HEAP 1 312# define EV_USE_4HEAP 1
320# define EV_HEAP_CACHE_AT 1 313# define EV_HEAP_CACHE_AT 1
321#endif 314#endif
322 315
323#ifndef EV_VERIFY 316#ifndef EV_VERIFY
324# define EV_VERIFY !EV_MINIMAL 317# define EV_VERIFY (EV_FEATURE_API ? 1 : 0)
325#endif 318#endif
326 319
327#ifndef EV_USE_4HEAP 320#ifndef EV_USE_4HEAP
328# define EV_USE_4HEAP !EV_MINIMAL 321# define EV_USE_4HEAP EV_FEATURE_DATA
329#endif 322#endif
330 323
331#ifndef EV_HEAP_CACHE_AT 324#ifndef EV_HEAP_CACHE_AT
332# define EV_HEAP_CACHE_AT !EV_MINIMAL 325# define EV_HEAP_CACHE_AT EV_FEATURE_DATA
333#endif 326#endif
334 327
335/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ 328/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
336/* which makes programs even slower. might work on other unices, too. */ 329/* which makes programs even slower. might work on other unices, too. */
337#if EV_USE_CLOCK_SYSCALL 330#if EV_USE_CLOCK_SYSCALL
442 435
443 436
444/**/ 437/**/
445 438
446#if EV_VERIFY >= 3 439#if EV_VERIFY >= 3
447# define EV_FREQUENT_CHECK ev_loop_verify (EV_A) 440# define EV_FREQUENT_CHECK ev_verify (EV_A)
448#else 441#else
449# define EV_FREQUENT_CHECK do { } while (0) 442# define EV_FREQUENT_CHECK do { } while (0)
450#endif 443#endif
451 444
452/* 445/*
475 468
476#define expect_false(expr) expect ((expr) != 0, 0) 469#define expect_false(expr) expect ((expr) != 0, 0)
477#define expect_true(expr) expect ((expr) != 0, 1) 470#define expect_true(expr) expect ((expr) != 0, 1)
478#define inline_size static inline 471#define inline_size static inline
479 472
480#if EV_MINIMAL 473#if EV_FEATURE_CODE
474# define inline_speed static inline
475#else
481# define inline_speed static noinline 476# define inline_speed static noinline
482#else
483# define inline_speed static inline
484#endif 477#endif
485 478
486#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) 479#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
487 480
488#if EV_MINPRI == EV_MAXPRI 481#if EV_MINPRI == EV_MAXPRI
572{ 565{
573#if __GLIBC__ 566#if __GLIBC__
574 return realloc (ptr, size); 567 return realloc (ptr, size);
575#else 568#else
576 /* some systems, notably openbsd and darwin, fail to properly 569 /* some systems, notably openbsd and darwin, fail to properly
577 * implement realloc (x, 0) (as required by both ansi c-98 and 570 * implement realloc (x, 0) (as required by both ansi c-89 and
578 * the single unix specification, so work around them here. 571 * the single unix specification, so work around them here.
579 */ 572 */
580 573
581 if (size) 574 if (size)
582 return realloc (ptr, size); 575 return realloc (ptr, size);
695 688
696 static int ev_default_loop_ptr; 689 static int ev_default_loop_ptr;
697 690
698#endif 691#endif
699 692
700#if EV_MINIMAL < 2 693#if EV_FEATURE_API
701# define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A) 694# define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A)
702# define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A) 695# define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A)
703# define EV_INVOKE_PENDING invoke_cb (EV_A) 696# define EV_INVOKE_PENDING invoke_cb (EV_A)
704#else 697#else
705# define EV_RELEASE_CB (void)0 698# define EV_RELEASE_CB (void)0
890} 883}
891 884
892/*****************************************************************************/ 885/*****************************************************************************/
893 886
894inline_speed void 887inline_speed void
895fd_event_nc (EV_P_ int fd, int revents) 888fd_event_nocheck (EV_P_ int fd, int revents)
896{ 889{
897 ANFD *anfd = anfds + fd; 890 ANFD *anfd = anfds + fd;
898 ev_io *w; 891 ev_io *w;
899 892
900 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) 893 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
912fd_event (EV_P_ int fd, int revents) 905fd_event (EV_P_ int fd, int revents)
913{ 906{
914 ANFD *anfd = anfds + fd; 907 ANFD *anfd = anfds + fd;
915 908
916 if (expect_true (!anfd->reify)) 909 if (expect_true (!anfd->reify))
917 fd_event_nc (EV_A_ fd, revents); 910 fd_event_nocheck (EV_A_ fd, revents);
918} 911}
919 912
920void 913void
921ev_feed_fd_event (EV_P_ int fd, int revents) 914ev_feed_fd_event (EV_P_ int fd, int revents)
922{ 915{
923 if (fd >= 0 && fd < anfdmax) 916 if (fd >= 0 && fd < anfdmax)
924 fd_event_nc (EV_A_ fd, revents); 917 fd_event_nocheck (EV_A_ fd, revents);
925} 918}
926 919
927/* make sure the external fd watch events are in-sync */ 920/* make sure the external fd watch events are in-sync */
928/* with the kernel/libev internal state */ 921/* with the kernel/libev internal state */
929inline_size void 922inline_size void
992 ev_io_stop (EV_A_ w); 985 ev_io_stop (EV_A_ w);
993 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); 986 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
994 } 987 }
995} 988}
996 989
997/* check whether the given fd is atcually valid, for error recovery */ 990/* check whether the given fd is actually valid, for error recovery */
998inline_size int 991inline_size int
999fd_valid (int fd) 992fd_valid (int fd)
1000{ 993{
1001#ifdef _WIN32 994#ifdef _WIN32
1002 return EV_FD_TO_WIN32_HANDLE (fd) != -1; 995 return EV_FD_TO_WIN32_HANDLE (fd) != -1;
1042 { 1035 {
1043 anfds [fd].events = 0; 1036 anfds [fd].events = 0;
1044 anfds [fd].emask = 0; 1037 anfds [fd].emask = 0;
1045 fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); 1038 fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY);
1046 } 1039 }
1040}
1041
1042/* used to prepare libev internal fd's */
1043/* this is not fork-safe */
1044inline_speed void
1045fd_intern (int fd)
1046{
1047#ifdef _WIN32
1048 unsigned long arg = 1;
1049 ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg);
1050#else
1051 fcntl (fd, F_SETFD, FD_CLOEXEC);
1052 fcntl (fd, F_SETFL, O_NONBLOCK);
1053#endif
1047} 1054}
1048 1055
1049/*****************************************************************************/ 1056/*****************************************************************************/
1050 1057
1051/* 1058/*
1205 1212
1206static ANSIG signals [EV_NSIG - 1]; 1213static ANSIG signals [EV_NSIG - 1];
1207 1214
1208/*****************************************************************************/ 1215/*****************************************************************************/
1209 1216
1210/* used to prepare libev internal fd's */ 1217#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1211/* this is not fork-safe */
1212inline_speed void
1213fd_intern (int fd)
1214{
1215#ifdef _WIN32
1216 unsigned long arg = 1;
1217 ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg);
1218#else
1219 fcntl (fd, F_SETFD, FD_CLOEXEC);
1220 fcntl (fd, F_SETFL, O_NONBLOCK);
1221#endif
1222}
1223 1218
1224static void noinline 1219static void noinline
1225evpipe_init (EV_P) 1220evpipe_init (EV_P)
1226{ 1221{
1227 if (!ev_is_active (&pipe_w)) 1222 if (!ev_is_active (&pipe_w))
1228 { 1223 {
1229#if EV_USE_EVENTFD 1224# if EV_USE_EVENTFD
1230 evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); 1225 evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC);
1231 if (evfd < 0 && errno == EINVAL) 1226 if (evfd < 0 && errno == EINVAL)
1232 evfd = eventfd (0, 0); 1227 evfd = eventfd (0, 0);
1233 1228
1234 if (evfd >= 0) 1229 if (evfd >= 0)
1236 evpipe [0] = -1; 1231 evpipe [0] = -1;
1237 fd_intern (evfd); /* doing it twice doesn't hurt */ 1232 fd_intern (evfd); /* doing it twice doesn't hurt */
1238 ev_io_set (&pipe_w, evfd, EV_READ); 1233 ev_io_set (&pipe_w, evfd, EV_READ);
1239 } 1234 }
1240 else 1235 else
1241#endif 1236# endif
1242 { 1237 {
1243 while (pipe (evpipe)) 1238 while (pipe (evpipe))
1244 ev_syserr ("(libev) error creating signal/async pipe"); 1239 ev_syserr ("(libev) error creating signal/async pipe");
1245 1240
1246 fd_intern (evpipe [0]); 1241 fd_intern (evpipe [0]);
1257evpipe_write (EV_P_ EV_ATOMIC_T *flag) 1252evpipe_write (EV_P_ EV_ATOMIC_T *flag)
1258{ 1253{
1259 if (!*flag) 1254 if (!*flag)
1260 { 1255 {
1261 int old_errno = errno; /* save errno because write might clobber it */ 1256 int old_errno = errno; /* save errno because write might clobber it */
1257 char dummy;
1262 1258
1263 *flag = 1; 1259 *flag = 1;
1264 1260
1265#if EV_USE_EVENTFD 1261#if EV_USE_EVENTFD
1266 if (evfd >= 0) 1262 if (evfd >= 0)
1268 uint64_t counter = 1; 1264 uint64_t counter = 1;
1269 write (evfd, &counter, sizeof (uint64_t)); 1265 write (evfd, &counter, sizeof (uint64_t));
1270 } 1266 }
1271 else 1267 else
1272#endif 1268#endif
1273 write (evpipe [1], &old_errno, 1); 1269 write (evpipe [1], &dummy, 1);
1274 1270
1275 errno = old_errno; 1271 errno = old_errno;
1276 } 1272 }
1277} 1273}
1278 1274
1379 break; 1375 break;
1380 } 1376 }
1381} 1377}
1382#endif 1378#endif
1383 1379
1380#endif
1381
1384/*****************************************************************************/ 1382/*****************************************************************************/
1385 1383
1384#if EV_CHILD_ENABLE
1386static WL childs [EV_PID_HASHSIZE]; 1385static WL childs [EV_PID_HASHSIZE];
1387
1388#ifndef _WIN32
1389 1386
1390static ev_signal childev; 1387static ev_signal childev;
1391 1388
1392#ifndef WIFCONTINUED 1389#ifndef WIFCONTINUED
1393# define WIFCONTINUED(status) 0 1390# define WIFCONTINUED(status) 0
1398child_reap (EV_P_ int chain, int pid, int status) 1395child_reap (EV_P_ int chain, int pid, int status)
1399{ 1396{
1400 ev_child *w; 1397 ev_child *w;
1401 int traced = WIFSTOPPED (status) || WIFCONTINUED (status); 1398 int traced = WIFSTOPPED (status) || WIFCONTINUED (status);
1402 1399
1403 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1400 for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next)
1404 { 1401 {
1405 if ((w->pid == pid || !w->pid) 1402 if ((w->pid == pid || !w->pid)
1406 && (!traced || (w->flags & 1))) 1403 && (!traced || (w->flags & 1)))
1407 { 1404 {
1408 ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */ 1405 ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */
1433 /* make sure we are called again until all children have been reaped */ 1430 /* make sure we are called again until all children have been reaped */
1434 /* we need to do it this way so that the callback gets called before we continue */ 1431 /* we need to do it this way so that the callback gets called before we continue */
1435 ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); 1432 ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
1436 1433
1437 child_reap (EV_A_ pid, pid, status); 1434 child_reap (EV_A_ pid, pid, status);
1438 if (EV_PID_HASHSIZE > 1) 1435 if ((EV_PID_HASHSIZE) > 1)
1439 child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ 1436 child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */
1440} 1437}
1441 1438
1442#endif 1439#endif
1443 1440
1532ev_backend (EV_P) 1529ev_backend (EV_P)
1533{ 1530{
1534 return backend; 1531 return backend;
1535} 1532}
1536 1533
1537#if EV_MINIMAL < 2 1534#if EV_FEATURE_API
1538unsigned int 1535unsigned int
1539ev_loop_count (EV_P) 1536ev_iteration (EV_P)
1540{ 1537{
1541 return loop_count; 1538 return loop_count;
1542} 1539}
1543 1540
1544unsigned int 1541unsigned int
1545ev_loop_depth (EV_P) 1542ev_depth (EV_P)
1546{ 1543{
1547 return loop_depth; 1544 return loop_depth;
1548} 1545}
1549 1546
1550void 1547void
1622 1619
1623 ev_rt_now = ev_time (); 1620 ev_rt_now = ev_time ();
1624 mn_now = get_clock (); 1621 mn_now = get_clock ();
1625 now_floor = mn_now; 1622 now_floor = mn_now;
1626 rtmn_diff = ev_rt_now - mn_now; 1623 rtmn_diff = ev_rt_now - mn_now;
1627#if EV_MINIMAL < 2 1624#if EV_FEATURE_API
1628 invoke_cb = ev_invoke_pending; 1625 invoke_cb = ev_invoke_pending;
1629#endif 1626#endif
1630 1627
1631 io_blocktime = 0.; 1628 io_blocktime = 0.;
1632 timeout_blocktime = 0.; 1629 timeout_blocktime = 0.;
1662 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); 1659 if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags);
1663#endif 1660#endif
1664 1661
1665 ev_prepare_init (&pending_w, pendingcb); 1662 ev_prepare_init (&pending_w, pendingcb);
1666 1663
1664#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1667 ev_init (&pipe_w, pipecb); 1665 ev_init (&pipe_w, pipecb);
1668 ev_set_priority (&pipe_w, EV_MAXPRI); 1666 ev_set_priority (&pipe_w, EV_MAXPRI);
1667#endif
1669 } 1668 }
1670} 1669}
1671 1670
1672/* free up a loop structure */ 1671/* free up a loop structure */
1673static void noinline 1672static void noinline
1791 { 1790 {
1792 EV_WIN32_CLOSE_FD (evpipe [0]); 1791 EV_WIN32_CLOSE_FD (evpipe [0]);
1793 EV_WIN32_CLOSE_FD (evpipe [1]); 1792 EV_WIN32_CLOSE_FD (evpipe [1]);
1794 } 1793 }
1795 1794
1795#if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE
1796 evpipe_init (EV_A); 1796 evpipe_init (EV_A);
1797 /* now iterate over everything, in case we missed something */ 1797 /* now iterate over everything, in case we missed something */
1798 pipecb (EV_A_ &pipe_w, EV_READ); 1798 pipecb (EV_A_ &pipe_w, EV_READ);
1799#endif
1799 } 1800 }
1800 1801
1801 postfork = 0; 1802 postfork = 0;
1802} 1803}
1803 1804
1865 verify_watcher (EV_A_ ws [cnt]); 1866 verify_watcher (EV_A_ ws [cnt]);
1866 } 1867 }
1867} 1868}
1868#endif 1869#endif
1869 1870
1870#if EV_MINIMAL < 2 1871#if EV_FEATURE_API
1871void 1872void
1872ev_loop_verify (EV_P) 1873ev_verify (EV_P)
1873{ 1874{
1874#if EV_VERIFY 1875#if EV_VERIFY
1875 int i; 1876 int i;
1876 WL w; 1877 WL w;
1877 1878
1916#if EV_ASYNC_ENABLE 1917#if EV_ASYNC_ENABLE
1917 assert (asyncmax >= asynccnt); 1918 assert (asyncmax >= asynccnt);
1918 array_verify (EV_A_ (W *)asyncs, asynccnt); 1919 array_verify (EV_A_ (W *)asyncs, asynccnt);
1919#endif 1920#endif
1920 1921
1922#if EV_PREPARE_ENABLE
1921 assert (preparemax >= preparecnt); 1923 assert (preparemax >= preparecnt);
1922 array_verify (EV_A_ (W *)prepares, preparecnt); 1924 array_verify (EV_A_ (W *)prepares, preparecnt);
1925#endif
1923 1926
1927#if EV_CHECK_ENABLE
1924 assert (checkmax >= checkcnt); 1928 assert (checkmax >= checkcnt);
1925 array_verify (EV_A_ (W *)checks, checkcnt); 1929 array_verify (EV_A_ (W *)checks, checkcnt);
1930#endif
1926 1931
1927# if 0 1932# if 0
1933#if EV_CHILD_ENABLE
1928 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1934 for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next)
1929 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) 1935 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending)
1936#endif
1930# endif 1937# endif
1931#endif 1938#endif
1932} 1939}
1933#endif 1940#endif
1934 1941
1950 1957
1951 loop_init (EV_A_ flags); 1958 loop_init (EV_A_ flags);
1952 1959
1953 if (ev_backend (EV_A)) 1960 if (ev_backend (EV_A))
1954 { 1961 {
1955#ifndef _WIN32 1962#if EV_CHILD_ENABLE
1956 ev_signal_init (&childev, childcb, SIGCHLD); 1963 ev_signal_init (&childev, childcb, SIGCHLD);
1957 ev_set_priority (&childev, EV_MAXPRI); 1964 ev_set_priority (&childev, EV_MAXPRI);
1958 ev_signal_start (EV_A_ &childev); 1965 ev_signal_start (EV_A_ &childev);
1959 ev_unref (EV_A); /* child watcher should not keep loop alive */ 1966 ev_unref (EV_A); /* child watcher should not keep loop alive */
1960#endif 1967#endif
1973 EV_P = ev_default_loop_ptr; 1980 EV_P = ev_default_loop_ptr;
1974#endif 1981#endif
1975 1982
1976 ev_default_loop_ptr = 0; 1983 ev_default_loop_ptr = 0;
1977 1984
1978#ifndef _WIN32 1985#if EV_CHILD_ENABLE
1979 ev_ref (EV_A); /* child watcher */ 1986 ev_ref (EV_A); /* child watcher */
1980 ev_signal_stop (EV_A_ &childev); 1987 ev_signal_stop (EV_A_ &childev);
1981#endif 1988#endif
1982 1989
1983 loop_destroy (EV_A); 1990 loop_destroy (EV_A);
2089 EV_FREQUENT_CHECK; 2096 EV_FREQUENT_CHECK;
2090 feed_reverse (EV_A_ (W)w); 2097 feed_reverse (EV_A_ (W)w);
2091 } 2098 }
2092 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); 2099 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now);
2093 2100
2094 feed_reverse_done (EV_A_ EV_TIMEOUT); 2101 feed_reverse_done (EV_A_ EV_TIMER);
2095 } 2102 }
2096} 2103}
2097 2104
2098#if EV_PERIODIC_ENABLE 2105#if EV_PERIODIC_ENABLE
2099/* make periodics pending */ 2106/* make periodics pending */
2260} 2267}
2261 2268
2262void 2269void
2263ev_loop (EV_P_ int flags) 2270ev_loop (EV_P_ int flags)
2264{ 2271{
2265#if EV_MINIMAL < 2 2272#if EV_FEATURE_API
2266 ++loop_depth; 2273 ++loop_depth;
2267#endif 2274#endif
2268 2275
2269 assert (("libev: ev_loop recursion during release detected", loop_done != EVUNLOOP_RECURSE)); 2276 assert (("libev: ev_loop recursion during release detected", loop_done != EVUNLOOP_RECURSE));
2270 2277
2273 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ 2280 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */
2274 2281
2275 do 2282 do
2276 { 2283 {
2277#if EV_VERIFY >= 2 2284#if EV_VERIFY >= 2
2278 ev_loop_verify (EV_A); 2285 ev_verify (EV_A);
2279#endif 2286#endif
2280 2287
2281#ifndef _WIN32 2288#ifndef _WIN32
2282 if (expect_false (curpid)) /* penalise the forking check even more */ 2289 if (expect_false (curpid)) /* penalise the forking check even more */
2283 if (expect_false (getpid () != curpid)) 2290 if (expect_false (getpid () != curpid))
2295 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 2302 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
2296 EV_INVOKE_PENDING; 2303 EV_INVOKE_PENDING;
2297 } 2304 }
2298#endif 2305#endif
2299 2306
2307#if EV_PREPARE_ENABLE
2300 /* queue prepare watchers (and execute them) */ 2308 /* queue prepare watchers (and execute them) */
2301 if (expect_false (preparecnt)) 2309 if (expect_false (preparecnt))
2302 { 2310 {
2303 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2311 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
2304 EV_INVOKE_PENDING; 2312 EV_INVOKE_PENDING;
2305 } 2313 }
2314#endif
2306 2315
2307 if (expect_false (loop_done)) 2316 if (expect_false (loop_done))
2308 break; 2317 break;
2309 2318
2310 /* we might have forked, so reify kernel state if necessary */ 2319 /* we might have forked, so reify kernel state if necessary */
2361 waittime -= sleeptime; 2370 waittime -= sleeptime;
2362 } 2371 }
2363 } 2372 }
2364 } 2373 }
2365 2374
2366#if EV_MINIMAL < 2 2375#if EV_FEATURE_API
2367 ++loop_count; 2376 ++loop_count;
2368#endif 2377#endif
2369 assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */ 2378 assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */
2370 backend_poll (EV_A_ waittime); 2379 backend_poll (EV_A_ waittime);
2371 assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */ 2380 assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */
2383#if EV_IDLE_ENABLE 2392#if EV_IDLE_ENABLE
2384 /* queue idle watchers unless other events are pending */ 2393 /* queue idle watchers unless other events are pending */
2385 idle_reify (EV_A); 2394 idle_reify (EV_A);
2386#endif 2395#endif
2387 2396
2397#if EV_CHECK_ENABLE
2388 /* queue check watchers, to be executed first */ 2398 /* queue check watchers, to be executed first */
2389 if (expect_false (checkcnt)) 2399 if (expect_false (checkcnt))
2390 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 2400 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
2401#endif
2391 2402
2392 EV_INVOKE_PENDING; 2403 EV_INVOKE_PENDING;
2393 } 2404 }
2394 while (expect_true ( 2405 while (expect_true (
2395 activecnt 2406 activecnt
2398 )); 2409 ));
2399 2410
2400 if (loop_done == EVUNLOOP_ONE) 2411 if (loop_done == EVUNLOOP_ONE)
2401 loop_done = EVUNLOOP_CANCEL; 2412 loop_done = EVUNLOOP_CANCEL;
2402 2413
2403#if EV_MINIMAL < 2 2414#if EV_FEATURE_API
2404 --loop_depth; 2415 --loop_depth;
2405#endif 2416#endif
2406} 2417}
2407 2418
2408void 2419void
2725 2736
2726#ifndef SA_RESTART 2737#ifndef SA_RESTART
2727# define SA_RESTART 0 2738# define SA_RESTART 0
2728#endif 2739#endif
2729 2740
2741#if EV_SIGNAL_ENABLE
2742
2730void noinline 2743void noinline
2731ev_signal_start (EV_P_ ev_signal *w) 2744ev_signal_start (EV_P_ ev_signal *w)
2732{ 2745{
2733 if (expect_false (ev_is_active (w))) 2746 if (expect_false (ev_is_active (w)))
2734 return; 2747 return;
2840 } 2853 }
2841 2854
2842 EV_FREQUENT_CHECK; 2855 EV_FREQUENT_CHECK;
2843} 2856}
2844 2857
2858#endif
2859
2860#if EV_CHILD_ENABLE
2861
2845void 2862void
2846ev_child_start (EV_P_ ev_child *w) 2863ev_child_start (EV_P_ ev_child *w)
2847{ 2864{
2848#if EV_MULTIPLICITY 2865#if EV_MULTIPLICITY
2849 assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); 2866 assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
2852 return; 2869 return;
2853 2870
2854 EV_FREQUENT_CHECK; 2871 EV_FREQUENT_CHECK;
2855 2872
2856 ev_start (EV_A_ (W)w, 1); 2873 ev_start (EV_A_ (W)w, 1);
2857 wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 2874 wlist_add (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w);
2858 2875
2859 EV_FREQUENT_CHECK; 2876 EV_FREQUENT_CHECK;
2860} 2877}
2861 2878
2862void 2879void
2866 if (expect_false (!ev_is_active (w))) 2883 if (expect_false (!ev_is_active (w)))
2867 return; 2884 return;
2868 2885
2869 EV_FREQUENT_CHECK; 2886 EV_FREQUENT_CHECK;
2870 2887
2871 wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); 2888 wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w);
2872 ev_stop (EV_A_ (W)w); 2889 ev_stop (EV_A_ (W)w);
2873 2890
2874 EV_FREQUENT_CHECK; 2891 EV_FREQUENT_CHECK;
2875} 2892}
2893
2894#endif
2876 2895
2877#if EV_STAT_ENABLE 2896#if EV_STAT_ENABLE
2878 2897
2879# ifdef _WIN32 2898# ifdef _WIN32
2880# undef lstat 2899# undef lstat
2947 while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); 2966 while (w->wd < 0 && (errno == ENOENT || errno == EACCES));
2948 } 2967 }
2949 } 2968 }
2950 2969
2951 if (w->wd >= 0) 2970 if (w->wd >= 0)
2952 wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); 2971 wlist_add (&fs_hash [w->wd & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w);
2953 2972
2954 /* now re-arm timer, if required */ 2973 /* now re-arm timer, if required */
2955 if (ev_is_active (&w->timer)) ev_ref (EV_A); 2974 if (ev_is_active (&w->timer)) ev_ref (EV_A);
2956 ev_timer_again (EV_A_ &w->timer); 2975 ev_timer_again (EV_A_ &w->timer);
2957 if (ev_is_active (&w->timer)) ev_unref (EV_A); 2976 if (ev_is_active (&w->timer)) ev_unref (EV_A);
2965 2984
2966 if (wd < 0) 2985 if (wd < 0)
2967 return; 2986 return;
2968 2987
2969 w->wd = -2; 2988 w->wd = -2;
2970 slot = wd & (EV_INOTIFY_HASHSIZE - 1); 2989 slot = wd & ((EV_INOTIFY_HASHSIZE) - 1);
2971 wlist_del (&fs_hash [slot].head, (WL)w); 2990 wlist_del (&fs_hash [slot].head, (WL)w);
2972 2991
2973 /* remove this watcher, if others are watching it, they will rearm */ 2992 /* remove this watcher, if others are watching it, they will rearm */
2974 inotify_rm_watch (fs_fd, wd); 2993 inotify_rm_watch (fs_fd, wd);
2975} 2994}
2977static void noinline 2996static void noinline
2978infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) 2997infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev)
2979{ 2998{
2980 if (slot < 0) 2999 if (slot < 0)
2981 /* overflow, need to check for all hash slots */ 3000 /* overflow, need to check for all hash slots */
2982 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) 3001 for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot)
2983 infy_wd (EV_A_ slot, wd, ev); 3002 infy_wd (EV_A_ slot, wd, ev);
2984 else 3003 else
2985 { 3004 {
2986 WL w_; 3005 WL w_;
2987 3006
2988 for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; ) 3007 for (w_ = fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head; w_; )
2989 { 3008 {
2990 ev_stat *w = (ev_stat *)w_; 3009 ev_stat *w = (ev_stat *)w_;
2991 w_ = w_->next; /* lets us remove this watcher and all before it */ 3010 w_ = w_->next; /* lets us remove this watcher and all before it */
2992 3011
2993 if (w->wd == wd || wd == -1) 3012 if (w->wd == wd || wd == -1)
2994 { 3013 {
2995 if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) 3014 if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF))
2996 { 3015 {
2997 wlist_del (&fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); 3016 wlist_del (&fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w);
2998 w->wd = -1; 3017 w->wd = -1;
2999 infy_add (EV_A_ w); /* re-add, no matter what */ 3018 infy_add (EV_A_ w); /* re-add, no matter what */
3000 } 3019 }
3001 3020
3002 stat_timer_cb (EV_A_ &w->timer, 0); 3021 stat_timer_cb (EV_A_ &w->timer, 0);
3116 ev_io_set (&fs_w, fs_fd, EV_READ); 3135 ev_io_set (&fs_w, fs_fd, EV_READ);
3117 ev_io_start (EV_A_ &fs_w); 3136 ev_io_start (EV_A_ &fs_w);
3118 ev_unref (EV_A); 3137 ev_unref (EV_A);
3119 } 3138 }
3120 3139
3121 for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) 3140 for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot)
3122 { 3141 {
3123 WL w_ = fs_hash [slot].head; 3142 WL w_ = fs_hash [slot].head;
3124 fs_hash [slot].head = 0; 3143 fs_hash [slot].head = 0;
3125 3144
3126 while (w_) 3145 while (w_)
3301 3320
3302 EV_FREQUENT_CHECK; 3321 EV_FREQUENT_CHECK;
3303} 3322}
3304#endif 3323#endif
3305 3324
3325#if EV_PREPARE_ENABLE
3306void 3326void
3307ev_prepare_start (EV_P_ ev_prepare *w) 3327ev_prepare_start (EV_P_ ev_prepare *w)
3308{ 3328{
3309 if (expect_false (ev_is_active (w))) 3329 if (expect_false (ev_is_active (w)))
3310 return; 3330 return;
3336 3356
3337 ev_stop (EV_A_ (W)w); 3357 ev_stop (EV_A_ (W)w);
3338 3358
3339 EV_FREQUENT_CHECK; 3359 EV_FREQUENT_CHECK;
3340} 3360}
3361#endif
3341 3362
3363#if EV_CHECK_ENABLE
3342void 3364void
3343ev_check_start (EV_P_ ev_check *w) 3365ev_check_start (EV_P_ ev_check *w)
3344{ 3366{
3345 if (expect_false (ev_is_active (w))) 3367 if (expect_false (ev_is_active (w)))
3346 return; 3368 return;
3372 3394
3373 ev_stop (EV_A_ (W)w); 3395 ev_stop (EV_A_ (W)w);
3374 3396
3375 EV_FREQUENT_CHECK; 3397 EV_FREQUENT_CHECK;
3376} 3398}
3399#endif
3377 3400
3378#if EV_EMBED_ENABLE 3401#if EV_EMBED_ENABLE
3379void noinline 3402void noinline
3380ev_embed_sweep (EV_P_ ev_embed *w) 3403ev_embed_sweep (EV_P_ ev_embed *w)
3381{ 3404{
3613{ 3636{
3614 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); 3637 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
3615 3638
3616 if (expect_false (!once)) 3639 if (expect_false (!once))
3617 { 3640 {
3618 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); 3641 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMER, arg);
3619 return; 3642 return;
3620 } 3643 }
3621 3644
3622 once->cb = cb; 3645 once->cb = cb;
3623 once->arg = arg; 3646 once->arg = arg;
3710 if (types & EV_ASYNC) 3733 if (types & EV_ASYNC)
3711 for (i = asynccnt; i--; ) 3734 for (i = asynccnt; i--; )
3712 cb (EV_A_ EV_ASYNC, asyncs [i]); 3735 cb (EV_A_ EV_ASYNC, asyncs [i]);
3713#endif 3736#endif
3714 3737
3738#if EV_PREPARE_ENABLE
3715 if (types & EV_PREPARE) 3739 if (types & EV_PREPARE)
3716 for (i = preparecnt; i--; ) 3740 for (i = preparecnt; i--; )
3717#if EV_EMBED_ENABLE 3741# if EV_EMBED_ENABLE
3718 if (ev_cb (prepares [i]) != embed_prepare_cb) 3742 if (ev_cb (prepares [i]) != embed_prepare_cb)
3719#endif 3743# endif
3720 cb (EV_A_ EV_PREPARE, prepares [i]); 3744 cb (EV_A_ EV_PREPARE, prepares [i]);
3745#endif
3721 3746
3747#if EV_CHECK_ENABLE
3722 if (types & EV_CHECK) 3748 if (types & EV_CHECK)
3723 for (i = checkcnt; i--; ) 3749 for (i = checkcnt; i--; )
3724 cb (EV_A_ EV_CHECK, checks [i]); 3750 cb (EV_A_ EV_CHECK, checks [i]);
3751#endif
3725 3752
3753#if EV_SIGNAL_ENABLE
3726 if (types & EV_SIGNAL) 3754 if (types & EV_SIGNAL)
3727 for (i = 0; i < EV_NSIG - 1; ++i) 3755 for (i = 0; i < EV_NSIG - 1; ++i)
3728 for (wl = signals [i].head; wl; ) 3756 for (wl = signals [i].head; wl; )
3729 { 3757 {
3730 wn = wl->next; 3758 wn = wl->next;
3731 cb (EV_A_ EV_SIGNAL, wl); 3759 cb (EV_A_ EV_SIGNAL, wl);
3732 wl = wn; 3760 wl = wn;
3733 } 3761 }
3762#endif
3734 3763
3764#if EV_CHILD_ENABLE
3735 if (types & EV_CHILD) 3765 if (types & EV_CHILD)
3736 for (i = EV_PID_HASHSIZE; i--; ) 3766 for (i = (EV_PID_HASHSIZE); i--; )
3737 for (wl = childs [i]; wl; ) 3767 for (wl = childs [i]; wl; )
3738 { 3768 {
3739 wn = wl->next; 3769 wn = wl->next;
3740 cb (EV_A_ EV_CHILD, wl); 3770 cb (EV_A_ EV_CHILD, wl);
3741 wl = wn; 3771 wl = wn;
3742 } 3772 }
3773#endif
3743/* EV_STAT 0x00001000 /* stat data changed */ 3774/* EV_STAT 0x00001000 /* stat data changed */
3744/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ 3775/* EV_EMBED 0x00010000 /* embedded event loop needs sweep */
3745} 3776}
3746#endif 3777#endif
3747 3778

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines