… | |
… | |
164 | #endif |
164 | #endif |
165 | |
165 | |
166 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
166 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
167 | |
167 | |
168 | #ifndef EV_USE_MONOTONIC |
168 | #ifndef EV_USE_MONOTONIC |
|
|
169 | # if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 |
|
|
170 | # define EV_USE_MONOTONIC 1 |
|
|
171 | # else |
169 | # define EV_USE_MONOTONIC 0 |
172 | # define EV_USE_MONOTONIC 0 |
|
|
173 | # endif |
170 | #endif |
174 | #endif |
171 | |
175 | |
172 | #ifndef EV_USE_REALTIME |
176 | #ifndef EV_USE_REALTIME |
173 | # define EV_USE_REALTIME 0 |
177 | # define EV_USE_REALTIME 0 |
174 | #endif |
178 | #endif |
175 | |
179 | |
176 | #ifndef EV_USE_NANOSLEEP |
180 | #ifndef EV_USE_NANOSLEEP |
|
|
181 | # if _POSIX_C_SOURCE >= 199309L |
|
|
182 | # define EV_USE_NANOSLEEP 1 |
|
|
183 | # else |
177 | # define EV_USE_NANOSLEEP 0 |
184 | # define EV_USE_NANOSLEEP 0 |
|
|
185 | # endif |
178 | #endif |
186 | #endif |
179 | |
187 | |
180 | #ifndef EV_USE_SELECT |
188 | #ifndef EV_USE_SELECT |
181 | # define EV_USE_SELECT 1 |
189 | # define EV_USE_SELECT 1 |
182 | #endif |
190 | #endif |
… | |
… | |
699 | events |= (unsigned char)w->events; |
707 | events |= (unsigned char)w->events; |
700 | |
708 | |
701 | #if EV_SELECT_IS_WINSOCKET |
709 | #if EV_SELECT_IS_WINSOCKET |
702 | if (events) |
710 | if (events) |
703 | { |
711 | { |
704 | unsigned long argp; |
712 | unsigned long arg; |
705 | #ifdef EV_FD_TO_WIN32_HANDLE |
713 | #ifdef EV_FD_TO_WIN32_HANDLE |
706 | anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); |
714 | anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); |
707 | #else |
715 | #else |
708 | anfd->handle = _get_osfhandle (fd); |
716 | anfd->handle = _get_osfhandle (fd); |
709 | #endif |
717 | #endif |
710 | assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &argp) == 0)); |
718 | assert (("libev only supports socket fds in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0)); |
711 | } |
719 | } |
712 | #endif |
720 | #endif |
713 | |
721 | |
714 | { |
722 | { |
715 | unsigned char o_events = anfd->events; |
723 | unsigned char o_events = anfd->events; |
… | |
… | |
768 | { |
776 | { |
769 | int fd; |
777 | int fd; |
770 | |
778 | |
771 | for (fd = 0; fd < anfdmax; ++fd) |
779 | for (fd = 0; fd < anfdmax; ++fd) |
772 | if (anfds [fd].events) |
780 | if (anfds [fd].events) |
773 | if (!fd_valid (fd) == -1 && errno == EBADF) |
781 | if (!fd_valid (fd) && errno == EBADF) |
774 | fd_kill (EV_A_ fd); |
782 | fd_kill (EV_A_ fd); |
775 | } |
783 | } |
776 | |
784 | |
777 | /* called on ENOMEM in select/poll to kill some fds and retry */ |
785 | /* called on ENOMEM in select/poll to kill some fds and retry */ |
778 | static void noinline |
786 | static void noinline |
… | |
… | |
975 | |
983 | |
976 | void inline_speed |
984 | void inline_speed |
977 | fd_intern (int fd) |
985 | fd_intern (int fd) |
978 | { |
986 | { |
979 | #ifdef _WIN32 |
987 | #ifdef _WIN32 |
980 | int arg = 1; |
988 | unsigned long arg = 1; |
981 | ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg); |
989 | ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg); |
982 | #else |
990 | #else |
983 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
991 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
984 | fcntl (fd, F_SETFL, O_NONBLOCK); |
992 | fcntl (fd, F_SETFL, O_NONBLOCK); |
985 | #endif |
993 | #endif |
… | |
… | |
1568 | |
1576 | |
1569 | for (i = NUMPRI; i--; ) |
1577 | for (i = NUMPRI; i--; ) |
1570 | { |
1578 | { |
1571 | assert (pendingmax [i] >= pendingcnt [i]); |
1579 | assert (pendingmax [i] >= pendingcnt [i]); |
1572 | #if EV_IDLE_ENABLE |
1580 | #if EV_IDLE_ENABLE |
|
|
1581 | assert (idleall >= 0); |
1573 | assert (idlemax [i] >= idlecnt [i]); |
1582 | assert (idlemax [i] >= idlecnt [i]); |
1574 | array_verify (EV_A_ (W *)idles [i], idlecnt [i]); |
1583 | array_verify (EV_A_ (W *)idles [i], idlecnt [i]); |
1575 | #endif |
1584 | #endif |
1576 | } |
1585 | } |
1577 | |
1586 | |
… | |
… | |
2558 | } |
2567 | } |
2559 | |
2568 | |
2560 | } |
2569 | } |
2561 | } |
2570 | } |
2562 | |
2571 | |
|
|
2572 | #endif |
|
|
2573 | |
|
|
2574 | #ifdef _WIN32 |
|
|
2575 | # define EV_LSTAT(p,b) _stati64 (p, b) |
|
|
2576 | #else |
|
|
2577 | # define EV_LSTAT(p,b) lstat (p, b) |
2563 | #endif |
2578 | #endif |
2564 | |
2579 | |
2565 | void |
2580 | void |
2566 | ev_stat_stat (EV_P_ ev_stat *w) |
2581 | ev_stat_stat (EV_P_ ev_stat *w) |
2567 | { |
2582 | { |