… | |
… | |
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 | { |
… | |
… | |
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 | |
|
|
344 | static SV * |
|
|
345 | newmortalFH (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 | |
340 | static void |
369 | static void |
341 | aio_grp_feed (aio_req grp) |
370 | aio_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 | |
1110 | void |
1114 | void |
1111 | aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) |
1115 | aio_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 | |
1122 | void |
1126 | void |
1123 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
1127 | aio_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 | |
1136 | void |
1140 | void |
1137 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
1141 | aio_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 | |
1154 | void |
1158 | void |
1155 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1159 | aio_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 | |
1171 | void |
1175 | void |
1172 | aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1176 | aio_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 | |
1188 | void |
1192 | void |
1189 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1193 | aio_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 | |
1222 | void |
1226 | void |
1223 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
1227 | aio_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 | |
1238 | void |
1242 | void |
1239 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
1243 | aio_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 | |
1294 | void |
1297 | void |
1295 | aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1298 | aio_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 | |
1309 | void |
1312 | void |
1310 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1313 | aio_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 | |
1328 | void |
1331 | void |
1329 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1332 | aio_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 | |
1344 | void |
1347 | void |
1345 | aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) |
1348 | aio_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 | |
1375 | void |
1378 | void |
1376 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1379 | aio_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 | |
1388 | void |
1391 | void |
1389 | aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) |
1392 | aio_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 | |
1400 | void |
1403 | void |
1401 | aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) |
1404 | aio_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 | |
1412 | void |
1415 | void |
1413 | aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback=&PL_sv_undef) |
1416 | aio_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 | |
1425 | void |
1428 | void |
1426 | aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) |
1429 | aio_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 | |
1442 | void |
1445 | void |
1443 | aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) |
1446 | aio_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 | |
1455 | void |
1458 | void |
1456 | aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1459 | aio_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 | |
1471 | void |
1474 | void |
1472 | aio_link (SV8 *oldpath, SV8 *newpath, SV *callback=&PL_sv_undef) |
1475 | aio_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 | |
1490 | void |
1493 | void |
1491 | aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback=&PL_sv_undef) |
1494 | aio_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 | |
1504 | void |
1507 | void |
1505 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1508 | aio_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 | |
1537 | void |
1540 | void |
1538 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
1541 | aio_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 | |
1566 | void |
1569 | void |
1567 | aio_mlockall (IV flags, SV *callback=&PL_sv_undef) |
1570 | aio_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 | |
1578 | void |
1581 | void |
1579 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1582 | aio_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 | |
1601 | void |
1604 | void |
1602 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1605 | aio_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 | |
1613 | void |
1616 | void |
1614 | aio_group (SV *callback=&PL_sv_undef) |
1617 | aio_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; |
… | |
… | |
1624 | |
1627 | |
1625 | XPUSHs (req_sv (req, aio_grp_stash)); |
1628 | XPUSHs (req_sv (req, aio_grp_stash)); |
1626 | } |
1629 | } |
1627 | |
1630 | |
1628 | void |
1631 | void |
1629 | aio_nop (SV *callback=&PL_sv_undef) |
1632 | aio_nop (SV *callback = &PL_sv_undef) |
1630 | ALIAS: |
1633 | ALIAS: |
1631 | aio_nop = EIO_NOP |
1634 | aio_nop = EIO_NOP |
1632 | aio_sync = EIO_SYNC |
1635 | aio_sync = EIO_SYNC |
1633 | PPCODE: |
1636 | PPCODE: |
1634 | { |
1637 | { |
… | |
… | |
1638 | |
1641 | |
1639 | REQ_SEND; |
1642 | REQ_SEND; |
1640 | } |
1643 | } |
1641 | |
1644 | |
1642 | int |
1645 | int |
1643 | aioreq_pri (int pri = 0) |
1646 | aioreq_pri (int pri = NO_INIT) |
1644 | CODE: |
1647 | CODE: |
1645 | RETVAL = next_pri; |
1648 | RETVAL = next_pri; |
1646 | if (items > 0) |
1649 | if (items > 0) |
1647 | { |
1650 | { |
1648 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1651 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
… | |
… | |
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); |
… | |
… | |
1888 | errno = ENOSYS; |
1891 | errno = ENOSYS; |
1889 | RETVAL = -1; |
1892 | RETVAL = -1; |
1890 | #endif |
1893 | #endif |
1891 | OUTPUT: |
1894 | OUTPUT: |
1892 | RETVAL |
1895 | RETVAL |
|
|
1896 | |
|
|
1897 | void |
|
|
1898 | pipe2 (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 | } |
1893 | |
1921 | |
1894 | void _on_next_submit (SV *cb) |
1922 | void _on_next_submit (SV *cb) |
1895 | CODE: |
1923 | CODE: |
1896 | SvREFCNT_dec (on_next_submit); |
1924 | SvREFCNT_dec (on_next_submit); |
1897 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1925 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
… | |
… | |
1932 | cancel (aio_req_ornot req) |
1960 | cancel (aio_req_ornot req) |
1933 | CODE: |
1961 | CODE: |
1934 | eio_cancel (req); |
1962 | eio_cancel (req); |
1935 | |
1963 | |
1936 | void |
1964 | void |
1937 | cb (aio_req_ornot req, SV *callback=&PL_sv_undef) |
1965 | cb (aio_req_ornot req, SV *callback = NO_INIT) |
1938 | PPCODE: |
1966 | PPCODE: |
1939 | { |
1967 | { |
1940 | if (GIMME_V != G_VOID) |
1968 | if (GIMME_V != G_VOID) |
1941 | 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); |
1942 | |
1970 | |
1943 | if (items > 1) |
1971 | if (items > 1) |
1944 | { |
1972 | { |
1945 | SV *cb_cv =get_cb (callback); |
1973 | SV *cb_cv = get_cb (callback); |
1946 | |
1974 | |
1947 | SvREFCNT_dec (req->callback); |
1975 | SvREFCNT_dec (req->callback); |
1948 | req->callback = SvREFCNT_inc (cb_cv); |
1976 | req->callback = SvREFCNT_inc (cb_cv); |
1949 | } |
1977 | } |
1950 | } |
1978 | } |
… | |
… | |
2007 | limit (aio_req grp, int limit) |
2035 | limit (aio_req grp, int limit) |
2008 | CODE: |
2036 | CODE: |
2009 | eio_grp_limit (grp, limit); |
2037 | eio_grp_limit (grp, limit); |
2010 | |
2038 | |
2011 | void |
2039 | void |
2012 | feed (aio_req grp, SV *callback=&PL_sv_undef) |
2040 | feed (aio_req grp, SV *callback = &PL_sv_undef) |
2013 | CODE: |
2041 | CODE: |
2014 | { |
2042 | { |
2015 | SvREFCNT_dec (grp->sv2); |
2043 | SvREFCNT_dec (grp->sv2); |
2016 | grp->sv2 = newSVsv (callback); |
2044 | grp->sv2 = newSVsv (callback); |
2017 | grp->feed = aio_grp_feed; |
2045 | grp->feed = aio_grp_feed; |