… | |
… | |
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 |
… | |
… | |
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 |
… | |
… | |
568 | } |
561 | } |
569 | |
562 | |
570 | static void * |
563 | static void * |
571 | ev_realloc_emul (void *ptr, long size) |
564 | ev_realloc_emul (void *ptr, long size) |
572 | { |
565 | { |
|
|
566 | #if __GLIBC__ |
|
|
567 | return realloc (ptr, size); |
|
|
568 | #else |
573 | /* some systems, notably openbsd and darwin, fail to properly |
569 | /* some systems, notably openbsd and darwin, fail to properly |
574 | * 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 |
575 | * the single unix specification, so work around them here. |
571 | * the single unix specification, so work around them here. |
576 | */ |
572 | */ |
577 | |
573 | |
578 | if (size) |
574 | if (size) |
579 | return realloc (ptr, size); |
575 | return realloc (ptr, size); |
580 | |
576 | |
581 | free (ptr); |
577 | free (ptr); |
582 | return 0; |
578 | return 0; |
|
|
579 | #endif |
583 | } |
580 | } |
584 | |
581 | |
585 | static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; |
582 | static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; |
586 | |
583 | |
587 | void |
584 | void |
… | |
… | |
691 | |
688 | |
692 | static int ev_default_loop_ptr; |
689 | static int ev_default_loop_ptr; |
693 | |
690 | |
694 | #endif |
691 | #endif |
695 | |
692 | |
696 | #if EV_MINIMAL < 2 |
693 | #if EV_FEATURE_API |
697 | # 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) |
698 | # 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) |
699 | # define EV_INVOKE_PENDING invoke_cb (EV_A) |
696 | # define EV_INVOKE_PENDING invoke_cb (EV_A) |
700 | #else |
697 | #else |
701 | # define EV_RELEASE_CB (void)0 |
698 | # define EV_RELEASE_CB (void)0 |
… | |
… | |
886 | } |
883 | } |
887 | |
884 | |
888 | /*****************************************************************************/ |
885 | /*****************************************************************************/ |
889 | |
886 | |
890 | inline_speed void |
887 | inline_speed void |
891 | fd_event_nc (EV_P_ int fd, int revents) |
888 | fd_event_nocheck (EV_P_ int fd, int revents) |
892 | { |
889 | { |
893 | ANFD *anfd = anfds + fd; |
890 | ANFD *anfd = anfds + fd; |
894 | ev_io *w; |
891 | ev_io *w; |
895 | |
892 | |
896 | 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) |
… | |
… | |
908 | fd_event (EV_P_ int fd, int revents) |
905 | fd_event (EV_P_ int fd, int revents) |
909 | { |
906 | { |
910 | ANFD *anfd = anfds + fd; |
907 | ANFD *anfd = anfds + fd; |
911 | |
908 | |
912 | if (expect_true (!anfd->reify)) |
909 | if (expect_true (!anfd->reify)) |
913 | fd_event_nc (EV_A_ fd, revents); |
910 | fd_event_nocheck (EV_A_ fd, revents); |
914 | } |
911 | } |
915 | |
912 | |
916 | void |
913 | void |
917 | ev_feed_fd_event (EV_P_ int fd, int revents) |
914 | ev_feed_fd_event (EV_P_ int fd, int revents) |
918 | { |
915 | { |
919 | if (fd >= 0 && fd < anfdmax) |
916 | if (fd >= 0 && fd < anfdmax) |
920 | fd_event_nc (EV_A_ fd, revents); |
917 | fd_event_nocheck (EV_A_ fd, revents); |
921 | } |
918 | } |
922 | |
919 | |
923 | /* make sure the external fd watch events are in-sync */ |
920 | /* make sure the external fd watch events are in-sync */ |
924 | /* with the kernel/libev internal state */ |
921 | /* with the kernel/libev internal state */ |
925 | inline_size void |
922 | inline_size void |
… | |
… | |
988 | ev_io_stop (EV_A_ w); |
985 | ev_io_stop (EV_A_ w); |
989 | 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); |
990 | } |
987 | } |
991 | } |
988 | } |
992 | |
989 | |
993 | /* check whether the given fd is atcually valid, for error recovery */ |
990 | /* check whether the given fd is actually valid, for error recovery */ |
994 | inline_size int |
991 | inline_size int |
995 | fd_valid (int fd) |
992 | fd_valid (int fd) |
996 | { |
993 | { |
997 | #ifdef _WIN32 |
994 | #ifdef _WIN32 |
998 | return EV_FD_TO_WIN32_HANDLE (fd) != -1; |
995 | return EV_FD_TO_WIN32_HANDLE (fd) != -1; |
… | |
… | |
1038 | { |
1035 | { |
1039 | anfds [fd].events = 0; |
1036 | anfds [fd].events = 0; |
1040 | anfds [fd].emask = 0; |
1037 | anfds [fd].emask = 0; |
1041 | fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); |
1038 | fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); |
1042 | } |
1039 | } |
|
|
1040 | } |
|
|
1041 | |
|
|
1042 | /* used to prepare libev internal fd's */ |
|
|
1043 | /* this is not fork-safe */ |
|
|
1044 | inline_speed void |
|
|
1045 | fd_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 |
1043 | } |
1054 | } |
1044 | |
1055 | |
1045 | /*****************************************************************************/ |
1056 | /*****************************************************************************/ |
1046 | |
1057 | |
1047 | /* |
1058 | /* |
… | |
… | |
1201 | |
1212 | |
1202 | static ANSIG signals [EV_NSIG - 1]; |
1213 | static ANSIG signals [EV_NSIG - 1]; |
1203 | |
1214 | |
1204 | /*****************************************************************************/ |
1215 | /*****************************************************************************/ |
1205 | |
1216 | |
1206 | /* used to prepare libev internal fd's */ |
1217 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
1207 | /* this is not fork-safe */ |
|
|
1208 | inline_speed void |
|
|
1209 | fd_intern (int fd) |
|
|
1210 | { |
|
|
1211 | #ifdef _WIN32 |
|
|
1212 | unsigned long arg = 1; |
|
|
1213 | ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg); |
|
|
1214 | #else |
|
|
1215 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
1216 | fcntl (fd, F_SETFL, O_NONBLOCK); |
|
|
1217 | #endif |
|
|
1218 | } |
|
|
1219 | |
1218 | |
1220 | static void noinline |
1219 | static void noinline |
1221 | evpipe_init (EV_P) |
1220 | evpipe_init (EV_P) |
1222 | { |
1221 | { |
1223 | if (!ev_is_active (&pipe_w)) |
1222 | if (!ev_is_active (&pipe_w)) |
1224 | { |
1223 | { |
1225 | #if EV_USE_EVENTFD |
1224 | # if EV_USE_EVENTFD |
1226 | evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); |
1225 | evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); |
1227 | if (evfd < 0 && errno == EINVAL) |
1226 | if (evfd < 0 && errno == EINVAL) |
1228 | evfd = eventfd (0, 0); |
1227 | evfd = eventfd (0, 0); |
1229 | |
1228 | |
1230 | if (evfd >= 0) |
1229 | if (evfd >= 0) |
… | |
… | |
1232 | evpipe [0] = -1; |
1231 | evpipe [0] = -1; |
1233 | fd_intern (evfd); /* doing it twice doesn't hurt */ |
1232 | fd_intern (evfd); /* doing it twice doesn't hurt */ |
1234 | ev_io_set (&pipe_w, evfd, EV_READ); |
1233 | ev_io_set (&pipe_w, evfd, EV_READ); |
1235 | } |
1234 | } |
1236 | else |
1235 | else |
1237 | #endif |
1236 | # endif |
1238 | { |
1237 | { |
1239 | while (pipe (evpipe)) |
1238 | while (pipe (evpipe)) |
1240 | ev_syserr ("(libev) error creating signal/async pipe"); |
1239 | ev_syserr ("(libev) error creating signal/async pipe"); |
1241 | |
1240 | |
1242 | fd_intern (evpipe [0]); |
1241 | fd_intern (evpipe [0]); |
… | |
… | |
1253 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
1252 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
1254 | { |
1253 | { |
1255 | if (!*flag) |
1254 | if (!*flag) |
1256 | { |
1255 | { |
1257 | 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; |
1258 | |
1258 | |
1259 | *flag = 1; |
1259 | *flag = 1; |
1260 | |
1260 | |
1261 | #if EV_USE_EVENTFD |
1261 | #if EV_USE_EVENTFD |
1262 | if (evfd >= 0) |
1262 | if (evfd >= 0) |
… | |
… | |
1264 | uint64_t counter = 1; |
1264 | uint64_t counter = 1; |
1265 | write (evfd, &counter, sizeof (uint64_t)); |
1265 | write (evfd, &counter, sizeof (uint64_t)); |
1266 | } |
1266 | } |
1267 | else |
1267 | else |
1268 | #endif |
1268 | #endif |
1269 | write (evpipe [1], &old_errno, 1); |
1269 | write (evpipe [1], &dummy, 1); |
1270 | |
1270 | |
1271 | errno = old_errno; |
1271 | errno = old_errno; |
1272 | } |
1272 | } |
1273 | } |
1273 | } |
1274 | |
1274 | |
… | |
… | |
1375 | break; |
1375 | break; |
1376 | } |
1376 | } |
1377 | } |
1377 | } |
1378 | #endif |
1378 | #endif |
1379 | |
1379 | |
|
|
1380 | #endif |
|
|
1381 | |
1380 | /*****************************************************************************/ |
1382 | /*****************************************************************************/ |
1381 | |
1383 | |
|
|
1384 | #if EV_CHILD_ENABLE |
1382 | static WL childs [EV_PID_HASHSIZE]; |
1385 | static WL childs [EV_PID_HASHSIZE]; |
1383 | |
|
|
1384 | #ifndef _WIN32 |
|
|
1385 | |
1386 | |
1386 | static ev_signal childev; |
1387 | static ev_signal childev; |
1387 | |
1388 | |
1388 | #ifndef WIFCONTINUED |
1389 | #ifndef WIFCONTINUED |
1389 | # define WIFCONTINUED(status) 0 |
1390 | # define WIFCONTINUED(status) 0 |
… | |
… | |
1394 | child_reap (EV_P_ int chain, int pid, int status) |
1395 | child_reap (EV_P_ int chain, int pid, int status) |
1395 | { |
1396 | { |
1396 | ev_child *w; |
1397 | ev_child *w; |
1397 | int traced = WIFSTOPPED (status) || WIFCONTINUED (status); |
1398 | int traced = WIFSTOPPED (status) || WIFCONTINUED (status); |
1398 | |
1399 | |
1399 | 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) |
1400 | { |
1401 | { |
1401 | if ((w->pid == pid || !w->pid) |
1402 | if ((w->pid == pid || !w->pid) |
1402 | && (!traced || (w->flags & 1))) |
1403 | && (!traced || (w->flags & 1))) |
1403 | { |
1404 | { |
1404 | 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 */ |
… | |
… | |
1429 | /* 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 */ |
1430 | /* 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 */ |
1431 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
1432 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
1432 | |
1433 | |
1433 | child_reap (EV_A_ pid, pid, status); |
1434 | child_reap (EV_A_ pid, pid, status); |
1434 | if (EV_PID_HASHSIZE > 1) |
1435 | if ((EV_PID_HASHSIZE) > 1) |
1435 | 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 */ |
1436 | } |
1437 | } |
1437 | |
1438 | |
1438 | #endif |
1439 | #endif |
1439 | |
1440 | |
… | |
… | |
1528 | ev_backend (EV_P) |
1529 | ev_backend (EV_P) |
1529 | { |
1530 | { |
1530 | return backend; |
1531 | return backend; |
1531 | } |
1532 | } |
1532 | |
1533 | |
1533 | #if EV_MINIMAL < 2 |
1534 | #if EV_FEATURE_API |
1534 | unsigned int |
1535 | unsigned int |
1535 | ev_loop_count (EV_P) |
1536 | ev_loop_count (EV_P) |
1536 | { |
1537 | { |
1537 | return loop_count; |
1538 | return loop_count; |
1538 | } |
1539 | } |
… | |
… | |
1618 | |
1619 | |
1619 | ev_rt_now = ev_time (); |
1620 | ev_rt_now = ev_time (); |
1620 | mn_now = get_clock (); |
1621 | mn_now = get_clock (); |
1621 | now_floor = mn_now; |
1622 | now_floor = mn_now; |
1622 | rtmn_diff = ev_rt_now - mn_now; |
1623 | rtmn_diff = ev_rt_now - mn_now; |
1623 | #if EV_MINIMAL < 2 |
1624 | #if EV_FEATURE_API |
1624 | invoke_cb = ev_invoke_pending; |
1625 | invoke_cb = ev_invoke_pending; |
1625 | #endif |
1626 | #endif |
1626 | |
1627 | |
1627 | io_blocktime = 0.; |
1628 | io_blocktime = 0.; |
1628 | timeout_blocktime = 0.; |
1629 | timeout_blocktime = 0.; |
… | |
… | |
1658 | if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); |
1659 | if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); |
1659 | #endif |
1660 | #endif |
1660 | |
1661 | |
1661 | ev_prepare_init (&pending_w, pendingcb); |
1662 | ev_prepare_init (&pending_w, pendingcb); |
1662 | |
1663 | |
|
|
1664 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
1663 | ev_init (&pipe_w, pipecb); |
1665 | ev_init (&pipe_w, pipecb); |
1664 | ev_set_priority (&pipe_w, EV_MAXPRI); |
1666 | ev_set_priority (&pipe_w, EV_MAXPRI); |
|
|
1667 | #endif |
1665 | } |
1668 | } |
1666 | } |
1669 | } |
1667 | |
1670 | |
1668 | /* free up a loop structure */ |
1671 | /* free up a loop structure */ |
1669 | static void noinline |
1672 | static void noinline |
… | |
… | |
1787 | { |
1790 | { |
1788 | EV_WIN32_CLOSE_FD (evpipe [0]); |
1791 | EV_WIN32_CLOSE_FD (evpipe [0]); |
1789 | EV_WIN32_CLOSE_FD (evpipe [1]); |
1792 | EV_WIN32_CLOSE_FD (evpipe [1]); |
1790 | } |
1793 | } |
1791 | |
1794 | |
|
|
1795 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
1792 | evpipe_init (EV_A); |
1796 | evpipe_init (EV_A); |
1793 | /* now iterate over everything, in case we missed something */ |
1797 | /* now iterate over everything, in case we missed something */ |
1794 | pipecb (EV_A_ &pipe_w, EV_READ); |
1798 | pipecb (EV_A_ &pipe_w, EV_READ); |
|
|
1799 | #endif |
1795 | } |
1800 | } |
1796 | |
1801 | |
1797 | postfork = 0; |
1802 | postfork = 0; |
1798 | } |
1803 | } |
1799 | |
1804 | |
… | |
… | |
1861 | verify_watcher (EV_A_ ws [cnt]); |
1866 | verify_watcher (EV_A_ ws [cnt]); |
1862 | } |
1867 | } |
1863 | } |
1868 | } |
1864 | #endif |
1869 | #endif |
1865 | |
1870 | |
1866 | #if EV_MINIMAL < 2 |
1871 | #if EV_FEATURE_API |
1867 | void |
1872 | void |
1868 | ev_loop_verify (EV_P) |
1873 | ev_loop_verify (EV_P) |
1869 | { |
1874 | { |
1870 | #if EV_VERIFY |
1875 | #if EV_VERIFY |
1871 | int i; |
1876 | int i; |
… | |
… | |
1912 | #if EV_ASYNC_ENABLE |
1917 | #if EV_ASYNC_ENABLE |
1913 | assert (asyncmax >= asynccnt); |
1918 | assert (asyncmax >= asynccnt); |
1914 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
1919 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
1915 | #endif |
1920 | #endif |
1916 | |
1921 | |
|
|
1922 | #if EV_PREPARE_ENABLE |
1917 | assert (preparemax >= preparecnt); |
1923 | assert (preparemax >= preparecnt); |
1918 | array_verify (EV_A_ (W *)prepares, preparecnt); |
1924 | array_verify (EV_A_ (W *)prepares, preparecnt); |
|
|
1925 | #endif |
1919 | |
1926 | |
|
|
1927 | #if EV_CHECK_ENABLE |
1920 | assert (checkmax >= checkcnt); |
1928 | assert (checkmax >= checkcnt); |
1921 | array_verify (EV_A_ (W *)checks, checkcnt); |
1929 | array_verify (EV_A_ (W *)checks, checkcnt); |
|
|
1930 | #endif |
1922 | |
1931 | |
1923 | # if 0 |
1932 | # if 0 |
|
|
1933 | #if EV_CHILD_ENABLE |
1924 | 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) |
1925 | for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) |
1935 | for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) |
|
|
1936 | #endif |
1926 | # endif |
1937 | # endif |
1927 | #endif |
1938 | #endif |
1928 | } |
1939 | } |
1929 | #endif |
1940 | #endif |
1930 | |
1941 | |
… | |
… | |
1946 | |
1957 | |
1947 | loop_init (EV_A_ flags); |
1958 | loop_init (EV_A_ flags); |
1948 | |
1959 | |
1949 | if (ev_backend (EV_A)) |
1960 | if (ev_backend (EV_A)) |
1950 | { |
1961 | { |
1951 | #ifndef _WIN32 |
1962 | #if EV_CHILD_ENABLE |
1952 | ev_signal_init (&childev, childcb, SIGCHLD); |
1963 | ev_signal_init (&childev, childcb, SIGCHLD); |
1953 | ev_set_priority (&childev, EV_MAXPRI); |
1964 | ev_set_priority (&childev, EV_MAXPRI); |
1954 | ev_signal_start (EV_A_ &childev); |
1965 | ev_signal_start (EV_A_ &childev); |
1955 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
1966 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
1956 | #endif |
1967 | #endif |
… | |
… | |
1969 | EV_P = ev_default_loop_ptr; |
1980 | EV_P = ev_default_loop_ptr; |
1970 | #endif |
1981 | #endif |
1971 | |
1982 | |
1972 | ev_default_loop_ptr = 0; |
1983 | ev_default_loop_ptr = 0; |
1973 | |
1984 | |
1974 | #ifndef _WIN32 |
1985 | #if EV_CHILD_ENABLE |
1975 | ev_ref (EV_A); /* child watcher */ |
1986 | ev_ref (EV_A); /* child watcher */ |
1976 | ev_signal_stop (EV_A_ &childev); |
1987 | ev_signal_stop (EV_A_ &childev); |
1977 | #endif |
1988 | #endif |
1978 | |
1989 | |
1979 | loop_destroy (EV_A); |
1990 | loop_destroy (EV_A); |
… | |
… | |
2256 | } |
2267 | } |
2257 | |
2268 | |
2258 | void |
2269 | void |
2259 | ev_loop (EV_P_ int flags) |
2270 | ev_loop (EV_P_ int flags) |
2260 | { |
2271 | { |
2261 | #if EV_MINIMAL < 2 |
2272 | #if EV_FEATURE_API |
2262 | ++loop_depth; |
2273 | ++loop_depth; |
2263 | #endif |
2274 | #endif |
2264 | |
2275 | |
2265 | 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)); |
2266 | |
2277 | |
… | |
… | |
2291 | queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); |
2302 | queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); |
2292 | EV_INVOKE_PENDING; |
2303 | EV_INVOKE_PENDING; |
2293 | } |
2304 | } |
2294 | #endif |
2305 | #endif |
2295 | |
2306 | |
|
|
2307 | #if EV_PREPARE_ENABLE |
2296 | /* queue prepare watchers (and execute them) */ |
2308 | /* queue prepare watchers (and execute them) */ |
2297 | if (expect_false (preparecnt)) |
2309 | if (expect_false (preparecnt)) |
2298 | { |
2310 | { |
2299 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
2311 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
2300 | EV_INVOKE_PENDING; |
2312 | EV_INVOKE_PENDING; |
2301 | } |
2313 | } |
|
|
2314 | #endif |
2302 | |
2315 | |
2303 | if (expect_false (loop_done)) |
2316 | if (expect_false (loop_done)) |
2304 | break; |
2317 | break; |
2305 | |
2318 | |
2306 | /* we might have forked, so reify kernel state if necessary */ |
2319 | /* we might have forked, so reify kernel state if necessary */ |
… | |
… | |
2357 | waittime -= sleeptime; |
2370 | waittime -= sleeptime; |
2358 | } |
2371 | } |
2359 | } |
2372 | } |
2360 | } |
2373 | } |
2361 | |
2374 | |
2362 | #if EV_MINIMAL < 2 |
2375 | #if EV_FEATURE_API |
2363 | ++loop_count; |
2376 | ++loop_count; |
2364 | #endif |
2377 | #endif |
2365 | assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */ |
2378 | assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */ |
2366 | backend_poll (EV_A_ waittime); |
2379 | backend_poll (EV_A_ waittime); |
2367 | assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */ |
2380 | assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */ |
… | |
… | |
2379 | #if EV_IDLE_ENABLE |
2392 | #if EV_IDLE_ENABLE |
2380 | /* queue idle watchers unless other events are pending */ |
2393 | /* queue idle watchers unless other events are pending */ |
2381 | idle_reify (EV_A); |
2394 | idle_reify (EV_A); |
2382 | #endif |
2395 | #endif |
2383 | |
2396 | |
|
|
2397 | #if EV_CHECK_ENABLE |
2384 | /* queue check watchers, to be executed first */ |
2398 | /* queue check watchers, to be executed first */ |
2385 | if (expect_false (checkcnt)) |
2399 | if (expect_false (checkcnt)) |
2386 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
2400 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
|
|
2401 | #endif |
2387 | |
2402 | |
2388 | EV_INVOKE_PENDING; |
2403 | EV_INVOKE_PENDING; |
2389 | } |
2404 | } |
2390 | while (expect_true ( |
2405 | while (expect_true ( |
2391 | activecnt |
2406 | activecnt |
… | |
… | |
2394 | )); |
2409 | )); |
2395 | |
2410 | |
2396 | if (loop_done == EVUNLOOP_ONE) |
2411 | if (loop_done == EVUNLOOP_ONE) |
2397 | loop_done = EVUNLOOP_CANCEL; |
2412 | loop_done = EVUNLOOP_CANCEL; |
2398 | |
2413 | |
2399 | #if EV_MINIMAL < 2 |
2414 | #if EV_FEATURE_API |
2400 | --loop_depth; |
2415 | --loop_depth; |
2401 | #endif |
2416 | #endif |
2402 | } |
2417 | } |
2403 | |
2418 | |
2404 | void |
2419 | void |
… | |
… | |
2721 | |
2736 | |
2722 | #ifndef SA_RESTART |
2737 | #ifndef SA_RESTART |
2723 | # define SA_RESTART 0 |
2738 | # define SA_RESTART 0 |
2724 | #endif |
2739 | #endif |
2725 | |
2740 | |
|
|
2741 | #if EV_SIGNAL_ENABLE |
|
|
2742 | |
2726 | void noinline |
2743 | void noinline |
2727 | ev_signal_start (EV_P_ ev_signal *w) |
2744 | ev_signal_start (EV_P_ ev_signal *w) |
2728 | { |
2745 | { |
2729 | if (expect_false (ev_is_active (w))) |
2746 | if (expect_false (ev_is_active (w))) |
2730 | return; |
2747 | return; |
… | |
… | |
2836 | } |
2853 | } |
2837 | |
2854 | |
2838 | EV_FREQUENT_CHECK; |
2855 | EV_FREQUENT_CHECK; |
2839 | } |
2856 | } |
2840 | |
2857 | |
|
|
2858 | #endif |
|
|
2859 | |
|
|
2860 | #if EV_CHILD_ENABLE |
|
|
2861 | |
2841 | void |
2862 | void |
2842 | ev_child_start (EV_P_ ev_child *w) |
2863 | ev_child_start (EV_P_ ev_child *w) |
2843 | { |
2864 | { |
2844 | #if EV_MULTIPLICITY |
2865 | #if EV_MULTIPLICITY |
2845 | 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)); |
… | |
… | |
2848 | return; |
2869 | return; |
2849 | |
2870 | |
2850 | EV_FREQUENT_CHECK; |
2871 | EV_FREQUENT_CHECK; |
2851 | |
2872 | |
2852 | ev_start (EV_A_ (W)w, 1); |
2873 | ev_start (EV_A_ (W)w, 1); |
2853 | wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
2874 | wlist_add (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); |
2854 | |
2875 | |
2855 | EV_FREQUENT_CHECK; |
2876 | EV_FREQUENT_CHECK; |
2856 | } |
2877 | } |
2857 | |
2878 | |
2858 | void |
2879 | void |
… | |
… | |
2862 | if (expect_false (!ev_is_active (w))) |
2883 | if (expect_false (!ev_is_active (w))) |
2863 | return; |
2884 | return; |
2864 | |
2885 | |
2865 | EV_FREQUENT_CHECK; |
2886 | EV_FREQUENT_CHECK; |
2866 | |
2887 | |
2867 | wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
2888 | wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); |
2868 | ev_stop (EV_A_ (W)w); |
2889 | ev_stop (EV_A_ (W)w); |
2869 | |
2890 | |
2870 | EV_FREQUENT_CHECK; |
2891 | EV_FREQUENT_CHECK; |
2871 | } |
2892 | } |
|
|
2893 | |
|
|
2894 | #endif |
2872 | |
2895 | |
2873 | #if EV_STAT_ENABLE |
2896 | #if EV_STAT_ENABLE |
2874 | |
2897 | |
2875 | # ifdef _WIN32 |
2898 | # ifdef _WIN32 |
2876 | # undef lstat |
2899 | # undef lstat |
… | |
… | |
2943 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2966 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2944 | } |
2967 | } |
2945 | } |
2968 | } |
2946 | |
2969 | |
2947 | if (w->wd >= 0) |
2970 | if (w->wd >= 0) |
2948 | 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); |
2949 | |
2972 | |
2950 | /* now re-arm timer, if required */ |
2973 | /* now re-arm timer, if required */ |
2951 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
2974 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
2952 | ev_timer_again (EV_A_ &w->timer); |
2975 | ev_timer_again (EV_A_ &w->timer); |
2953 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
2976 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
… | |
… | |
2961 | |
2984 | |
2962 | if (wd < 0) |
2985 | if (wd < 0) |
2963 | return; |
2986 | return; |
2964 | |
2987 | |
2965 | w->wd = -2; |
2988 | w->wd = -2; |
2966 | slot = wd & (EV_INOTIFY_HASHSIZE - 1); |
2989 | slot = wd & ((EV_INOTIFY_HASHSIZE) - 1); |
2967 | wlist_del (&fs_hash [slot].head, (WL)w); |
2990 | wlist_del (&fs_hash [slot].head, (WL)w); |
2968 | |
2991 | |
2969 | /* remove this watcher, if others are watching it, they will rearm */ |
2992 | /* remove this watcher, if others are watching it, they will rearm */ |
2970 | inotify_rm_watch (fs_fd, wd); |
2993 | inotify_rm_watch (fs_fd, wd); |
2971 | } |
2994 | } |
… | |
… | |
2973 | static void noinline |
2996 | static void noinline |
2974 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
2997 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
2975 | { |
2998 | { |
2976 | if (slot < 0) |
2999 | if (slot < 0) |
2977 | /* overflow, need to check for all hash slots */ |
3000 | /* overflow, need to check for all hash slots */ |
2978 | for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) |
3001 | for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) |
2979 | infy_wd (EV_A_ slot, wd, ev); |
3002 | infy_wd (EV_A_ slot, wd, ev); |
2980 | else |
3003 | else |
2981 | { |
3004 | { |
2982 | WL w_; |
3005 | WL w_; |
2983 | |
3006 | |
2984 | for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; ) |
3007 | for (w_ = fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head; w_; ) |
2985 | { |
3008 | { |
2986 | ev_stat *w = (ev_stat *)w_; |
3009 | ev_stat *w = (ev_stat *)w_; |
2987 | 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 */ |
2988 | |
3011 | |
2989 | if (w->wd == wd || wd == -1) |
3012 | if (w->wd == wd || wd == -1) |
2990 | { |
3013 | { |
2991 | if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) |
3014 | if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) |
2992 | { |
3015 | { |
2993 | 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); |
2994 | w->wd = -1; |
3017 | w->wd = -1; |
2995 | infy_add (EV_A_ w); /* re-add, no matter what */ |
3018 | infy_add (EV_A_ w); /* re-add, no matter what */ |
2996 | } |
3019 | } |
2997 | |
3020 | |
2998 | stat_timer_cb (EV_A_ &w->timer, 0); |
3021 | stat_timer_cb (EV_A_ &w->timer, 0); |
… | |
… | |
3112 | ev_io_set (&fs_w, fs_fd, EV_READ); |
3135 | ev_io_set (&fs_w, fs_fd, EV_READ); |
3113 | ev_io_start (EV_A_ &fs_w); |
3136 | ev_io_start (EV_A_ &fs_w); |
3114 | ev_unref (EV_A); |
3137 | ev_unref (EV_A); |
3115 | } |
3138 | } |
3116 | |
3139 | |
3117 | for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) |
3140 | for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) |
3118 | { |
3141 | { |
3119 | WL w_ = fs_hash [slot].head; |
3142 | WL w_ = fs_hash [slot].head; |
3120 | fs_hash [slot].head = 0; |
3143 | fs_hash [slot].head = 0; |
3121 | |
3144 | |
3122 | while (w_) |
3145 | while (w_) |
… | |
… | |
3297 | |
3320 | |
3298 | EV_FREQUENT_CHECK; |
3321 | EV_FREQUENT_CHECK; |
3299 | } |
3322 | } |
3300 | #endif |
3323 | #endif |
3301 | |
3324 | |
|
|
3325 | #if EV_PREPARE_ENABLE |
3302 | void |
3326 | void |
3303 | ev_prepare_start (EV_P_ ev_prepare *w) |
3327 | ev_prepare_start (EV_P_ ev_prepare *w) |
3304 | { |
3328 | { |
3305 | if (expect_false (ev_is_active (w))) |
3329 | if (expect_false (ev_is_active (w))) |
3306 | return; |
3330 | return; |
… | |
… | |
3332 | |
3356 | |
3333 | ev_stop (EV_A_ (W)w); |
3357 | ev_stop (EV_A_ (W)w); |
3334 | |
3358 | |
3335 | EV_FREQUENT_CHECK; |
3359 | EV_FREQUENT_CHECK; |
3336 | } |
3360 | } |
|
|
3361 | #endif |
3337 | |
3362 | |
|
|
3363 | #if EV_CHECK_ENABLE |
3338 | void |
3364 | void |
3339 | ev_check_start (EV_P_ ev_check *w) |
3365 | ev_check_start (EV_P_ ev_check *w) |
3340 | { |
3366 | { |
3341 | if (expect_false (ev_is_active (w))) |
3367 | if (expect_false (ev_is_active (w))) |
3342 | return; |
3368 | return; |
… | |
… | |
3368 | |
3394 | |
3369 | ev_stop (EV_A_ (W)w); |
3395 | ev_stop (EV_A_ (W)w); |
3370 | |
3396 | |
3371 | EV_FREQUENT_CHECK; |
3397 | EV_FREQUENT_CHECK; |
3372 | } |
3398 | } |
|
|
3399 | #endif |
3373 | |
3400 | |
3374 | #if EV_EMBED_ENABLE |
3401 | #if EV_EMBED_ENABLE |
3375 | void noinline |
3402 | void noinline |
3376 | ev_embed_sweep (EV_P_ ev_embed *w) |
3403 | ev_embed_sweep (EV_P_ ev_embed *w) |
3377 | { |
3404 | { |
… | |
… | |
3706 | if (types & EV_ASYNC) |
3733 | if (types & EV_ASYNC) |
3707 | for (i = asynccnt; i--; ) |
3734 | for (i = asynccnt; i--; ) |
3708 | cb (EV_A_ EV_ASYNC, asyncs [i]); |
3735 | cb (EV_A_ EV_ASYNC, asyncs [i]); |
3709 | #endif |
3736 | #endif |
3710 | |
3737 | |
|
|
3738 | #if EV_PREPARE_ENABLE |
3711 | if (types & EV_PREPARE) |
3739 | if (types & EV_PREPARE) |
3712 | for (i = preparecnt; i--; ) |
3740 | for (i = preparecnt; i--; ) |
3713 | #if EV_EMBED_ENABLE |
3741 | # if EV_EMBED_ENABLE |
3714 | if (ev_cb (prepares [i]) != embed_prepare_cb) |
3742 | if (ev_cb (prepares [i]) != embed_prepare_cb) |
3715 | #endif |
3743 | # endif |
3716 | cb (EV_A_ EV_PREPARE, prepares [i]); |
3744 | cb (EV_A_ EV_PREPARE, prepares [i]); |
|
|
3745 | #endif |
3717 | |
3746 | |
|
|
3747 | #if EV_CHECK_ENABLE |
3718 | if (types & EV_CHECK) |
3748 | if (types & EV_CHECK) |
3719 | for (i = checkcnt; i--; ) |
3749 | for (i = checkcnt; i--; ) |
3720 | cb (EV_A_ EV_CHECK, checks [i]); |
3750 | cb (EV_A_ EV_CHECK, checks [i]); |
|
|
3751 | #endif |
3721 | |
3752 | |
|
|
3753 | #if EV_SIGNAL_ENABLE |
3722 | if (types & EV_SIGNAL) |
3754 | if (types & EV_SIGNAL) |
3723 | for (i = 0; i < EV_NSIG - 1; ++i) |
3755 | for (i = 0; i < EV_NSIG - 1; ++i) |
3724 | for (wl = signals [i].head; wl; ) |
3756 | for (wl = signals [i].head; wl; ) |
3725 | { |
3757 | { |
3726 | wn = wl->next; |
3758 | wn = wl->next; |
3727 | cb (EV_A_ EV_SIGNAL, wl); |
3759 | cb (EV_A_ EV_SIGNAL, wl); |
3728 | wl = wn; |
3760 | wl = wn; |
3729 | } |
3761 | } |
|
|
3762 | #endif |
3730 | |
3763 | |
|
|
3764 | #if EV_CHILD_ENABLE |
3731 | if (types & EV_CHILD) |
3765 | if (types & EV_CHILD) |
3732 | for (i = EV_PID_HASHSIZE; i--; ) |
3766 | for (i = (EV_PID_HASHSIZE); i--; ) |
3733 | for (wl = childs [i]; wl; ) |
3767 | for (wl = childs [i]; wl; ) |
3734 | { |
3768 | { |
3735 | wn = wl->next; |
3769 | wn = wl->next; |
3736 | cb (EV_A_ EV_CHILD, wl); |
3770 | cb (EV_A_ EV_CHILD, wl); |
3737 | wl = wn; |
3771 | wl = wn; |
3738 | } |
3772 | } |
|
|
3773 | #endif |
3739 | /* EV_STAT 0x00001000 /* stat data changed */ |
3774 | /* EV_STAT 0x00001000 /* stat data changed */ |
3740 | /* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ |
3775 | /* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ |
3741 | } |
3776 | } |
3742 | #endif |
3777 | #endif |
3743 | |
3778 | |