--- IO-AIO/AIO.xs 2018/01/06 01:04:42 1.251 +++ IO-AIO/AIO.xs 2018/02/20 04:32:59 1.253 @@ -108,6 +108,10 @@ #include "libeio/config.h" +#if HAVE_EVENTFD +# include +#endif + #if HAVE_RLIMITS #include #include @@ -701,7 +705,13 @@ sv_set_foreign (req->sv2, &sysfree_vtbl, req->ptr2, req->result); } else - SvCUR_set (req->sv2, req->result); + { + SvCUR_set (req->sv2, req->result); + *SvEND (req->sv2) = 0; + SvPOK_only (req->sv2); + } + + SvSETMAGIC (req->sv2); } PUSHs (sv_result); @@ -1157,6 +1167,10 @@ const_iv (SPLICE_F_MORE) const_iv (SPLICE_F_GIFT) + const_iv (EFD_CLOEXEC) + const_iv (EFD_NONBLOCK) + const_iv (EFD_SEMAPHORE) + /* these are libeio constants, and are independent of gendef0 */ const_eio (SEEK_SET) const_eio (SEEK_CUR) @@ -1417,7 +1431,7 @@ { /* read: check type and grow scalar as necessary */ if (!SvPOK (data) || SvLEN (data) >= SvCUR (data)) - svptr = sv_grow (data, len + dataoffset); + svptr = sv_grow (data, len + dataoffset + 1); else if (SvCUR (data) < len + dataoffset) croak ("length + dataoffset outside of scalar, and cannot grow"); } @@ -1821,7 +1835,7 @@ if (length) /* known length, directly read into scalar */ { if (!SvPOK (data) || SvLEN (data) >= SvCUR (data)) - svptr = sv_grow (data, length); + svptr = sv_grow (data, length + 1); else if (SvCUR (data) < length) croak ("length outside of scalar, and cannot grow"); else @@ -2152,6 +2166,20 @@ } } +void +eventfd (unsigned int initval = 0, int flags = 0) + PPCODE: +{ + int fd; +#if HAVE_EVENTFD + fd = eventfd (initval, flags); +#else + fd = (errno = ENOSYS, -1); +#endif + + XPUSHs (newmortalFH (fd, O_RDWR)); +} + UV get_fdlimit () CODE: