… | |
… | |
19 | |
19 | |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
21 | # include <sys/mman.h> |
21 | # include <sys/mman.h> |
22 | #endif |
22 | #endif |
23 | |
23 | |
24 | #if __linux__ |
24 | /* the incompetent fool that created musl keeps __linux__, refuses |
|
|
25 | * to implement any linux standard apis, and also has no way to test |
|
|
26 | * for his broken iplementation. on't complain if this fails for you. |
|
|
27 | */ |
|
|
28 | #if __linux__ && (defined __GLIBC__ || defined __UCLIBC__) |
25 | # include <linux/fs.h> |
29 | # include <linux/fs.h> |
26 | # ifdef FS_IOC_FIEMAP |
30 | # ifdef FS_IOC_FIEMAP |
27 | # include <linux/types.h> |
31 | # include <linux/types.h> |
28 | # include <linux/fiemap.h> |
32 | # include <linux/fiemap.h> |
29 | # define HAVE_FIEMAP 1 |
33 | # define HAVE_FIEMAP 1 |
… | |
… | |
304 | } |
308 | } |
305 | |
309 | |
306 | static SV * |
310 | static SV * |
307 | newSVaio_wd (aio_wd wd) |
311 | newSVaio_wd (aio_wd wd) |
308 | { |
312 | { |
309 | return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); |
313 | return sv_bless (newRV_noinc (newSViv ((intptr_t)wd)), aio_wd_stash); |
310 | } |
314 | } |
311 | |
315 | |
312 | static aio_req |
316 | static aio_req |
313 | SvAIO_REQ (SV *sv) |
317 | SvAIO_REQ (SV *sv) |
314 | { |
318 | { |
… | |
… | |
1260 | len = svlen - dataoffset; |
1264 | len = svlen - dataoffset; |
1261 | } |
1265 | } |
1262 | else |
1266 | else |
1263 | { |
1267 | { |
1264 | /* read: check type and grow scalar as necessary */ |
1268 | /* read: check type and grow scalar as necessary */ |
1265 | SvUPGRADE (data, SVt_PV); |
|
|
1266 | if (SvLEN (data) >= SvCUR (data)) |
1269 | if (!SvPOK (data) || SvLEN (data) >= SvCUR (data)) |
1267 | svptr = SvGROW (data, len + dataoffset + 1); |
1270 | svptr = sv_grow (data, len + dataoffset + 1); |
1268 | else if (SvCUR (data) < len + dataoffset) |
1271 | else if (SvCUR (data) < len + dataoffset) |
1269 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1272 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1270 | } |
1273 | } |
1271 | |
1274 | |
1272 | { |
1275 | { |
… | |
… | |
1616 | { |
1619 | { |
1617 | dREQ; |
1620 | dREQ; |
1618 | |
1621 | |
1619 | req->type = EIO_GROUP; |
1622 | req->type = EIO_GROUP; |
1620 | |
1623 | |
|
|
1624 | PUTBACK; |
1621 | req_submit (req); |
1625 | req_submit (req); |
|
|
1626 | SPAGAIN; |
|
|
1627 | |
1622 | XPUSHs (req_sv (req, aio_grp_stash)); |
1628 | XPUSHs (req_sv (req, aio_grp_stash)); |
1623 | } |
1629 | } |
1624 | |
1630 | |
1625 | void |
1631 | void |
1626 | aio_nop (SV *callback=&PL_sv_undef) |
1632 | aio_nop (SV *callback=&PL_sv_undef) |
… | |
… | |
1735 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1741 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1736 | OUTPUT: |
1742 | OUTPUT: |
1737 | RETVAL |
1743 | RETVAL |
1738 | |
1744 | |
1739 | void |
1745 | void |
1740 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1746 | mmap (SV *scalar, STRLEN length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1741 | PPCODE: |
1747 | PPCODE: |
1742 | sv_unmagic (scalar, MMAP_MAGIC); |
1748 | sv_unmagic (scalar, MMAP_MAGIC); |
1743 | { |
1749 | { |
1744 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1750 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1745 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1751 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1772 | munmap (SV *scalar) |
1778 | munmap (SV *scalar) |
1773 | CODE: |
1779 | CODE: |
1774 | sv_unmagic (scalar, MMAP_MAGIC); |
1780 | sv_unmagic (scalar, MMAP_MAGIC); |
1775 | |
1781 | |
1776 | int |
1782 | int |
1777 | madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1783 | madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1778 | ALIAS: |
1784 | ALIAS: |
1779 | mprotect = 1 |
1785 | mprotect = 1 |
1780 | CODE: |
1786 | CODE: |
1781 | { |
1787 | { |
1782 | STRLEN svlen; |
1788 | STRLEN svlen; |
1783 | void *addr = SvPVbyte (scalar, svlen); |
1789 | void *addr = SvPVbyte (scalar, svlen); |
1784 | size_t len = SvUV (length); |
1790 | STRLEN len = SvUV (length); |
1785 | |
1791 | |
1786 | if (offset < 0) |
1792 | if (offset < 0) |
1787 | offset += svlen; |
1793 | offset += svlen; |
1788 | |
1794 | |
1789 | if (offset < 0 || offset > svlen) |
1795 | if (offset < 0 || offset > svlen) |
… | |
… | |
1803 | } |
1809 | } |
1804 | OUTPUT: |
1810 | OUTPUT: |
1805 | RETVAL |
1811 | RETVAL |
1806 | |
1812 | |
1807 | int |
1813 | int |
1808 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1814 | munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef) |
1809 | CODE: |
1815 | CODE: |
1810 | { |
1816 | { |
1811 | STRLEN svlen; |
1817 | STRLEN svlen; |
1812 | void *addr = SvPVbyte (scalar, svlen); |
1818 | void *addr = SvPVbyte (scalar, svlen); |
1813 | size_t len = SvUV (length); |
1819 | size_t len = SvUV (length); |
… | |
… | |
1868 | RETVAL = tee (rfh, wfh, length, flags); |
1874 | RETVAL = tee (rfh, wfh, length, flags); |
1869 | #else |
1875 | #else |
1870 | RETVAL = EIO_ENOSYS (); |
1876 | RETVAL = EIO_ENOSYS (); |
1871 | #endif |
1877 | #endif |
1872 | OUTPUT: |
1878 | OUTPUT: |
|
|
1879 | RETVAL |
|
|
1880 | |
|
|
1881 | int |
|
|
1882 | pipesize (aio_rfd rfh, int new_size = -1) |
|
|
1883 | PROTOTYPE: $;$ |
|
|
1884 | CODE: |
|
|
1885 | #if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) |
|
|
1886 | if (new_size >= 0) |
|
|
1887 | RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size); |
|
|
1888 | else |
|
|
1889 | RETVAL = fcntl (rfh, F_GETPIPE_SZ); |
|
|
1890 | #else |
|
|
1891 | errno = ENOSYS; |
|
|
1892 | RETVAL = -1; |
|
|
1893 | #endif |
|
|
1894 | OUTPUT: |
1873 | RETVAL |
1895 | RETVAL |
1874 | |
1896 | |
1875 | void _on_next_submit (SV *cb) |
1897 | void _on_next_submit (SV *cb) |
1876 | CODE: |
1898 | CODE: |
1877 | SvREFCNT_dec (on_next_submit); |
1899 | SvREFCNT_dec (on_next_submit); |