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.229 by root, Fri Apr 11 05:19:40 2014 UTC vs.
Revision 1.234 by root, Thu Jun 25 15:20:11 2015 UTC

308} 308}
309 309
310static SV * 310static SV *
311newSVaio_wd (aio_wd wd) 311newSVaio_wd (aio_wd wd)
312{ 312{
313 return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); 313 return sv_bless (newRV_noinc (newSViv ((intptr_t)wd)), aio_wd_stash);
314} 314}
315 315
316static aio_req 316static aio_req
317SvAIO_REQ (SV *sv) 317SvAIO_REQ (SV *sv)
318{ 318{
337 || SvTYPE (SvRV (sv)) != SVt_PVMG 337 || SvTYPE (SvRV (sv)) != SVt_PVMG
338 || SvSTASH (SvRV (sv)) != aio_wd_stash) 338 || SvSTASH (SvRV (sv)) != aio_wd_stash)
339 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");
340 340
341 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;
342} 367}
343 368
344static void 369static void
345aio_grp_feed (aio_req grp) 370aio_grp_feed (aio_req grp)
346{ 371{
474 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))));
475 } 500 }
476 break; 501 break;
477 502
478 case EIO_OPEN: 503 case EIO_OPEN:
479 { 504 PUSHs (newmortalFH (req->result, req->int1 & (O_RDONLY | O_WRONLY | O_RDWR)));
480 /* convert fd to fh */
481 SV *fh = &PL_sv_undef;
482
483 if (req->result >= 0)
484 {
485 GV *gv = (GV *)sv_newmortal ();
486 int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR);
487 char sym [64];
488 int symlen;
489
490 symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result);
491 gv_init (gv, aio_stash, sym, symlen, 0);
492
493 symlen = snprintf (
494 sym,
495 sizeof (sym),
496 "%s&=%d",
497 flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<",
498 (int)req->result
499 );
500
501 if (do_open (gv, sym, symlen, 0, 0, 0, 0))
502 fh = (SV *)gv;
503 }
504
505 PUSHs (fh);
506 }
507 break; 505 break;
508 506
509 case EIO_STATVFS: 507 case EIO_STATVFS:
510 case EIO_FSTATVFS: 508 case EIO_FSTATVFS:
511 { 509 {
935 const_iv (O_SEARCH) 933 const_iv (O_SEARCH)
936 const_iv (O_DIRECTORY) 934 const_iv (O_DIRECTORY)
937 const_iv (O_DSYNC) 935 const_iv (O_DSYNC)
938 const_iv (O_RSYNC) 936 const_iv (O_RSYNC)
939 const_iv (O_SYNC) 937 const_iv (O_SYNC)
938 const_iv (O_PATH)
939 const_iv (O_TMPFILE)
940 const_iv (O_TTY_INIT) 940 const_iv (O_TTY_INIT)
941 941
942 const_iv (S_IFIFO) 942 const_iv (S_IFIFO)
943 const_iv (S_IFCHR) 943 const_iv (S_IFCHR)
944 const_iv (S_IFBLK) 944 const_iv (S_IFBLK)
1033 const_eio (SYNC_FILE_RANGE_WRITE) 1033 const_eio (SYNC_FILE_RANGE_WRITE)
1034 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 1034 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
1035 1035
1036 const_eio (FALLOC_FL_KEEP_SIZE) 1036 const_eio (FALLOC_FL_KEEP_SIZE)
1037 const_eio (FALLOC_FL_PUNCH_HOLE) 1037 const_eio (FALLOC_FL_PUNCH_HOLE)
1038 const_eio (FALLOC_FL_COLLAPSE_RANGE)
1039 const_eio (FALLOC_FL_ZERO_RANGE)
1038 1040
1039 const_eio (READDIR_DENTS) 1041 const_eio (READDIR_DENTS)
1040 const_eio (READDIR_DIRS_FIRST) 1042 const_eio (READDIR_DIRS_FIRST)
1041 const_eio (READDIR_STAT_ORDER) 1043 const_eio (READDIR_STAT_ORDER)
1042 const_eio (READDIR_FOUND_UNKNOWN) 1044 const_eio (READDIR_FOUND_UNKNOWN)
1110 PROTOTYPE: $ 1112 PROTOTYPE: $
1111 CODE: 1113 CODE:
1112 max_outstanding = maxreqs; 1114 max_outstanding = maxreqs;
1113 1115
1114void 1116void
1115aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) 1117aio_wd (SV8 *pathname, SV *callback = &PL_sv_undef)
1116 PPCODE: 1118 PPCODE:
1117{ 1119{
1118 dREQ; 1120 dREQ;
1119 1121
1120 req->type = EIO_WD_OPEN; 1122 req->type = EIO_WD_OPEN;
1122 1124
1123 REQ_SEND; 1125 REQ_SEND;
1124} 1126}
1125 1127
1126void 1128void
1127aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) 1129aio_open (SV8 *pathname, int flags, int mode, SV *callback = &PL_sv_undef)
1128 PPCODE: 1130 PPCODE:
1129{ 1131{
1130 dREQ; 1132 dREQ;
1131 1133
1132 req->type = EIO_OPEN; 1134 req->type = EIO_OPEN;
1136 1138
1137 REQ_SEND; 1139 REQ_SEND;
1138} 1140}
1139 1141
1140void 1142void
1141aio_fsync (SV *fh, SV *callback=&PL_sv_undef) 1143aio_fsync (SV *fh, SV *callback = &PL_sv_undef)
1142 ALIAS: 1144 ALIAS:
1143 aio_fsync = EIO_FSYNC 1145 aio_fsync = EIO_FSYNC
1144 aio_fdatasync = EIO_FDATASYNC 1146 aio_fdatasync = EIO_FDATASYNC
1145 aio_syncfs = EIO_SYNCFS 1147 aio_syncfs = EIO_SYNCFS
1146 PPCODE: 1148 PPCODE:
1154 1156
1155 REQ_SEND; 1157 REQ_SEND;
1156} 1158}
1157 1159
1158void 1160void
1159aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) 1161aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback = &PL_sv_undef)
1160 PPCODE: 1162 PPCODE:
1161{ 1163{
1162 int fd = s_fileno_croak (fh, 0); 1164 int fd = s_fileno_croak (fh, 0);
1163 dREQ; 1165 dREQ;
1164 1166
1171 1173
1172 REQ_SEND; 1174 REQ_SEND;
1173} 1175}
1174 1176
1175void 1177void
1176aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) 1178aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback = &PL_sv_undef)
1177 PPCODE: 1179 PPCODE:
1178{ 1180{
1179 int fd = s_fileno_croak (fh, 0); 1181 int fd = s_fileno_croak (fh, 0);
1180 dREQ; 1182 dREQ;
1181 1183
1188 1190
1189 REQ_SEND; 1191 REQ_SEND;
1190} 1192}
1191 1193
1192void 1194void
1193aio_close (SV *fh, SV *callback=&PL_sv_undef) 1195aio_close (SV *fh, SV *callback = &PL_sv_undef)
1194 PPCODE: 1196 PPCODE:
1195{ 1197{
1196 static int close_fd = -1; /* dummy fd to close fds via dup2 */ 1198 static int close_fd = -1; /* dummy fd to close fds via dup2 */
1197 int fd = s_fileno_croak (fh, 0); 1199 int fd = s_fileno_croak (fh, 0);
1198 dREQ; 1200 dREQ;
1222 1224
1223 REQ_SEND; 1225 REQ_SEND;
1224} 1226}
1225 1227
1226void 1228void
1227aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) 1229aio_seek (SV *fh, SV *offset, int whence, SV *callback = &PL_sv_undef)
1228 PPCODE: 1230 PPCODE:
1229{ 1231{
1230 int fd = s_fileno_croak (fh, 0); 1232 int fd = s_fileno_croak (fh, 0);
1231 dREQ; 1233 dREQ;
1232 1234
1238 1240
1239 REQ_SEND; 1241 REQ_SEND;
1240} 1242}
1241 1243
1242void 1244void
1243aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) 1245aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback = &PL_sv_undef)
1244 ALIAS: 1246 ALIAS:
1245 aio_read = EIO_READ 1247 aio_read = EIO_READ
1246 aio_write = EIO_WRITE 1248 aio_write = EIO_WRITE
1247 PPCODE: 1249 PPCODE:
1248{ 1250{
1264 len = svlen - dataoffset; 1266 len = svlen - dataoffset;
1265 } 1267 }
1266 else 1268 else
1267 { 1269 {
1268 /* read: check type and grow scalar as necessary */ 1270 /* read: check type and grow scalar as necessary */
1269 SvUPGRADE (data, SVt_PV);
1270 if (SvLEN (data) >= SvCUR (data)) 1271 if (!SvPOK (data) || SvLEN (data) >= SvCUR (data))
1271 svptr = SvGROW (data, len + dataoffset + 1); 1272 svptr = sv_grow (data, len + dataoffset + 1);
1272 else if (SvCUR (data) < len + dataoffset) 1273 else if (SvCUR (data) < len + dataoffset)
1273 croak ("length + dataoffset outside of scalar, and cannot grow"); 1274 croak ("length + dataoffset outside of scalar, and cannot grow");
1274 } 1275 }
1275 1276
1276 { 1277 {
1294 REQ_SEND; 1295 REQ_SEND;
1295 } 1296 }
1296} 1297}
1297 1298
1298void 1299void
1299aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1300aio_readlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1300 ALIAS: 1301 ALIAS:
1301 aio_readlink = EIO_READLINK 1302 aio_readlink = EIO_READLINK
1302 aio_realpath = EIO_REALPATH 1303 aio_realpath = EIO_REALPATH
1303 PPCODE: 1304 PPCODE:
1304{ 1305{
1309 1310
1310 REQ_SEND; 1311 REQ_SEND;
1311} 1312}
1312 1313
1313void 1314void
1314aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) 1315aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback = &PL_sv_undef)
1315 PPCODE: 1316 PPCODE:
1316{ 1317{
1317 int ifd = s_fileno_croak (in_fh , 0); 1318 int ifd = s_fileno_croak (in_fh , 0);
1318 int ofd = s_fileno_croak (out_fh, 1); 1319 int ofd = s_fileno_croak (out_fh, 1);
1319 dREQ; 1320 dREQ;
1328 1329
1329 REQ_SEND; 1330 REQ_SEND;
1330} 1331}
1331 1332
1332void 1333void
1333aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) 1334aio_readahead (SV *fh, off_t offset, size_t length, SV *callback = &PL_sv_undef)
1334 PPCODE: 1335 PPCODE:
1335{ 1336{
1336 int fd = s_fileno_croak (fh, 0); 1337 int fd = s_fileno_croak (fh, 0);
1337 dREQ; 1338 dREQ;
1338 1339
1344 1345
1345 REQ_SEND; 1346 REQ_SEND;
1346} 1347}
1347 1348
1348void 1349void
1349aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) 1350aio_stat (SV8 *fh_or_path, SV *callback = &PL_sv_undef)
1350 ALIAS: 1351 ALIAS:
1351 aio_stat = EIO_STAT 1352 aio_stat = EIO_STAT
1352 aio_lstat = EIO_LSTAT 1353 aio_lstat = EIO_LSTAT
1353 aio_statvfs = EIO_STATVFS 1354 aio_statvfs = EIO_STATVFS
1354 PPCODE: 1355 PPCODE:
1375 RETVAL = makedev (maj, min); 1376 RETVAL = makedev (maj, min);
1376 OUTPUT: 1377 OUTPUT:
1377 RETVAL 1378 RETVAL
1378 1379
1379void 1380void
1380aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) 1381aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback = &PL_sv_undef)
1381 PPCODE: 1382 PPCODE:
1382{ 1383{
1383 dREQ; 1384 dREQ;
1384 1385
1385 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; 1386 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.;
1388 1389
1389 REQ_SEND; 1390 REQ_SEND;
1390} 1391}
1391 1392
1392void 1393void
1393aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) 1394aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback = &PL_sv_undef)
1394 PPCODE: 1395 PPCODE:
1395{ 1396{
1396 dREQ; 1397 dREQ;
1397 1398
1398 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; 1399 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1;
1400 1401
1401 REQ_SEND; 1402 REQ_SEND;
1402} 1403}
1403 1404
1404void 1405void
1405aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) 1406aio_chmod (SV8 *fh_or_path, int mode, SV *callback = &PL_sv_undef)
1406 PPCODE: 1407 PPCODE:
1407{ 1408{
1408 dREQ; 1409 dREQ;
1409 1410
1410 req->int2 = mode; 1411 req->int2 = mode;
1412 1413
1413 REQ_SEND; 1414 REQ_SEND;
1414} 1415}
1415 1416
1416void 1417void
1417aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback=&PL_sv_undef) 1418aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback = &PL_sv_undef)
1418 PPCODE: 1419 PPCODE:
1419{ 1420{
1420 dREQ; 1421 dREQ;
1421 1422
1422 req->int2 = SvOK (uid) ? SvIV (uid) : -1; 1423 req->int2 = SvOK (uid) ? SvIV (uid) : -1;
1425 1426
1426 REQ_SEND; 1427 REQ_SEND;
1427} 1428}
1428 1429
1429void 1430void
1430aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) 1431aio_readdirx (SV8 *pathname, IV flags, SV *callback = &PL_sv_undef)
1431 PPCODE: 1432 PPCODE:
1432{ 1433{
1433 dREQ; 1434 dREQ;
1434 1435
1435 req->type = EIO_READDIR; 1436 req->type = EIO_READDIR;
1442 1443
1443 REQ_SEND; 1444 REQ_SEND;
1444} 1445}
1445 1446
1446void 1447void
1447aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) 1448aio_mkdir (SV8 *pathname, int mode, SV *callback = &PL_sv_undef)
1448 PPCODE: 1449 PPCODE:
1449{ 1450{
1450 dREQ; 1451 dREQ;
1451 1452
1452 req->type = EIO_MKDIR; 1453 req->type = EIO_MKDIR;
1455 1456
1456 REQ_SEND; 1457 REQ_SEND;
1457} 1458}
1458 1459
1459void 1460void
1460aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1461aio_unlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1461 ALIAS: 1462 ALIAS:
1462 aio_unlink = EIO_UNLINK 1463 aio_unlink = EIO_UNLINK
1463 aio_rmdir = EIO_RMDIR 1464 aio_rmdir = EIO_RMDIR
1464 aio_readdir = EIO_READDIR 1465 aio_readdir = EIO_READDIR
1465 PPCODE: 1466 PPCODE:
1471 1472
1472 REQ_SEND; 1473 REQ_SEND;
1473} 1474}
1474 1475
1475void 1476void
1476aio_link (SV8 *oldpath, SV8 *newpath, SV *callback=&PL_sv_undef) 1477aio_link (SV8 *oldpath, SV8 *newpath, SV *callback = &PL_sv_undef)
1477 ALIAS: 1478 ALIAS:
1478 aio_link = EIO_LINK 1479 aio_link = EIO_LINK
1479 aio_symlink = EIO_SYMLINK 1480 aio_symlink = EIO_SYMLINK
1480 aio_rename = EIO_RENAME 1481 aio_rename = EIO_RENAME
1481 PPCODE: 1482 PPCODE:
1490 1491
1491 REQ_SEND; 1492 REQ_SEND;
1492} 1493}
1493 1494
1494void 1495void
1495aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback=&PL_sv_undef) 1496aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback = &PL_sv_undef)
1496 PPCODE: 1497 PPCODE:
1497{ 1498{
1498 dREQ; 1499 dREQ;
1499 1500
1500 req->type = EIO_MKNOD; 1501 req->type = EIO_MKNOD;
1504 1505
1505 REQ_SEND; 1506 REQ_SEND;
1506} 1507}
1507 1508
1508void 1509void
1509aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) 1510aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback = &PL_sv_undef)
1510 ALIAS: 1511 ALIAS:
1511 aio_mtouch = EIO_MTOUCH 1512 aio_mtouch = EIO_MTOUCH
1512 aio_msync = EIO_MSYNC 1513 aio_msync = EIO_MSYNC
1513 PPCODE: 1514 PPCODE:
1514{ 1515{
1537 REQ_SEND; 1538 REQ_SEND;
1538 } 1539 }
1539} 1540}
1540 1541
1541void 1542void
1542aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) 1543aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback = &PL_sv_undef)
1543 PPCODE: 1544 PPCODE:
1544{ 1545{
1545 STRLEN svlen; 1546 STRLEN svlen;
1546 char *svptr = SvPVbyte (data, svlen); 1547 char *svptr = SvPVbyte (data, svlen);
1547 UV len = SvUV (length); 1548 UV len = SvUV (length);
1566 REQ_SEND; 1567 REQ_SEND;
1567 } 1568 }
1568} 1569}
1569 1570
1570void 1571void
1571aio_mlockall (IV flags, SV *callback=&PL_sv_undef) 1572aio_mlockall (IV flags, SV *callback = &PL_sv_undef)
1572 PPCODE: 1573 PPCODE:
1573{ 1574{
1574 dREQ; 1575 dREQ;
1575 1576
1576 req->type = EIO_MLOCKALL; 1577 req->type = EIO_MLOCKALL;
1578 1579
1579 REQ_SEND; 1580 REQ_SEND;
1580} 1581}
1581 1582
1582void 1583void
1583aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) 1584aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback = &PL_sv_undef)
1584 PPCODE: 1585 PPCODE:
1585{ 1586{
1586 int fd = s_fileno_croak (fh, 0); 1587 int fd = s_fileno_croak (fh, 0);
1587 dREQ; 1588 dREQ;
1588 1589
1601 1602
1602 REQ_SEND; 1603 REQ_SEND;
1603} 1604}
1604 1605
1605void 1606void
1606aio_busy (double delay, SV *callback=&PL_sv_undef) 1607aio_busy (double delay, SV *callback = &PL_sv_undef)
1607 PPCODE: 1608 PPCODE:
1608{ 1609{
1609 dREQ; 1610 dREQ;
1610 1611
1611 req->type = EIO_BUSY; 1612 req->type = EIO_BUSY;
1613 1614
1614 REQ_SEND; 1615 REQ_SEND;
1615} 1616}
1616 1617
1617void 1618void
1618aio_group (SV *callback=&PL_sv_undef) 1619aio_group (SV *callback = &PL_sv_undef)
1619 PPCODE: 1620 PPCODE:
1620{ 1621{
1621 dREQ; 1622 dREQ;
1622 1623
1623 req->type = EIO_GROUP; 1624 req->type = EIO_GROUP;
1628 1629
1629 XPUSHs (req_sv (req, aio_grp_stash)); 1630 XPUSHs (req_sv (req, aio_grp_stash));
1630} 1631}
1631 1632
1632void 1633void
1633aio_nop (SV *callback=&PL_sv_undef) 1634aio_nop (SV *callback = &PL_sv_undef)
1634 ALIAS: 1635 ALIAS:
1635 aio_nop = EIO_NOP 1636 aio_nop = EIO_NOP
1636 aio_sync = EIO_SYNC 1637 aio_sync = EIO_SYNC
1637 PPCODE: 1638 PPCODE:
1638{ 1639{
1642 1643
1643 REQ_SEND; 1644 REQ_SEND;
1644} 1645}
1645 1646
1646int 1647int
1647aioreq_pri (int pri = 0) 1648aioreq_pri (int pri = NO_INIT)
1648 CODE: 1649 CODE:
1649 RETVAL = next_pri; 1650 RETVAL = next_pri;
1650 if (items > 0) 1651 if (items > 0)
1651 { 1652 {
1652 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; 1653 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN;
1742 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); 1743 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count);
1743 OUTPUT: 1744 OUTPUT:
1744 RETVAL 1745 RETVAL
1745 1746
1746void 1747void
1747mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) 1748mmap (SV *scalar, STRLEN length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0)
1748 PPCODE: 1749 PPCODE:
1749 sv_unmagic (scalar, MMAP_MAGIC); 1750 sv_unmagic (scalar, MMAP_MAGIC);
1750{ 1751{
1751 int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; 1752 int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1;
1752 void *addr = (void *)mmap (0, length, prot, flags, fd, offset); 1753 void *addr = (void *)mmap (0, length, prot, flags, fd, offset);
1779munmap (SV *scalar) 1780munmap (SV *scalar)
1780 CODE: 1781 CODE:
1781 sv_unmagic (scalar, MMAP_MAGIC); 1782 sv_unmagic (scalar, MMAP_MAGIC);
1782 1783
1783int 1784int
1784madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) 1785madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot)
1785 ALIAS: 1786 ALIAS:
1786 mprotect = 1 1787 mprotect = 1
1787 CODE: 1788 CODE:
1788{ 1789{
1789 STRLEN svlen; 1790 STRLEN svlen;
1790 void *addr = SvPVbyte (scalar, svlen); 1791 void *addr = SvPVbyte (scalar, svlen);
1791 size_t len = SvUV (length); 1792 STRLEN len = SvUV (length);
1792 1793
1793 if (offset < 0) 1794 if (offset < 0)
1794 offset += svlen; 1795 offset += svlen;
1795 1796
1796 if (offset < 0 || offset > svlen) 1797 if (offset < 0 || offset > svlen)
1810} 1811}
1811 OUTPUT: 1812 OUTPUT:
1812 RETVAL 1813 RETVAL
1813 1814
1814int 1815int
1815munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) 1816munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef)
1816 CODE: 1817 CODE:
1817{ 1818{
1818 STRLEN svlen; 1819 STRLEN svlen;
1819 void *addr = SvPVbyte (scalar, svlen); 1820 void *addr = SvPVbyte (scalar, svlen);
1820 size_t len = SvUV (length); 1821 size_t len = SvUV (length);
1892 errno = ENOSYS; 1893 errno = ENOSYS;
1893 RETVAL = -1; 1894 RETVAL = -1;
1894#endif 1895#endif
1895 OUTPUT: 1896 OUTPUT:
1896 RETVAL 1897 RETVAL
1898
1899void
1900pipe2 (int flags = 0)
1901 PROTOTYPE: ;$
1902 PPCODE:
1903{
1904 int fd[2];
1905 int res;
1906
1907 if (flags)
1908#if HAVE_PIPE2
1909 res = pipe2 (fd, flags);
1910#else
1911 res = (errno = ENOSYS, -1);
1912#endif
1913 else
1914 res = pipe (fd);
1915
1916 if (!res)
1917 {
1918 EXTEND (SP, 2);
1919 PUSHs (newmortalFH (fd[0], O_RDONLY));
1920 PUSHs (newmortalFH (fd[1], O_WRONLY));
1921 }
1922}
1897 1923
1898void _on_next_submit (SV *cb) 1924void _on_next_submit (SV *cb)
1899 CODE: 1925 CODE:
1900 SvREFCNT_dec (on_next_submit); 1926 SvREFCNT_dec (on_next_submit);
1901 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; 1927 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0;
1936cancel (aio_req_ornot req) 1962cancel (aio_req_ornot req)
1937 CODE: 1963 CODE:
1938 eio_cancel (req); 1964 eio_cancel (req);
1939 1965
1940void 1966void
1941cb (aio_req_ornot req, SV *callback=&PL_sv_undef) 1967cb (aio_req_ornot req, SV *callback = NO_INIT)
1942 PPCODE: 1968 PPCODE:
1943{ 1969{
1944 if (GIMME_V != G_VOID) 1970 if (GIMME_V != G_VOID)
1945 XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef); 1971 XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef);
1946 1972
1947 if (items > 1) 1973 if (items > 1)
1948 { 1974 {
1949 SV *cb_cv =get_cb (callback); 1975 SV *cb_cv = get_cb (callback);
1950 1976
1951 SvREFCNT_dec (req->callback); 1977 SvREFCNT_dec (req->callback);
1952 req->callback = SvREFCNT_inc (cb_cv); 1978 req->callback = SvREFCNT_inc (cb_cv);
1953 } 1979 }
1954} 1980}
2011limit (aio_req grp, int limit) 2037limit (aio_req grp, int limit)
2012 CODE: 2038 CODE:
2013 eio_grp_limit (grp, limit); 2039 eio_grp_limit (grp, limit);
2014 2040
2015void 2041void
2016feed (aio_req grp, SV *callback=&PL_sv_undef) 2042feed (aio_req grp, SV *callback = &PL_sv_undef)
2017 CODE: 2043 CODE:
2018{ 2044{
2019 SvREFCNT_dec (grp->sv2); 2045 SvREFCNT_dec (grp->sv2);
2020 grp->sv2 = newSVsv (callback); 2046 grp->sv2 = newSVsv (callback);
2021 grp->feed = aio_grp_feed; 2047 grp->feed = aio_grp_feed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines