--- IO-AIO/AIO.xs 2011/07/16 16:46:10 1.187 +++ IO-AIO/AIO.xs 2011/07/17 04:20:04 1.188 @@ -32,44 +32,46 @@ #ifdef _WIN32 -# define EIO_STRUCT_DIRENT Direntry_t -# undef malloc -# undef free - -// perl overrides all those nice win32 functions -# undef open -# undef read -# undef write -# undef send -# undef recv -# undef lstat -# undef truncate -# undef ftruncate -# undef open -# undef link -# undef close -# undef unlink -# undef mkdir -# undef rmdir -# undef rename -# undef lseek -# undef opendir -# undef readdir -# undef closedir -# undef chmod -# undef fchmod - -# define opendir(fd) EIO_ERRNO (ENOSYS, 0) -# define readdir(fd) EIO_ENOSYS () -# define closedir(fd) EIO_ENOSYS () + #define EIO_STRUCT_DIRENT Direntry_t + #undef malloc + #undef free + + // perl overrides all those nice libc functions + #undef open + #undef read + #undef write + #undef send + #undef recv + #undef stat + #undef lstat + #undef fstat + #undef truncate + #undef ftruncate + #undef open + #undef link + #undef close + #undef unlink + #undef mkdir + #undef rmdir + #undef rename + #undef lseek + #undef opendir + #undef readdir + #undef closedir + #undef chmod + #undef fchmod + #undef dup + #undef dup2 + #undef abort + #undef pipe #else -# include -# include -# include -# include -# include + #include + #include + #include + #include + #include #endif @@ -116,6 +118,13 @@ #include "libeio/config.h" #include "libeio/eio.h" +static int req_invoke (eio_req *req); +#define EIO_FINISH(req) req_invoke (req) +static void req_destroy (eio_req *grp); +#define EIO_DESTROY(req) req_destroy (req) + +#include "libeio/eio.c" + /* Linux/others */ #ifndef O_ASYNC # define O_ASYNC 0 @@ -317,17 +326,10 @@ # define PAGESIZE sysconf (_SC_PAGESIZE) #endif -static int req_invoke (eio_req *req); -#define EIO_FINISH(req) req_invoke (req) -static void req_destroy (eio_req *grp); -#define EIO_DESTROY(req) req_destroy (req) - enum { FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ }; -#include "libeio/eio.c" - typedef eio_req *aio_req; typedef eio_req *aio_req_ornot; @@ -598,6 +600,7 @@ case EIO_FSTAT: PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; PL_laststatval = req->result; + /* if compilation fails here then perl's Stat_t is not struct _stati64 */ PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); PUSHs (sv_result); break; @@ -659,8 +662,6 @@ static void req_cancel_subs (aio_req grp) { - aio_req sub; - if (grp->type != EIO_GROUP) return; @@ -1048,18 +1049,20 @@ if (expect_false (close_fd < 0)) { -#ifdef _WIN32 - close_fd = _open_osfhandle (socket (AF_INET, SOCK_STREAM, 0), 0); -#else int pipefd [2]; - if (pipe (pipefd) < 0 - || close (pipefd [1]) < 0 - || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) + if ( +#ifdef _WIN32 + _pipe (pipefd, 1, _O_BINARY) < 0 +#else + pipe (pipefd) < 0 + || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0 +#endif + || close (pipefd [1]) < 0 + ) abort (); /*D*/ close_fd = pipefd [0]; -#endif } req->type = EIO_DUP2; @@ -1130,7 +1133,6 @@ aio_realpath = EIO_REALPATH PPCODE: { - SV *data; dREQ; req->type = ix;