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