--- IO-AIO/AIO.xs 2011/07/14 22:36:17 1.186 +++ IO-AIO/AIO.xs 2011/07/16 16:46:10 1.187 @@ -24,6 +24,12 @@ /* perl namespace pollution */ #undef VERSION +/* perl stupidly overrides readdir and maybe others */ +/* with thread-unsafe versions, imagine that :( */ +#undef readdir +#undef opendir +#undef closedir + #ifdef _WIN32 # define EIO_STRUCT_DIRENT Direntry_t @@ -36,21 +42,26 @@ # undef write # undef send # undef recv -# undef stat -# undef fstat -# define lstat stat +# undef lstat # undef truncate # undef ftruncate # undef open +# undef link # undef close # undef unlink +# undef mkdir # undef rmdir # undef rename # undef lseek - -# define opendir(fd) (errno = ENOSYS, 0) -# define readdir(fd) (errno = ENOSYS, -1) -# define closedir(fd) (errno = ENOSYS, -1) +# 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 () #else @@ -59,16 +70,9 @@ # include # include # include -# define EIO_STRUCT_DIRENT struct dirent #endif -/* perl stupidly overrides readdir and maybe others */ -/* with thread-unsafe versions, imagine that :( */ -#undef readdir -#undef opendir -#undef closedir - #define EIO_STRUCT_STAT Stat_t /* use NV for 32 bit perls as it allows larger offsets */ @@ -214,6 +218,12 @@ # define PROT_EXEC 0 #endif +#ifndef ST_RDONLY +# define ST_RDONLY 0 +#endif +#ifndef ST_NOSUID +# define ST_NOSUID 0 +#endif #ifndef ST_NODEV # define ST_NODEV 0 #endif @@ -532,6 +542,7 @@ { SV *rv = &PL_sv_undef; +#ifndef _WIN32 if (req->result >= 0) { EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); @@ -551,6 +562,7 @@ hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); } +#endif PUSHs (rv); } @@ -1030,12 +1042,15 @@ aio_close (SV *fh, SV *callback=&PL_sv_undef) PPCODE: { - static int close_pipe = -1; /* dummy fd to close fds via dup2 */ + static int close_fd = -1; /* dummy fd to close fds via dup2 */ int fd = s_fileno_croak (fh, 0); dREQ; - if (close_pipe < 0) + 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 @@ -1043,11 +1058,12 @@ || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) abort (); /*D*/ - close_pipe = pipefd [0]; + close_fd = pipefd [0]; +#endif } req->type = EIO_DUP2; - req->int1 = close_pipe; + req->int1 = close_fd; req->sv2 = newSVsv (fh); req->int2 = fd;