--- IO-AIO/AIO.xs 2012/12/29 09:35:39 1.225 +++ IO-AIO/AIO.xs 2015/02/11 19:32:36 1.231 @@ -21,7 +21,11 @@ # include #endif -#if __linux__ +/* the incompetent fool that created musl keeps __linux__, refuses + * to implement any linux standard apis, and also has no way to test + * for his broken iplementation. on't complain if this fails for you. + */ +#if __linux__ && (defined __GLIBC__ || defined __UCLIBC__) # include # ifdef FS_IOC_FIEMAP # include @@ -200,7 +204,7 @@ goto done; /* else we have to loop - - * it would be tempting (atcually I tried that first) to just query the + * it would be tempting (actually I tried that first) to just query the * number of extents needed, but linux often feels like not returning all * extents, without telling us it left any out. this complicates * this quite a bit. @@ -223,6 +227,9 @@ if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) return; + if (!incmap->fm_mapped_extents) + goto done; + count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); errno = ENOMEM; @@ -303,7 +310,7 @@ static SV * newSVaio_wd (aio_wd wd) { - return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); + return sv_bless (newRV_noinc (newSViv ((intptr_t)wd)), aio_wd_stash); } static aio_req @@ -1259,9 +1266,8 @@ else { /* read: check type and grow scalar as necessary */ - SvUPGRADE (data, SVt_PV); - if (SvLEN (data) >= SvCUR (data)) - svptr = SvGROW (data, len + dataoffset + 1); + if (!SvPOK (data) || SvLEN (data) >= SvCUR (data)) + svptr = sv_grow (data, len + dataoffset + 1); else if (SvCUR (data) < len + dataoffset) croak ("length + dataoffset outside of scalar, and cannot grow"); } @@ -1615,7 +1621,10 @@ req->type = EIO_GROUP; + PUTBACK; req_submit (req); + SPAGAIN; + XPUSHs (req_sv (req, aio_grp_stash)); } @@ -1734,7 +1743,7 @@ RETVAL void -mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) +mmap (SV *scalar, STRLEN length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) PPCODE: sv_unmagic (scalar, MMAP_MAGIC); { @@ -1771,14 +1780,14 @@ sv_unmagic (scalar, MMAP_MAGIC); int -madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) +madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) ALIAS: mprotect = 1 CODE: { STRLEN svlen; void *addr = SvPVbyte (scalar, svlen); - size_t len = SvUV (length); + STRLEN len = SvUV (length); if (offset < 0) offset += svlen; @@ -1802,7 +1811,7 @@ RETVAL int -munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) +munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef) CODE: { STRLEN svlen; @@ -1869,6 +1878,22 @@ OUTPUT: RETVAL +int +pipesize (aio_rfd rfh, int new_size = -1) + PROTOTYPE: $;$ + CODE: +#if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) + if (new_size >= 0) + RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size); + else + RETVAL = fcntl (rfh, F_GETPIPE_SZ); +#else + errno = ENOSYS; + RETVAL = -1; +#endif + OUTPUT: + RETVAL + void _on_next_submit (SV *cb) CODE: SvREFCNT_dec (on_next_submit);