--- libev/ev.c 2009/08/12 18:48:17 1.312 +++ libev/ev.c 2009/08/19 23:44:51 1.313 @@ -478,6 +478,16 @@ static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ #endif +#ifndef EV_FD_TO_WIN32_HANDLE +# define EV_FD_TO_WIN32_HANDLE(fd) _get_osfhandle (fd) +#endif +#ifndef EV_WIN32_HANDLE_TO_FD +# define EV_WIN32_HANDLE_TO_FD(handle) _open_osfhandle (fd, 0) +#endif +#ifndef EV_WIN32_CLOSE_FD +# define EV_WIN32_CLOSE_FD(fd) close (fd) +#endif + #ifdef _WIN32 # include "ev_win32.c" #endif @@ -878,11 +888,7 @@ if (events) { unsigned long arg; - #ifdef EV_FD_TO_WIN32_HANDLE - anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); - #else - anfd->handle = _get_osfhandle (fd); - #endif + anfd->handle = EV_FD_TO_WIN32_HANDLE (fd); assert (("libev: only socket fds supported in this configuration", ioctlsocket (anfd->handle, FIONREAD, &arg) == 0)); } #endif @@ -1623,8 +1629,8 @@ if (evpipe [0] >= 0) { - close (evpipe [0]); - close (evpipe [1]); + EV_WIN32_CLOSE_FD (evpipe [0]); + EV_WIN32_CLOSE_FD (evpipe [1]); } } @@ -1730,8 +1736,8 @@ if (evpipe [0] >= 0) { - close (evpipe [0]); - close (evpipe [1]); + EV_WIN32_CLOSE_FD (evpipe [0]); + EV_WIN32_CLOSE_FD (evpipe [1]); } evpipe_init (EV_A);