--- IO-AIO/AIO.xs 2018/08/14 14:03:14 1.266 +++ IO-AIO/AIO.xs 2018/08/25 19:25:32 1.267 @@ -86,6 +86,7 @@ #undef dup2 #undef abort #undef pipe + #undef utime #define EIO_STRUCT_STAT struct _stati64 #define EIO_STRUCT_STATI64 @@ -131,6 +132,23 @@ # define CTIMENSEC 0 #endif +#if HAVE_ST_BIRTHTIMENSEC +# define BTIMESEC PL_statcache.st_birthtime +# define BTIMENSEC PL_statcache.st_birthtimensec +#elif HAVE_ST_BIRTHTIMESPEC +# define BTIMESEC PL_statcache.st_birthtim.tv_sec +# define BTIMENSEC PL_statcache.st_birthtim.tv_nsec +#else +# define BTIMESEC 0 +# define BTIMENSEC 0 +#endif + +#if HAVE_ST_GEN +# define ST_GEN PL_statcache.st_gen +#else +# define ST_GEN 0 +#endif + #include "schmorp.h" #if HAVE_EVENTFD @@ -406,6 +424,8 @@ /*****************************************************************************/ +static int close_fd; /* dummy fd to close fds via dup2 */ + enum { FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ }; @@ -1303,6 +1323,24 @@ newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); + /* allocate dummy pipe fd for aio_close */ + { + int pipefd [2]; + + 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 + ) + croak ("IO::AIO: unable to create dummy pipe for aio_close"); + + close_fd = pipefd [0]; + } + reinit (); } @@ -1434,28 +1472,9 @@ aio_close (SV *fh, SV *callback = &PL_sv_undef) PPCODE: { - static int close_fd = -1; /* dummy fd to close fds via dup2 */ int fd = s_fileno_croak (fh, 0); dREQ; - if (expect_false (close_fd < 0)) - { - int pipefd [2]; - - 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]; - } - req->type = EIO_DUP2; req->int1 = close_fd; req->sv2 = newSVsv (fh); @@ -1643,28 +1662,36 @@ void st_xtime () ALIAS: - st_atime = 1 - st_mtime = 2 - st_ctime = 4 - st_xtime = 7 - PPCODE: - EXTEND (SP, 3); - if (ix & 1) PUSHs (newSVnv (PL_statcache.st_atime + 1e-9 * ATIMENSEC)); - if (ix & 2) PUSHs (newSVnv (PL_statcache.st_mtime + 1e-9 * MTIMENSEC)); - if (ix & 4) PUSHs (newSVnv (PL_statcache.st_ctime + 1e-9 * CTIMENSEC)); + st_atime = 0x01 + st_mtime = 0x02 + st_ctime = 0x04 + st_btime = 0x08 + st_xtime = 0x0f + PPCODE: + EXTEND (SP, 4); + if (ix & 0x01) PUSHs (newSVnv (PL_statcache.st_atime + 1e-9 * ATIMENSEC)); + if (ix & 0x02) PUSHs (newSVnv (PL_statcache.st_mtime + 1e-9 * MTIMENSEC)); + if (ix & 0x04) PUSHs (newSVnv (PL_statcache.st_ctime + 1e-9 * CTIMENSEC)); + if (ix & 0x08) PUSHs (newSVnv (BTIMESEC + 1e-9 * BTIMENSEC)); void st_xtimensec () ALIAS: - st_atimensec = 1 - st_mtimensec = 2 - st_ctimensec = 4 - st_xtimensec = 7 - PPCODE: - EXTEND (SP, 3); - if (ix & 1) PUSHs (newSViv (ATIMENSEC)); - if (ix & 2) PUSHs (newSViv (MTIMENSEC)); - if (ix & 4) PUSHs (newSViv (CTIMENSEC)); + st_atimensec = 0x01 + st_mtimensec = 0x02 + st_ctimensec = 0x04 + st_btimensec = 0x08 + st_xtimensec = 0x0f + st_btimesec = 0x10 + st_gen = 0x20 + PPCODE: + EXTEND (SP, 4); + if (ix & 0x01) PUSHs (newSViv (ATIMENSEC)); + if (ix & 0x02) PUSHs (newSViv (MTIMENSEC)); + if (ix & 0x04) PUSHs (newSViv (CTIMENSEC)); + if (ix & 0x08) PUSHs (newSViv (BTIMENSEC)); + if (ix & 0x10) PUSHs (newSVuv (BTIMESEC)); + if (ix & 0x20) PUSHs (newSVuv (ST_GEN)); UV major (UV dev) @@ -2160,7 +2187,7 @@ RETVAL int -madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) +madvise (SV *scalar, IV offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) ALIAS: mprotect = 1 CODE: @@ -2191,7 +2218,7 @@ RETVAL int -munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef) +munlock (SV *scalar, IV offset = 0, SV *length = &PL_sv_undef) CODE: { STRLEN svlen;