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.228 by root, Fri Jan 24 23:46:16 2014 UTC vs.
Revision 1.234 by root, Thu Jun 25 15:20:11 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 {
931 const_iv (O_SEARCH) 933 const_iv (O_SEARCH)
932 const_iv (O_DIRECTORY) 934 const_iv (O_DIRECTORY)
933 const_iv (O_DSYNC) 935 const_iv (O_DSYNC)
934 const_iv (O_RSYNC) 936 const_iv (O_RSYNC)
935 const_iv (O_SYNC) 937 const_iv (O_SYNC)
938 const_iv (O_PATH)
939 const_iv (O_TMPFILE)
936 const_iv (O_TTY_INIT) 940 const_iv (O_TTY_INIT)
937 941
938 const_iv (S_IFIFO) 942 const_iv (S_IFIFO)
939 const_iv (S_IFCHR) 943 const_iv (S_IFCHR)
940 const_iv (S_IFBLK) 944 const_iv (S_IFBLK)
1029 const_eio (SYNC_FILE_RANGE_WRITE) 1033 const_eio (SYNC_FILE_RANGE_WRITE)
1030 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 1034 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
1031 1035
1032 const_eio (FALLOC_FL_KEEP_SIZE) 1036 const_eio (FALLOC_FL_KEEP_SIZE)
1033 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)
1034 1040
1035 const_eio (READDIR_DENTS) 1041 const_eio (READDIR_DENTS)
1036 const_eio (READDIR_DIRS_FIRST) 1042 const_eio (READDIR_DIRS_FIRST)
1037 const_eio (READDIR_STAT_ORDER) 1043 const_eio (READDIR_STAT_ORDER)
1038 const_eio (READDIR_FOUND_UNKNOWN) 1044 const_eio (READDIR_FOUND_UNKNOWN)
1106 PROTOTYPE: $ 1112 PROTOTYPE: $
1107 CODE: 1113 CODE:
1108 max_outstanding = maxreqs; 1114 max_outstanding = maxreqs;
1109 1115
1110void 1116void
1111aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) 1117aio_wd (SV8 *pathname, SV *callback = &PL_sv_undef)
1112 PPCODE: 1118 PPCODE:
1113{ 1119{
1114 dREQ; 1120 dREQ;
1115 1121
1116 req->type = EIO_WD_OPEN; 1122 req->type = EIO_WD_OPEN;
1118 1124
1119 REQ_SEND; 1125 REQ_SEND;
1120} 1126}
1121 1127
1122void 1128void
1123aio_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)
1124 PPCODE: 1130 PPCODE:
1125{ 1131{
1126 dREQ; 1132 dREQ;
1127 1133
1128 req->type = EIO_OPEN; 1134 req->type = EIO_OPEN;
1132 1138
1133 REQ_SEND; 1139 REQ_SEND;
1134} 1140}
1135 1141
1136void 1142void
1137aio_fsync (SV *fh, SV *callback=&PL_sv_undef) 1143aio_fsync (SV *fh, SV *callback = &PL_sv_undef)
1138 ALIAS: 1144 ALIAS:
1139 aio_fsync = EIO_FSYNC 1145 aio_fsync = EIO_FSYNC
1140 aio_fdatasync = EIO_FDATASYNC 1146 aio_fdatasync = EIO_FDATASYNC
1141 aio_syncfs = EIO_SYNCFS 1147 aio_syncfs = EIO_SYNCFS
1142 PPCODE: 1148 PPCODE:
1150 1156
1151 REQ_SEND; 1157 REQ_SEND;
1152} 1158}
1153 1159
1154void 1160void
1155aio_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)
1156 PPCODE: 1162 PPCODE:
1157{ 1163{
1158 int fd = s_fileno_croak (fh, 0); 1164 int fd = s_fileno_croak (fh, 0);
1159 dREQ; 1165 dREQ;
1160 1166
1167 1173
1168 REQ_SEND; 1174 REQ_SEND;
1169} 1175}
1170 1176
1171void 1177void
1172aio_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)
1173 PPCODE: 1179 PPCODE:
1174{ 1180{
1175 int fd = s_fileno_croak (fh, 0); 1181 int fd = s_fileno_croak (fh, 0);
1176 dREQ; 1182 dREQ;
1177 1183
1184 1190
1185 REQ_SEND; 1191 REQ_SEND;
1186} 1192}
1187 1193
1188void 1194void
1189aio_close (SV *fh, SV *callback=&PL_sv_undef) 1195aio_close (SV *fh, SV *callback = &PL_sv_undef)
1190 PPCODE: 1196 PPCODE:
1191{ 1197{
1192 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 */
1193 int fd = s_fileno_croak (fh, 0); 1199 int fd = s_fileno_croak (fh, 0);
1194 dREQ; 1200 dREQ;
1218 1224
1219 REQ_SEND; 1225 REQ_SEND;
1220} 1226}
1221 1227
1222void 1228void
1223aio_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)
1224 PPCODE: 1230 PPCODE:
1225{ 1231{
1226 int fd = s_fileno_croak (fh, 0); 1232 int fd = s_fileno_croak (fh, 0);
1227 dREQ; 1233 dREQ;
1228 1234
1234 1240
1235 REQ_SEND; 1241 REQ_SEND;
1236} 1242}
1237 1243
1238void 1244void
1239aio_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)
1240 ALIAS: 1246 ALIAS:
1241 aio_read = EIO_READ 1247 aio_read = EIO_READ
1242 aio_write = EIO_WRITE 1248 aio_write = EIO_WRITE
1243 PPCODE: 1249 PPCODE:
1244{ 1250{
1260 len = svlen - dataoffset; 1266 len = svlen - dataoffset;
1261 } 1267 }
1262 else 1268 else
1263 { 1269 {
1264 /* read: check type and grow scalar as necessary */ 1270 /* read: check type and grow scalar as necessary */
1265 SvUPGRADE (data, SVt_PV);
1266 if (SvLEN (data) >= SvCUR (data)) 1271 if (!SvPOK (data) || SvLEN (data) >= SvCUR (data))
1267 svptr = SvGROW (data, len + dataoffset + 1); 1272 svptr = sv_grow (data, len + dataoffset + 1);
1268 else if (SvCUR (data) < len + dataoffset) 1273 else if (SvCUR (data) < len + dataoffset)
1269 croak ("length + dataoffset outside of scalar, and cannot grow"); 1274 croak ("length + dataoffset outside of scalar, and cannot grow");
1270 } 1275 }
1271 1276
1272 { 1277 {
1290 REQ_SEND; 1295 REQ_SEND;
1291 } 1296 }
1292} 1297}
1293 1298
1294void 1299void
1295aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1300aio_readlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1296 ALIAS: 1301 ALIAS:
1297 aio_readlink = EIO_READLINK 1302 aio_readlink = EIO_READLINK
1298 aio_realpath = EIO_REALPATH 1303 aio_realpath = EIO_REALPATH
1299 PPCODE: 1304 PPCODE:
1300{ 1305{
1305 1310
1306 REQ_SEND; 1311 REQ_SEND;
1307} 1312}
1308 1313
1309void 1314void
1310aio_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)
1311 PPCODE: 1316 PPCODE:
1312{ 1317{
1313 int ifd = s_fileno_croak (in_fh , 0); 1318 int ifd = s_fileno_croak (in_fh , 0);
1314 int ofd = s_fileno_croak (out_fh, 1); 1319 int ofd = s_fileno_croak (out_fh, 1);
1315 dREQ; 1320 dREQ;
1324 1329
1325 REQ_SEND; 1330 REQ_SEND;
1326} 1331}
1327 1332
1328void 1333void
1329aio_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)
1330 PPCODE: 1335 PPCODE:
1331{ 1336{
1332 int fd = s_fileno_croak (fh, 0); 1337 int fd = s_fileno_croak (fh, 0);
1333 dREQ; 1338 dREQ;
1334 1339
1340 1345
1341 REQ_SEND; 1346 REQ_SEND;
1342} 1347}
1343 1348
1344void 1349void
1345aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) 1350aio_stat (SV8 *fh_or_path, SV *callback = &PL_sv_undef)
1346 ALIAS: 1351 ALIAS:
1347 aio_stat = EIO_STAT 1352 aio_stat = EIO_STAT
1348 aio_lstat = EIO_LSTAT 1353 aio_lstat = EIO_LSTAT
1349 aio_statvfs = EIO_STATVFS 1354 aio_statvfs = EIO_STATVFS
1350 PPCODE: 1355 PPCODE:
1371 RETVAL = makedev (maj, min); 1376 RETVAL = makedev (maj, min);
1372 OUTPUT: 1377 OUTPUT:
1373 RETVAL 1378 RETVAL
1374 1379
1375void 1380void
1376aio_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)
1377 PPCODE: 1382 PPCODE:
1378{ 1383{
1379 dREQ; 1384 dREQ;
1380 1385
1381 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; 1386 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.;
1384 1389
1385 REQ_SEND; 1390 REQ_SEND;
1386} 1391}
1387 1392
1388void 1393void
1389aio_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)
1390 PPCODE: 1395 PPCODE:
1391{ 1396{
1392 dREQ; 1397 dREQ;
1393 1398
1394 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; 1399 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1;
1396 1401
1397 REQ_SEND; 1402 REQ_SEND;
1398} 1403}
1399 1404
1400void 1405void
1401aio_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)
1402 PPCODE: 1407 PPCODE:
1403{ 1408{
1404 dREQ; 1409 dREQ;
1405 1410
1406 req->int2 = mode; 1411 req->int2 = mode;
1408 1413
1409 REQ_SEND; 1414 REQ_SEND;
1410} 1415}
1411 1416
1412void 1417void
1413aio_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)
1414 PPCODE: 1419 PPCODE:
1415{ 1420{
1416 dREQ; 1421 dREQ;
1417 1422
1418 req->int2 = SvOK (uid) ? SvIV (uid) : -1; 1423 req->int2 = SvOK (uid) ? SvIV (uid) : -1;
1421 1426
1422 REQ_SEND; 1427 REQ_SEND;
1423} 1428}
1424 1429
1425void 1430void
1426aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) 1431aio_readdirx (SV8 *pathname, IV flags, SV *callback = &PL_sv_undef)
1427 PPCODE: 1432 PPCODE:
1428{ 1433{
1429 dREQ; 1434 dREQ;
1430 1435
1431 req->type = EIO_READDIR; 1436 req->type = EIO_READDIR;
1438 1443
1439 REQ_SEND; 1444 REQ_SEND;
1440} 1445}
1441 1446
1442void 1447void
1443aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) 1448aio_mkdir (SV8 *pathname, int mode, SV *callback = &PL_sv_undef)
1444 PPCODE: 1449 PPCODE:
1445{ 1450{
1446 dREQ; 1451 dREQ;
1447 1452
1448 req->type = EIO_MKDIR; 1453 req->type = EIO_MKDIR;
1451 1456
1452 REQ_SEND; 1457 REQ_SEND;
1453} 1458}
1454 1459
1455void 1460void
1456aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1461aio_unlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1457 ALIAS: 1462 ALIAS:
1458 aio_unlink = EIO_UNLINK 1463 aio_unlink = EIO_UNLINK
1459 aio_rmdir = EIO_RMDIR 1464 aio_rmdir = EIO_RMDIR
1460 aio_readdir = EIO_READDIR 1465 aio_readdir = EIO_READDIR
1461 PPCODE: 1466 PPCODE:
1467 1472
1468 REQ_SEND; 1473 REQ_SEND;
1469} 1474}
1470 1475
1471void 1476void
1472aio_link (SV8 *oldpath, SV8 *newpath, SV *callback=&PL_sv_undef) 1477aio_link (SV8 *oldpath, SV8 *newpath, SV *callback = &PL_sv_undef)
1473 ALIAS: 1478 ALIAS:
1474 aio_link = EIO_LINK 1479 aio_link = EIO_LINK
1475 aio_symlink = EIO_SYMLINK 1480 aio_symlink = EIO_SYMLINK
1476 aio_rename = EIO_RENAME 1481 aio_rename = EIO_RENAME
1477 PPCODE: 1482 PPCODE:
1486 1491
1487 REQ_SEND; 1492 REQ_SEND;
1488} 1493}
1489 1494
1490void 1495void
1491aio_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)
1492 PPCODE: 1497 PPCODE:
1493{ 1498{
1494 dREQ; 1499 dREQ;
1495 1500
1496 req->type = EIO_MKNOD; 1501 req->type = EIO_MKNOD;
1500 1505
1501 REQ_SEND; 1506 REQ_SEND;
1502} 1507}
1503 1508
1504void 1509void
1505aio_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)
1506 ALIAS: 1511 ALIAS:
1507 aio_mtouch = EIO_MTOUCH 1512 aio_mtouch = EIO_MTOUCH
1508 aio_msync = EIO_MSYNC 1513 aio_msync = EIO_MSYNC
1509 PPCODE: 1514 PPCODE:
1510{ 1515{
1533 REQ_SEND; 1538 REQ_SEND;
1534 } 1539 }
1535} 1540}
1536 1541
1537void 1542void
1538aio_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)
1539 PPCODE: 1544 PPCODE:
1540{ 1545{
1541 STRLEN svlen; 1546 STRLEN svlen;
1542 char *svptr = SvPVbyte (data, svlen); 1547 char *svptr = SvPVbyte (data, svlen);
1543 UV len = SvUV (length); 1548 UV len = SvUV (length);
1562 REQ_SEND; 1567 REQ_SEND;
1563 } 1568 }
1564} 1569}
1565 1570
1566void 1571void
1567aio_mlockall (IV flags, SV *callback=&PL_sv_undef) 1572aio_mlockall (IV flags, SV *callback = &PL_sv_undef)
1568 PPCODE: 1573 PPCODE:
1569{ 1574{
1570 dREQ; 1575 dREQ;
1571 1576
1572 req->type = EIO_MLOCKALL; 1577 req->type = EIO_MLOCKALL;
1574 1579
1575 REQ_SEND; 1580 REQ_SEND;
1576} 1581}
1577 1582
1578void 1583void
1579aio_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)
1580 PPCODE: 1585 PPCODE:
1581{ 1586{
1582 int fd = s_fileno_croak (fh, 0); 1587 int fd = s_fileno_croak (fh, 0);
1583 dREQ; 1588 dREQ;
1584 1589
1597 1602
1598 REQ_SEND; 1603 REQ_SEND;
1599} 1604}
1600 1605
1601void 1606void
1602aio_busy (double delay, SV *callback=&PL_sv_undef) 1607aio_busy (double delay, SV *callback = &PL_sv_undef)
1603 PPCODE: 1608 PPCODE:
1604{ 1609{
1605 dREQ; 1610 dREQ;
1606 1611
1607 req->type = EIO_BUSY; 1612 req->type = EIO_BUSY;
1609 1614
1610 REQ_SEND; 1615 REQ_SEND;
1611} 1616}
1612 1617
1613void 1618void
1614aio_group (SV *callback=&PL_sv_undef) 1619aio_group (SV *callback = &PL_sv_undef)
1615 PPCODE: 1620 PPCODE:
1616{ 1621{
1617 dREQ; 1622 dREQ;
1618 1623
1619 req->type = EIO_GROUP; 1624 req->type = EIO_GROUP;
1624 1629
1625 XPUSHs (req_sv (req, aio_grp_stash)); 1630 XPUSHs (req_sv (req, aio_grp_stash));
1626} 1631}
1627 1632
1628void 1633void
1629aio_nop (SV *callback=&PL_sv_undef) 1634aio_nop (SV *callback = &PL_sv_undef)
1630 ALIAS: 1635 ALIAS:
1631 aio_nop = EIO_NOP 1636 aio_nop = EIO_NOP
1632 aio_sync = EIO_SYNC 1637 aio_sync = EIO_SYNC
1633 PPCODE: 1638 PPCODE:
1634{ 1639{
1638 1643
1639 REQ_SEND; 1644 REQ_SEND;
1640} 1645}
1641 1646
1642int 1647int
1643aioreq_pri (int pri = 0) 1648aioreq_pri (int pri = NO_INIT)
1644 CODE: 1649 CODE:
1645 RETVAL = next_pri; 1650 RETVAL = next_pri;
1646 if (items > 0) 1651 if (items > 0)
1647 { 1652 {
1648 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; 1653 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN;
1738 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); 1743 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count);
1739 OUTPUT: 1744 OUTPUT:
1740 RETVAL 1745 RETVAL
1741 1746
1742void 1747void
1743mmap (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)
1744 PPCODE: 1749 PPCODE:
1745 sv_unmagic (scalar, MMAP_MAGIC); 1750 sv_unmagic (scalar, MMAP_MAGIC);
1746{ 1751{
1747 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;
1748 void *addr = (void *)mmap (0, length, prot, flags, fd, offset); 1753 void *addr = (void *)mmap (0, length, prot, flags, fd, offset);
1775munmap (SV *scalar) 1780munmap (SV *scalar)
1776 CODE: 1781 CODE:
1777 sv_unmagic (scalar, MMAP_MAGIC); 1782 sv_unmagic (scalar, MMAP_MAGIC);
1778 1783
1779int 1784int
1780madvise (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)
1781 ALIAS: 1786 ALIAS:
1782 mprotect = 1 1787 mprotect = 1
1783 CODE: 1788 CODE:
1784{ 1789{
1785 STRLEN svlen; 1790 STRLEN svlen;
1786 void *addr = SvPVbyte (scalar, svlen); 1791 void *addr = SvPVbyte (scalar, svlen);
1787 size_t len = SvUV (length); 1792 STRLEN len = SvUV (length);
1788 1793
1789 if (offset < 0) 1794 if (offset < 0)
1790 offset += svlen; 1795 offset += svlen;
1791 1796
1792 if (offset < 0 || offset > svlen) 1797 if (offset < 0 || offset > svlen)
1806} 1811}
1807 OUTPUT: 1812 OUTPUT:
1808 RETVAL 1813 RETVAL
1809 1814
1810int 1815int
1811munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) 1816munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef)
1812 CODE: 1817 CODE:
1813{ 1818{
1814 STRLEN svlen; 1819 STRLEN svlen;
1815 void *addr = SvPVbyte (scalar, svlen); 1820 void *addr = SvPVbyte (scalar, svlen);
1816 size_t len = SvUV (length); 1821 size_t len = SvUV (length);
1888 errno = ENOSYS; 1893 errno = ENOSYS;
1889 RETVAL = -1; 1894 RETVAL = -1;
1890#endif 1895#endif
1891 OUTPUT: 1896 OUTPUT:
1892 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}
1893 1923
1894void _on_next_submit (SV *cb) 1924void _on_next_submit (SV *cb)
1895 CODE: 1925 CODE:
1896 SvREFCNT_dec (on_next_submit); 1926 SvREFCNT_dec (on_next_submit);
1897 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; 1927 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0;
1932cancel (aio_req_ornot req) 1962cancel (aio_req_ornot req)
1933 CODE: 1963 CODE:
1934 eio_cancel (req); 1964 eio_cancel (req);
1935 1965
1936void 1966void
1937cb (aio_req_ornot req, SV *callback=&PL_sv_undef) 1967cb (aio_req_ornot req, SV *callback = NO_INIT)
1938 PPCODE: 1968 PPCODE:
1939{ 1969{
1940 if (GIMME_V != G_VOID) 1970 if (GIMME_V != G_VOID)
1941 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);
1942 1972
1943 if (items > 1) 1973 if (items > 1)
1944 { 1974 {
1945 SV *cb_cv =get_cb (callback); 1975 SV *cb_cv = get_cb (callback);
1946 1976
1947 SvREFCNT_dec (req->callback); 1977 SvREFCNT_dec (req->callback);
1948 req->callback = SvREFCNT_inc (cb_cv); 1978 req->callback = SvREFCNT_inc (cb_cv);
1949 } 1979 }
1950} 1980}
2007limit (aio_req grp, int limit) 2037limit (aio_req grp, int limit)
2008 CODE: 2038 CODE:
2009 eio_grp_limit (grp, limit); 2039 eio_grp_limit (grp, limit);
2010 2040
2011void 2041void
2012feed (aio_req grp, SV *callback=&PL_sv_undef) 2042feed (aio_req grp, SV *callback = &PL_sv_undef)
2013 CODE: 2043 CODE:
2014{ 2044{
2015 SvREFCNT_dec (grp->sv2); 2045 SvREFCNT_dec (grp->sv2);
2016 grp->sv2 = newSVsv (callback); 2046 grp->sv2 = newSVsv (callback);
2017 grp->feed = aio_grp_feed; 2047 grp->feed = aio_grp_feed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines