ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.212 by root, Sun Apr 8 00:11:50 2012 UTC vs.
Revision 1.217 by root, Fri Jul 27 17:24:06 2012 UTC

698} 698}
699 699
700/*****************************************************************************/ 700/*****************************************************************************/
701 701
702#if !_POSIX_MAPPED_FILES 702#if !_POSIX_MAPPED_FILES
703# define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) 703# define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS ()
704# define munmap(addr,length) (errno = ENOSYS, -1) 704# define munmap(addr,length) EIO_ENOSYS ()
705#endif 705#endif
706 706
707#if !_POSIX_MEMORY_PROTECTION 707#if !_POSIX_MEMORY_PROTECTION
708# define mprotect(addr,len,prot) (errno = ENOSYS, -1) 708# define mprotect(addr,len,prot) EIO_ENOSYS ()
709# define PROT_NONE 0 709# define PROT_NONE 0
710# define PROT_WRITE 0 710# define PROT_WRITE 0
711# define MAP_PRIVATE 0 711# define MAP_PRIVATE 0
712# define MAP_SHARED 0 712# define MAP_SHARED 0
713# define MAP_FIXED 0 713# define MAP_FIXED 0
956 const_iv (FIEMAP_EXTENT_DATA_TAIL) 956 const_iv (FIEMAP_EXTENT_DATA_TAIL)
957 const_iv (FIEMAP_EXTENT_UNWRITTEN) 957 const_iv (FIEMAP_EXTENT_UNWRITTEN)
958 const_iv (FIEMAP_EXTENT_MERGED) 958 const_iv (FIEMAP_EXTENT_MERGED)
959 const_iv (FIEMAP_EXTENT_SHARED) 959 const_iv (FIEMAP_EXTENT_SHARED)
960 960
961 const_iv (SPLICE_F_MOVE)
962 const_iv (SPLICE_F_NONBLOCK)
963 const_iv (SPLICE_F_MORE)
964 const_iv (SPLICE_F_GIFT)
965
966 const_iv (SEEK_DATA)
967 const_iv (SEEK_HOLE)
968
969 /* libeio constants */
961 const_eio (SEEK_SET) 970 const_eio (SEEK_SET)
962 const_eio (SEEK_CUR) 971 const_eio (SEEK_CUR)
963 const_eio (SEEK_END) 972 const_eio (SEEK_END)
964 973
965 const_eio (MCL_FUTURE) 974 const_eio (MCL_FUTURE)
974 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) 983 const_eio (SYNC_FILE_RANGE_WAIT_BEFORE)
975 const_eio (SYNC_FILE_RANGE_WRITE) 984 const_eio (SYNC_FILE_RANGE_WRITE)
976 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 985 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
977 986
978 const_eio (FALLOC_FL_KEEP_SIZE) 987 const_eio (FALLOC_FL_KEEP_SIZE)
988 const_eio (FALLOC_FL_PUNCH_HOLE)
979 989
980 const_eio (READDIR_DENTS) 990 const_eio (READDIR_DENTS)
981 const_eio (READDIR_DIRS_FIRST) 991 const_eio (READDIR_DIRS_FIRST)
982 const_eio (READDIR_STAT_ORDER) 992 const_eio (READDIR_STAT_ORDER)
983 const_eio (READDIR_FOUND_UNKNOWN) 993 const_eio (READDIR_FOUND_UNKNOWN)
1206 } 1216 }
1207 else 1217 else
1208 { 1218 {
1209 /* read: check type and grow scalar as necessary */ 1219 /* read: check type and grow scalar as necessary */
1210 SvUPGRADE (data, SVt_PV); 1220 SvUPGRADE (data, SVt_PV);
1221 if (SvLEN (data) >= SvCUR (data))
1211 svptr = SvGROW (data, len + dataoffset + 1); 1222 svptr = SvGROW (data, len + dataoffset + 1);
1223 else if (SvCUR (data) < len + dataoffset)
1224 croak ("length + dataoffset outside of scalar, and cannot grow");
1212 } 1225 }
1213 1226
1214 { 1227 {
1215 dREQ; 1228 dREQ;
1216 1229
1519 1532
1520void 1533void
1521aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) 1534aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef)
1522 PPCODE: 1535 PPCODE:
1523{ 1536{
1524 int fd = s_fileno_croak (fh, 0); 1537 int fd = s_fileno_croak (fh, 0);
1525 dREQ; 1538 dREQ;
1526 1539
1527 req->type = EIO_CUSTOM; 1540 req->type = EIO_CUSTOM;
1528 req->sv1 = newSVsv (fh); 1541 req->sv1 = newSVsv (fh);
1529 req->int1 = fd; 1542 req->int1 = fd;
1677 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); 1690 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count);
1678 OUTPUT: 1691 OUTPUT:
1679 RETVAL 1692 RETVAL
1680 1693
1681void 1694void
1682mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) 1695mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0)
1683 PPCODE: 1696 PPCODE:
1684 sv_unmagic (scalar, MMAP_MAGIC); 1697 sv_unmagic (scalar, MMAP_MAGIC);
1685{ 1698{
1686 int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; 1699 int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1;
1687 void *addr = (void *)mmap (0, length, prot, flags, fd, offset); 1700 void *addr = (void *)mmap (0, length, prot, flags, fd, offset);
1720 ALIAS: 1733 ALIAS:
1721 mprotect = 1 1734 mprotect = 1
1722 CODE: 1735 CODE:
1723{ 1736{
1724 STRLEN svlen; 1737 STRLEN svlen;
1725 void *addr = SvPVbyte (scalar, svlen); 1738 void *addr = SvPVbyte (scalar, svlen);
1726 size_t len = SvUV (length); 1739 size_t len = SvUV (length);
1727 1740
1728 if (offset < 0) 1741 if (offset < 0)
1729 offset += svlen; 1742 offset += svlen;
1730 1743
1766 addr = (void *)(((intptr_t)addr) + offset); 1779 addr = (void *)(((intptr_t)addr) + offset);
1767 eio_page_align (&addr, &len); 1780 eio_page_align (&addr, &len);
1768#if _POSIX_MEMLOCK_RANGE 1781#if _POSIX_MEMLOCK_RANGE
1769 RETVAL = munlock (addr, len); 1782 RETVAL = munlock (addr, len);
1770#else 1783#else
1771 RETVAL = ((errno = ENOSYS), -1); 1784 RETVAL = EIO_ENOSYS ();
1772#endif 1785#endif
1773} 1786}
1774 OUTPUT: 1787 OUTPUT:
1775 RETVAL 1788 RETVAL
1776 1789
1778munlockall () 1791munlockall ()
1779 CODE: 1792 CODE:
1780#if _POSIX_MEMLOCK 1793#if _POSIX_MEMLOCK
1781 munlockall (); 1794 munlockall ();
1782#else 1795#else
1783 RETVAL = -1; 1796 RETVAL = EIO_ENOSYS ();
1784 errno = ENOSYS;
1785#endif 1797#endif
1786 OUTPUT: 1798 OUTPUT:
1799 RETVAL
1800
1801int
1802splice (aio_rfd rfh, SV *off_in, aio_wfd wfh, SV *off_out, size_t length, unsigned int flags)
1803 CODE:
1804{
1805#if HAVE_LINUX_SPLICE
1806 loff_t off_in_, off_out_;
1807 RETVAL = splice (
1808 rfh, SvOK (off_in ) ? (off_in_ = SvVAL64 (off_in )), &off_in_ : 0,
1809 wfh, SvOK (off_out) ? (off_out_ = SvVAL64 (off_out)), &off_out_ : 0,
1810 length, flags
1811 );
1812#else
1813 RETVAL = EIO_ENOSYS ();
1814#endif
1815}
1816 OUTPUT:
1817 RETVAL
1818
1819int
1820tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags)
1821 CODE:
1822#if HAVE_LINUX_SPLICE
1823 RETVAL = tee (rfh, wfh, length, flags);
1824#else
1825 RETVAL = EIO_ENOSYS ();
1826#endif
1827 OUTPUT:
1787 RETVAL 1828 RETVAL
1788 1829
1789void _on_next_submit (SV *cb) 1830void _on_next_submit (SV *cb)
1790 CODE: 1831 CODE:
1791 SvREFCNT_dec (on_next_submit); 1832 SvREFCNT_dec (on_next_submit);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines