… | |
… | |
302 | # define EV_USE_EVENTFD 0 |
302 | # define EV_USE_EVENTFD 0 |
303 | # endif |
303 | # endif |
304 | #endif |
304 | #endif |
305 | |
305 | |
306 | #ifndef EV_USE_SIGNALFD |
306 | #ifndef EV_USE_SIGNALFD |
307 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9)) |
307 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
308 | # define EV_USE_SIGNALFD 1 |
308 | # define EV_USE_SIGNALFD 1 |
309 | # else |
309 | # else |
310 | # define EV_USE_SIGNALFD 0 |
310 | # define EV_USE_SIGNALFD 0 |
311 | # endif |
311 | # endif |
312 | #endif |
312 | #endif |
… | |
… | |
386 | # include <stdint.h> |
386 | # include <stdint.h> |
387 | # ifndef EFD_NONBLOCK |
387 | # ifndef EFD_NONBLOCK |
388 | # define EFD_NONBLOCK O_NONBLOCK |
388 | # define EFD_NONBLOCK O_NONBLOCK |
389 | # endif |
389 | # endif |
390 | # ifndef EFD_CLOEXEC |
390 | # ifndef EFD_CLOEXEC |
|
|
391 | # ifdef O_CLOEXEC |
391 | # define EFD_CLOEXEC O_CLOEXEC |
392 | # define EFD_CLOEXEC O_CLOEXEC |
|
|
393 | # else |
|
|
394 | # define EFD_CLOEXEC 02000000 |
|
|
395 | # endif |
392 | # endif |
396 | # endif |
393 | # ifdef __cplusplus |
397 | # ifdef __cplusplus |
394 | extern "C" { |
398 | extern "C" { |
395 | # endif |
399 | # endif |
396 | int eventfd (unsigned int initval, int flags); |
400 | int eventfd (unsigned int initval, int flags); |
… | |
… | |
398 | } |
402 | } |
399 | # endif |
403 | # endif |
400 | #endif |
404 | #endif |
401 | |
405 | |
402 | #if EV_USE_SIGNALFD |
406 | #if EV_USE_SIGNALFD |
403 | # include <sys/signalfd.h> |
407 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
|
|
408 | # include <stdint.h> |
|
|
409 | # ifndef SFD_NONBLOCK |
|
|
410 | # define SFD_NONBLOCK O_NONBLOCK |
404 | #endif |
411 | # endif |
|
|
412 | # ifndef SFD_CLOEXEC |
|
|
413 | # ifdef O_CLOEXEC |
|
|
414 | # define SFD_CLOEXEC O_CLOEXEC |
|
|
415 | # else |
|
|
416 | # define SFD_CLOEXEC 02000000 |
|
|
417 | # endif |
|
|
418 | # endif |
|
|
419 | # ifdef __cplusplus |
|
|
420 | extern "C" { |
|
|
421 | # endif |
|
|
422 | int signalfd (int fd, const sigset_t *mask, int flags); |
|
|
423 | |
|
|
424 | struct signalfd_siginfo |
|
|
425 | { |
|
|
426 | uint32_t ssi_signo; |
|
|
427 | char pad[128 - sizeof (uint32_t)]; |
|
|
428 | }; |
|
|
429 | # ifdef __cplusplus |
|
|
430 | } |
|
|
431 | # endif |
|
|
432 | #endif |
|
|
433 | |
405 | |
434 | |
406 | /**/ |
435 | /**/ |
407 | |
436 | |
408 | #if EV_VERIFY >= 3 |
437 | #if EV_VERIFY >= 3 |
409 | # define EV_FREQUENT_CHECK ev_loop_verify (EV_A) |
438 | # define EV_FREQUENT_CHECK ev_loop_verify (EV_A) |
… | |
… | |
472 | |
501 | |
473 | #if EV_USE_MONOTONIC |
502 | #if EV_USE_MONOTONIC |
474 | static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
503 | static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
475 | #endif |
504 | #endif |
476 | |
505 | |
|
|
506 | #ifndef EV_FD_TO_WIN32_HANDLE |
|
|
507 | # define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) |
|
|
508 | #endif |
|
|
509 | #ifndef EV_WIN32_HANDLE_TO_FD |
|
|
510 | # define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (fd, 0) |
|
|
511 | #endif |
|
|
512 | #ifndef EV_WIN32_CLOSE_FD |
|
|
513 | # define EV_WIN32_CLOSE_FD(fd) close (fd) |
|
|
514 | #endif |
|
|
515 | |
477 | #ifdef _WIN32 |
516 | #ifdef _WIN32 |
478 | # include "ev_win32.c" |
517 | # include "ev_win32.c" |
479 | #endif |
518 | #endif |
480 | |
519 | |
481 | /*****************************************************************************/ |
520 | /*****************************************************************************/ |
… | |
… | |
872 | |
911 | |
873 | #if EV_SELECT_IS_WINSOCKET |
912 | #if EV_SELECT_IS_WINSOCKET |
874 | if (events) |
913 | if (events) |
875 | { |
914 | { |
876 | unsigned long arg; |
915 | unsigned long arg; |
877 | #ifdef EV_FD_TO_WIN32_HANDLE |
|
|
878 | anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); |
916 | anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); |
879 | #else |
|
|
880 | anfd->handle = _get_osfhandle (fd); |
|
|
881 | #endif |
|
|
882 | assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0)); |
917 | assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0)); |
883 | } |
918 | } |
884 | #endif |
919 | #endif |
885 | |
920 | |
886 | { |
921 | { |
… | |
… | |
1103 | |
1138 | |
1104 | /* move an element suitably so it is in a correct place */ |
1139 | /* move an element suitably so it is in a correct place */ |
1105 | inline_size void |
1140 | inline_size void |
1106 | adjustheap (ANHE *heap, int N, int k) |
1141 | adjustheap (ANHE *heap, int N, int k) |
1107 | { |
1142 | { |
1108 | if (k > HEAP0 && ANHE_at (heap [HPARENT (k)]) >= ANHE_at (heap [k])) |
1143 | if (k > HEAP0 && ANHE_at (heap [k]) <= ANHE_at (heap [HPARENT (k)])) |
1109 | upheap (heap, k); |
1144 | upheap (heap, k); |
1110 | else |
1145 | else |
1111 | downheap (heap, N, k); |
1146 | downheap (heap, N, k); |
1112 | } |
1147 | } |
1113 | |
1148 | |
… | |
… | |
1617 | close (evfd); |
1652 | close (evfd); |
1618 | #endif |
1653 | #endif |
1619 | |
1654 | |
1620 | if (evpipe [0] >= 0) |
1655 | if (evpipe [0] >= 0) |
1621 | { |
1656 | { |
1622 | close (evpipe [0]); |
1657 | EV_WIN32_CLOSE_FD (evpipe [0]); |
1623 | close (evpipe [1]); |
1658 | EV_WIN32_CLOSE_FD (evpipe [1]); |
1624 | } |
1659 | } |
1625 | } |
1660 | } |
1626 | |
1661 | |
1627 | #if EV_USE_SIGNALFD |
1662 | #if EV_USE_SIGNALFD |
1628 | if (ev_is_active (&sigfd_w)) |
1663 | if (ev_is_active (&sigfd_w)) |
… | |
… | |
1724 | close (evfd); |
1759 | close (evfd); |
1725 | #endif |
1760 | #endif |
1726 | |
1761 | |
1727 | if (evpipe [0] >= 0) |
1762 | if (evpipe [0] >= 0) |
1728 | { |
1763 | { |
1729 | close (evpipe [0]); |
1764 | EV_WIN32_CLOSE_FD (evpipe [0]); |
1730 | close (evpipe [1]); |
1765 | EV_WIN32_CLOSE_FD (evpipe [1]); |
1731 | } |
1766 | } |
1732 | |
1767 | |
1733 | evpipe_init (EV_A); |
1768 | evpipe_init (EV_A); |
1734 | /* now iterate over everything, in case we missed something */ |
1769 | /* now iterate over everything, in case we missed something */ |
1735 | pipecb (EV_A_ &pipe_w, EV_READ); |
1770 | pipecb (EV_A_ &pipe_w, EV_READ); |
… | |
… | |
2857 | } |
2892 | } |
2858 | } |
2893 | } |
2859 | |
2894 | |
2860 | if (w->wd >= 0) |
2895 | if (w->wd >= 0) |
2861 | { |
2896 | { |
|
|
2897 | struct statfs sfs; |
|
|
2898 | |
2862 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2899 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2863 | |
2900 | |
2864 | /* now local changes will be tracked by inotify, but remote changes won't */ |
2901 | /* now local changes will be tracked by inotify, but remote changes won't */ |
2865 | /* unless the filesystem it known to be local, we therefore still poll */ |
2902 | /* unless the filesystem it known to be local, we therefore still poll */ |
2866 | /* also do poll on <2.6.25, but with normal frequency */ |
2903 | /* also do poll on <2.6.25, but with normal frequency */ |
2867 | struct statfs sfs; |
|
|
2868 | |
2904 | |
2869 | if (fs_2625 && !statfs (w->path, &sfs)) |
2905 | if (fs_2625 && !statfs (w->path, &sfs)) |
2870 | if (sfs.f_type == 0x1373 /* devfs */ |
2906 | if (sfs.f_type == 0x1373 /* devfs */ |
2871 | || sfs.f_type == 0xEF53 /* ext2/3 */ |
2907 | || sfs.f_type == 0xEF53 /* ext2/3 */ |
2872 | || sfs.f_type == 0x3153464a /* jfs */ |
2908 | || sfs.f_type == 0x3153464a /* jfs */ |