--- IO-AIO/schmorp.h 2009/07/18 05:58:39 1.7 +++ IO-AIO/schmorp.h 2010/08/04 14:02:58 1.11 @@ -8,7 +8,11 @@ #include #include -#ifndef _WIN32 +#if defined(WIN32 ) || defined(_MINIX) +# define SCHMORP_H_PREFER_SELECT 1 +#endif + +#if !SCHMORP_H_PREFER_SELECT # include #endif @@ -22,6 +26,10 @@ && (PERL_VERSION > (b) \ || (PERL_VERSION == (b) && PERL_SUBVERSION >= (c))))) +#ifndef PERL_MAGIC_ext +# define PERL_MAGIC_ext '~' +#endif + #if !PERL_VERSION_ATLEAST (5,6,0) # ifndef PL_ppaddr # define PL_ppaddr ppaddr @@ -325,6 +333,7 @@ #endif #if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) +# define SCHMORP_H_HAVE_EVENTFD 1 /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ # include # ifdef __cplusplus @@ -402,7 +411,11 @@ DWORD dummy; WriteFile (S_TO_HANDLE (epp->fd [1]), (LPCVOID)&dummy, 1, &dummy, 0); #else +# if SCHMORP_H_HAVE_EVENTFD static uint64_t counter = 1; +# else + static char counter [8]; +# endif /* some modules accept fd's from outside, support eventfd here */ if (write (epp->fd [1], &counter, epp->len) < 0 && errno == EINVAL @@ -442,8 +455,10 @@ if (dup2 (epn.fd [0], epp->fd [0]) < 0) croak ("unable to dup over old event pipe"); /* should not croak */ - if (epp->fd [1] != epp->fd [0]) - close (epn.fd [0]); + close (epn.fd [0]); + + if (epn.fd [0] == epn.fd [1]) + epn.fd [1] = epp->fd [0]; epn.fd [0] = epp->fd [0]; } @@ -459,7 +474,7 @@ s_epipe_wait (s_epipe *epp) { dTHX; -#ifdef _WIN32 +#if SCHMORP_H_PREFER_SELECT fd_set rfd; int fd = s_epipe_fd (epp); @@ -474,7 +489,7 @@ pfd.fd = s_epipe_fd (epp); pfd.events = POLLIN; - return poll (&pfd, 1, 0); + return poll (&pfd, 1, -1); #endif }