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.227 by root, Sat Sep 7 23:18:23 2013 UTC vs.
Revision 1.233 by root, Thu Jun 25 13:34:28 2015 UTC

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
306static SV * 310static SV *
307newSVaio_wd (aio_wd wd) 311newSVaio_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
312static aio_req 316static aio_req
313SvAIO_REQ (SV *sv) 317SvAIO_REQ (SV *sv)
314{ 318{
333 || SvTYPE (SvRV (sv)) != SVt_PVMG 337 || SvTYPE (SvRV (sv)) != SVt_PVMG
334 || SvSTASH (SvRV (sv)) != aio_wd_stash) 338 || SvSTASH (SvRV (sv)) != aio_wd_stash)
335 croak ("IO::AIO: expected a working directory object as returned by aio_wd"); 339 croak ("IO::AIO: expected a working directory object as returned by aio_wd");
336 340
337 return (aio_wd)(long)SvIVX (SvRV (sv)); 341 return (aio_wd)(long)SvIVX (SvRV (sv));
342}
343
344static SV *
345newmortalFH (int fd, int flags)
346{
347 if (fd < 0)
348 return &PL_sv_undef;
349
350 GV *gv = (GV *)sv_newmortal ();
351 char sym[64];
352 int symlen;
353
354 symlen = snprintf (sym, sizeof (sym), "fd#%d", fd);
355 gv_init (gv, aio_stash, sym, symlen, 0);
356
357 symlen = snprintf (
358 sym,
359 sizeof (sym),
360 "%s&=%d",
361 flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<",
362 fd
363 );
364
365 return do_open (gv, sym, symlen, 0, 0, 0, 0)
366 ? (SV *)gv : &PL_sv_undef;
338} 367}
339 368
340static void 369static void
341aio_grp_feed (aio_req grp) 370aio_grp_feed (aio_req grp)
342{ 371{
470 XPUSHs (sv_2mortal (newSViv (req->int1 & ~(EIO_READDIR_CUSTOM1 | EIO_READDIR_CUSTOM2)))); 499 XPUSHs (sv_2mortal (newSViv (req->int1 & ~(EIO_READDIR_CUSTOM1 | EIO_READDIR_CUSTOM2))));
471 } 500 }
472 break; 501 break;
473 502
474 case EIO_OPEN: 503 case EIO_OPEN:
475 { 504 PUSHs (newmortalFH (req->result, req->int1 & (O_RDONLY | O_WRONLY | O_RDWR)));
476 /* convert fd to fh */
477 SV *fh = &PL_sv_undef;
478
479 if (req->result >= 0)
480 {
481 GV *gv = (GV *)sv_newmortal ();
482 int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR);
483 char sym [64];
484 int symlen;
485
486 symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result);
487 gv_init (gv, aio_stash, sym, symlen, 0);
488
489 symlen = snprintf (
490 sym,
491 sizeof (sym),
492 "%s&=%d",
493 flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<",
494 (int)req->result
495 );
496
497 if (do_open (gv, sym, symlen, 0, 0, 0, 0))
498 fh = (SV *)gv;
499 }
500
501 PUSHs (fh);
502 }
503 break; 505 break;
504 506
505 case EIO_STATVFS: 507 case EIO_STATVFS:
506 case EIO_FSTATVFS: 508 case EIO_FSTATVFS:
507 { 509 {
1029 const_eio (SYNC_FILE_RANGE_WRITE) 1031 const_eio (SYNC_FILE_RANGE_WRITE)
1030 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 1032 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
1031 1033
1032 const_eio (FALLOC_FL_KEEP_SIZE) 1034 const_eio (FALLOC_FL_KEEP_SIZE)
1033 const_eio (FALLOC_FL_PUNCH_HOLE) 1035 const_eio (FALLOC_FL_PUNCH_HOLE)
1036 const_eio (FALLOC_FL_COLLAPSE_RANGE)
1037 const_eio (FALLOC_FL_ZERO_RANGE)
1034 1038
1035 const_eio (READDIR_DENTS) 1039 const_eio (READDIR_DENTS)
1036 const_eio (READDIR_DIRS_FIRST) 1040 const_eio (READDIR_DIRS_FIRST)
1037 const_eio (READDIR_STAT_ORDER) 1041 const_eio (READDIR_STAT_ORDER)
1038 const_eio (READDIR_FOUND_UNKNOWN) 1042 const_eio (READDIR_FOUND_UNKNOWN)
1106 PROTOTYPE: $ 1110 PROTOTYPE: $
1107 CODE: 1111 CODE:
1108 max_outstanding = maxreqs; 1112 max_outstanding = maxreqs;
1109 1113
1110void 1114void
1111aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) 1115aio_wd (SV8 *pathname, SV *callback = &PL_sv_undef)
1112 PPCODE: 1116 PPCODE:
1113{ 1117{
1114 dREQ; 1118 dREQ;
1115 1119
1116 req->type = EIO_WD_OPEN; 1120 req->type = EIO_WD_OPEN;
1118 1122
1119 REQ_SEND; 1123 REQ_SEND;
1120} 1124}
1121 1125
1122void 1126void
1123aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) 1127aio_open (SV8 *pathname, int flags, int mode, SV *callback = &PL_sv_undef)
1124 PPCODE: 1128 PPCODE:
1125{ 1129{
1126 dREQ; 1130 dREQ;
1127 1131
1128 req->type = EIO_OPEN; 1132 req->type = EIO_OPEN;
1132 1136
1133 REQ_SEND; 1137 REQ_SEND;
1134} 1138}
1135 1139
1136void 1140void
1137aio_fsync (SV *fh, SV *callback=&PL_sv_undef) 1141aio_fsync (SV *fh, SV *callback = &PL_sv_undef)
1138 ALIAS: 1142 ALIAS:
1139 aio_fsync = EIO_FSYNC 1143 aio_fsync = EIO_FSYNC
1140 aio_fdatasync = EIO_FDATASYNC 1144 aio_fdatasync = EIO_FDATASYNC
1141 aio_syncfs = EIO_SYNCFS 1145 aio_syncfs = EIO_SYNCFS
1142 PPCODE: 1146 PPCODE:
1150 1154
1151 REQ_SEND; 1155 REQ_SEND;
1152} 1156}
1153 1157
1154void 1158void
1155aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) 1159aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback = &PL_sv_undef)
1156 PPCODE: 1160 PPCODE:
1157{ 1161{
1158 int fd = s_fileno_croak (fh, 0); 1162 int fd = s_fileno_croak (fh, 0);
1159 dREQ; 1163 dREQ;
1160 1164
1167 1171
1168 REQ_SEND; 1172 REQ_SEND;
1169} 1173}
1170 1174
1171void 1175void
1172aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) 1176aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback = &PL_sv_undef)
1173 PPCODE: 1177 PPCODE:
1174{ 1178{
1175 int fd = s_fileno_croak (fh, 0); 1179 int fd = s_fileno_croak (fh, 0);
1176 dREQ; 1180 dREQ;
1177 1181
1184 1188
1185 REQ_SEND; 1189 REQ_SEND;
1186} 1190}
1187 1191
1188void 1192void
1189aio_close (SV *fh, SV *callback=&PL_sv_undef) 1193aio_close (SV *fh, SV *callback = &PL_sv_undef)
1190 PPCODE: 1194 PPCODE:
1191{ 1195{
1192 static int close_fd = -1; /* dummy fd to close fds via dup2 */ 1196 static int close_fd = -1; /* dummy fd to close fds via dup2 */
1193 int fd = s_fileno_croak (fh, 0); 1197 int fd = s_fileno_croak (fh, 0);
1194 dREQ; 1198 dREQ;
1218 1222
1219 REQ_SEND; 1223 REQ_SEND;
1220} 1224}
1221 1225
1222void 1226void
1223aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) 1227aio_seek (SV *fh, SV *offset, int whence, SV *callback = &PL_sv_undef)
1224 PPCODE: 1228 PPCODE:
1225{ 1229{
1226 int fd = s_fileno_croak (fh, 0); 1230 int fd = s_fileno_croak (fh, 0);
1227 dREQ; 1231 dREQ;
1228 1232
1234 1238
1235 REQ_SEND; 1239 REQ_SEND;
1236} 1240}
1237 1241
1238void 1242void
1239aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) 1243aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback = &PL_sv_undef)
1240 ALIAS: 1244 ALIAS:
1241 aio_read = EIO_READ 1245 aio_read = EIO_READ
1242 aio_write = EIO_WRITE 1246 aio_write = EIO_WRITE
1243 PPCODE: 1247 PPCODE:
1244{ 1248{
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 {
1290 REQ_SEND; 1293 REQ_SEND;
1291 } 1294 }
1292} 1295}
1293 1296
1294void 1297void
1295aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1298aio_readlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1296 ALIAS: 1299 ALIAS:
1297 aio_readlink = EIO_READLINK 1300 aio_readlink = EIO_READLINK
1298 aio_realpath = EIO_REALPATH 1301 aio_realpath = EIO_REALPATH
1299 PPCODE: 1302 PPCODE:
1300{ 1303{
1305 1308
1306 REQ_SEND; 1309 REQ_SEND;
1307} 1310}
1308 1311
1309void 1312void
1310aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) 1313aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback = &PL_sv_undef)
1311 PPCODE: 1314 PPCODE:
1312{ 1315{
1313 int ifd = s_fileno_croak (in_fh , 0); 1316 int ifd = s_fileno_croak (in_fh , 0);
1314 int ofd = s_fileno_croak (out_fh, 1); 1317 int ofd = s_fileno_croak (out_fh, 1);
1315 dREQ; 1318 dREQ;
1324 1327
1325 REQ_SEND; 1328 REQ_SEND;
1326} 1329}
1327 1330
1328void 1331void
1329aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) 1332aio_readahead (SV *fh, off_t offset, size_t length, SV *callback = &PL_sv_undef)
1330 PPCODE: 1333 PPCODE:
1331{ 1334{
1332 int fd = s_fileno_croak (fh, 0); 1335 int fd = s_fileno_croak (fh, 0);
1333 dREQ; 1336 dREQ;
1334 1337
1340 1343
1341 REQ_SEND; 1344 REQ_SEND;
1342} 1345}
1343 1346
1344void 1347void
1345aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) 1348aio_stat (SV8 *fh_or_path, SV *callback = &PL_sv_undef)
1346 ALIAS: 1349 ALIAS:
1347 aio_stat = EIO_STAT 1350 aio_stat = EIO_STAT
1348 aio_lstat = EIO_LSTAT 1351 aio_lstat = EIO_LSTAT
1349 aio_statvfs = EIO_STATVFS 1352 aio_statvfs = EIO_STATVFS
1350 PPCODE: 1353 PPCODE:
1371 RETVAL = makedev (maj, min); 1374 RETVAL = makedev (maj, min);
1372 OUTPUT: 1375 OUTPUT:
1373 RETVAL 1376 RETVAL
1374 1377
1375void 1378void
1376aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) 1379aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback = &PL_sv_undef)
1377 PPCODE: 1380 PPCODE:
1378{ 1381{
1379 dREQ; 1382 dREQ;
1380 1383
1381 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; 1384 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.;
1384 1387
1385 REQ_SEND; 1388 REQ_SEND;
1386} 1389}
1387 1390
1388void 1391void
1389aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) 1392aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback = &PL_sv_undef)
1390 PPCODE: 1393 PPCODE:
1391{ 1394{
1392 dREQ; 1395 dREQ;
1393 1396
1394 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; 1397 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1;
1396 1399
1397 REQ_SEND; 1400 REQ_SEND;
1398} 1401}
1399 1402
1400void 1403void
1401aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) 1404aio_chmod (SV8 *fh_or_path, int mode, SV *callback = &PL_sv_undef)
1402 PPCODE: 1405 PPCODE:
1403{ 1406{
1404 dREQ; 1407 dREQ;
1405 1408
1406 req->int2 = mode; 1409 req->int2 = mode;
1408 1411
1409 REQ_SEND; 1412 REQ_SEND;
1410} 1413}
1411 1414
1412void 1415void
1413aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback=&PL_sv_undef) 1416aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback = &PL_sv_undef)
1414 PPCODE: 1417 PPCODE:
1415{ 1418{
1416 dREQ; 1419 dREQ;
1417 1420
1418 req->int2 = SvOK (uid) ? SvIV (uid) : -1; 1421 req->int2 = SvOK (uid) ? SvIV (uid) : -1;
1421 1424
1422 REQ_SEND; 1425 REQ_SEND;
1423} 1426}
1424 1427
1425void 1428void
1426aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) 1429aio_readdirx (SV8 *pathname, IV flags, SV *callback = &PL_sv_undef)
1427 PPCODE: 1430 PPCODE:
1428{ 1431{
1429 dREQ; 1432 dREQ;
1430 1433
1431 req->type = EIO_READDIR; 1434 req->type = EIO_READDIR;
1438 1441
1439 REQ_SEND; 1442 REQ_SEND;
1440} 1443}
1441 1444
1442void 1445void
1443aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) 1446aio_mkdir (SV8 *pathname, int mode, SV *callback = &PL_sv_undef)
1444 PPCODE: 1447 PPCODE:
1445{ 1448{
1446 dREQ; 1449 dREQ;
1447 1450
1448 req->type = EIO_MKDIR; 1451 req->type = EIO_MKDIR;
1451 1454
1452 REQ_SEND; 1455 REQ_SEND;
1453} 1456}
1454 1457
1455void 1458void
1456aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1459aio_unlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1457 ALIAS: 1460 ALIAS:
1458 aio_unlink = EIO_UNLINK 1461 aio_unlink = EIO_UNLINK
1459 aio_rmdir = EIO_RMDIR 1462 aio_rmdir = EIO_RMDIR
1460 aio_readdir = EIO_READDIR 1463 aio_readdir = EIO_READDIR
1461 PPCODE: 1464 PPCODE:
1467 1470
1468 REQ_SEND; 1471 REQ_SEND;
1469} 1472}
1470 1473
1471void 1474void
1472aio_link (SV8 *oldpath, SV8 *newpath, SV *callback=&PL_sv_undef) 1475aio_link (SV8 *oldpath, SV8 *newpath, SV *callback = &PL_sv_undef)
1473 ALIAS: 1476 ALIAS:
1474 aio_link = EIO_LINK 1477 aio_link = EIO_LINK
1475 aio_symlink = EIO_SYMLINK 1478 aio_symlink = EIO_SYMLINK
1476 aio_rename = EIO_RENAME 1479 aio_rename = EIO_RENAME
1477 PPCODE: 1480 PPCODE:
1486 1489
1487 REQ_SEND; 1490 REQ_SEND;
1488} 1491}
1489 1492
1490void 1493void
1491aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback=&PL_sv_undef) 1494aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback = &PL_sv_undef)
1492 PPCODE: 1495 PPCODE:
1493{ 1496{
1494 dREQ; 1497 dREQ;
1495 1498
1496 req->type = EIO_MKNOD; 1499 req->type = EIO_MKNOD;
1500 1503
1501 REQ_SEND; 1504 REQ_SEND;
1502} 1505}
1503 1506
1504void 1507void
1505aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) 1508aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback = &PL_sv_undef)
1506 ALIAS: 1509 ALIAS:
1507 aio_mtouch = EIO_MTOUCH 1510 aio_mtouch = EIO_MTOUCH
1508 aio_msync = EIO_MSYNC 1511 aio_msync = EIO_MSYNC
1509 PPCODE: 1512 PPCODE:
1510{ 1513{
1533 REQ_SEND; 1536 REQ_SEND;
1534 } 1537 }
1535} 1538}
1536 1539
1537void 1540void
1538aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) 1541aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback = &PL_sv_undef)
1539 PPCODE: 1542 PPCODE:
1540{ 1543{
1541 STRLEN svlen; 1544 STRLEN svlen;
1542 char *svptr = SvPVbyte (data, svlen); 1545 char *svptr = SvPVbyte (data, svlen);
1543 UV len = SvUV (length); 1546 UV len = SvUV (length);
1562 REQ_SEND; 1565 REQ_SEND;
1563 } 1566 }
1564} 1567}
1565 1568
1566void 1569void
1567aio_mlockall (IV flags, SV *callback=&PL_sv_undef) 1570aio_mlockall (IV flags, SV *callback = &PL_sv_undef)
1568 PPCODE: 1571 PPCODE:
1569{ 1572{
1570 dREQ; 1573 dREQ;
1571 1574
1572 req->type = EIO_MLOCKALL; 1575 req->type = EIO_MLOCKALL;
1574 1577
1575 REQ_SEND; 1578 REQ_SEND;
1576} 1579}
1577 1580
1578void 1581void
1579aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) 1582aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback = &PL_sv_undef)
1580 PPCODE: 1583 PPCODE:
1581{ 1584{
1582 int fd = s_fileno_croak (fh, 0); 1585 int fd = s_fileno_croak (fh, 0);
1583 dREQ; 1586 dREQ;
1584 1587
1597 1600
1598 REQ_SEND; 1601 REQ_SEND;
1599} 1602}
1600 1603
1601void 1604void
1602aio_busy (double delay, SV *callback=&PL_sv_undef) 1605aio_busy (double delay, SV *callback = &PL_sv_undef)
1603 PPCODE: 1606 PPCODE:
1604{ 1607{
1605 dREQ; 1608 dREQ;
1606 1609
1607 req->type = EIO_BUSY; 1610 req->type = EIO_BUSY;
1609 1612
1610 REQ_SEND; 1613 REQ_SEND;
1611} 1614}
1612 1615
1613void 1616void
1614aio_group (SV *callback=&PL_sv_undef) 1617aio_group (SV *callback = &PL_sv_undef)
1615 PPCODE: 1618 PPCODE:
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
1625void 1631void
1626aio_nop (SV *callback=&PL_sv_undef) 1632aio_nop (SV *callback = &PL_sv_undef)
1627 ALIAS: 1633 ALIAS:
1628 aio_nop = EIO_NOP 1634 aio_nop = EIO_NOP
1629 aio_sync = EIO_SYNC 1635 aio_sync = EIO_SYNC
1630 PPCODE: 1636 PPCODE:
1631{ 1637{
1635 1641
1636 REQ_SEND; 1642 REQ_SEND;
1637} 1643}
1638 1644
1639int 1645int
1640aioreq_pri (int pri = 0) 1646aioreq_pri (int pri = NO_INIT)
1641 CODE: 1647 CODE:
1642 RETVAL = next_pri; 1648 RETVAL = next_pri;
1643 if (items > 0) 1649 if (items > 0)
1644 { 1650 {
1645 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; 1651 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN;
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
1739void 1745void
1740mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) 1746mmap (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);
1772munmap (SV *scalar) 1778munmap (SV *scalar)
1773 CODE: 1779 CODE:
1774 sv_unmagic (scalar, MMAP_MAGIC); 1780 sv_unmagic (scalar, MMAP_MAGIC);
1775 1781
1776int 1782int
1777madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) 1783madvise (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
1807int 1813int
1808munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) 1814munlock (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);
1885 errno = ENOSYS; 1891 errno = ENOSYS;
1886 RETVAL = -1; 1892 RETVAL = -1;
1887#endif 1893#endif
1888 OUTPUT: 1894 OUTPUT:
1889 RETVAL 1895 RETVAL
1896
1897void
1898pipe2 (int flags = 0)
1899 PROTOTYPE: ;$
1900 PPCODE:
1901{
1902 int fd[2];
1903 int res;
1904
1905 if (flags)
1906#if HAVE_PIPE2
1907 res = pipe2 (fd, flags);
1908#else
1909 res = (errno = ENOSYS, -1);
1910#endif
1911 else
1912 res = pipe (fd);
1913
1914 if (!res)
1915 {
1916 EXTEND (SP, 2);
1917 PUSHs (newmortalFH (fd[0], O_RDONLY));
1918 PUSHs (newmortalFH (fd[1], O_WRONLY));
1919 }
1920}
1890 1921
1891void _on_next_submit (SV *cb) 1922void _on_next_submit (SV *cb)
1892 CODE: 1923 CODE:
1893 SvREFCNT_dec (on_next_submit); 1924 SvREFCNT_dec (on_next_submit);
1894 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; 1925 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0;
1929cancel (aio_req_ornot req) 1960cancel (aio_req_ornot req)
1930 CODE: 1961 CODE:
1931 eio_cancel (req); 1962 eio_cancel (req);
1932 1963
1933void 1964void
1934cb (aio_req_ornot req, SV *callback=&PL_sv_undef) 1965cb (aio_req_ornot req, SV *callback = NO_INIT)
1935 PPCODE: 1966 PPCODE:
1936{ 1967{
1937 if (GIMME_V != G_VOID) 1968 if (GIMME_V != G_VOID)
1938 XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef); 1969 XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef);
1939 1970
1940 if (items > 1) 1971 if (items > 1)
1941 { 1972 {
1942 SV *cb_cv =get_cb (callback); 1973 SV *cb_cv = get_cb (callback);
1943 1974
1944 SvREFCNT_dec (req->callback); 1975 SvREFCNT_dec (req->callback);
1945 req->callback = SvREFCNT_inc (cb_cv); 1976 req->callback = SvREFCNT_inc (cb_cv);
1946 } 1977 }
1947} 1978}
2004limit (aio_req grp, int limit) 2035limit (aio_req grp, int limit)
2005 CODE: 2036 CODE:
2006 eio_grp_limit (grp, limit); 2037 eio_grp_limit (grp, limit);
2007 2038
2008void 2039void
2009feed (aio_req grp, SV *callback=&PL_sv_undef) 2040feed (aio_req grp, SV *callback = &PL_sv_undef)
2010 CODE: 2041 CODE:
2011{ 2042{
2012 SvREFCNT_dec (grp->sv2); 2043 SvREFCNT_dec (grp->sv2);
2013 grp->sv2 = newSVsv (callback); 2044 grp->sv2 = newSVsv (callback);
2014 grp->feed = aio_grp_feed; 2045 grp->feed = aio_grp_feed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines