… | |
… | |
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 | { |
… | |
… | |
1738 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1741 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1739 | OUTPUT: |
1742 | OUTPUT: |
1740 | RETVAL |
1743 | RETVAL |
1741 | |
1744 | |
1742 | void |
1745 | void |
1743 | 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) |
1744 | PPCODE: |
1747 | PPCODE: |
1745 | sv_unmagic (scalar, MMAP_MAGIC); |
1748 | sv_unmagic (scalar, MMAP_MAGIC); |
1746 | { |
1749 | { |
1747 | 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; |
1748 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1751 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1775 | munmap (SV *scalar) |
1778 | munmap (SV *scalar) |
1776 | CODE: |
1779 | CODE: |
1777 | sv_unmagic (scalar, MMAP_MAGIC); |
1780 | sv_unmagic (scalar, MMAP_MAGIC); |
1778 | |
1781 | |
1779 | int |
1782 | int |
1780 | 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) |
1781 | ALIAS: |
1784 | ALIAS: |
1782 | mprotect = 1 |
1785 | mprotect = 1 |
1783 | CODE: |
1786 | CODE: |
1784 | { |
1787 | { |
1785 | STRLEN svlen; |
1788 | STRLEN svlen; |
1786 | void *addr = SvPVbyte (scalar, svlen); |
1789 | void *addr = SvPVbyte (scalar, svlen); |
1787 | size_t len = SvUV (length); |
1790 | STRLEN len = SvUV (length); |
1788 | |
1791 | |
1789 | if (offset < 0) |
1792 | if (offset < 0) |
1790 | offset += svlen; |
1793 | offset += svlen; |
1791 | |
1794 | |
1792 | if (offset < 0 || offset > svlen) |
1795 | if (offset < 0 || offset > svlen) |
… | |
… | |
1806 | } |
1809 | } |
1807 | OUTPUT: |
1810 | OUTPUT: |
1808 | RETVAL |
1811 | RETVAL |
1809 | |
1812 | |
1810 | int |
1813 | int |
1811 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1814 | munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef) |
1812 | CODE: |
1815 | CODE: |
1813 | { |
1816 | { |
1814 | STRLEN svlen; |
1817 | STRLEN svlen; |
1815 | void *addr = SvPVbyte (scalar, svlen); |
1818 | void *addr = SvPVbyte (scalar, svlen); |
1816 | size_t len = SvUV (length); |
1819 | size_t len = SvUV (length); |