… | |
… | |
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 |
… | |
… | |
153 | #endif |
157 | #endif |
154 | #ifndef minor |
158 | #ifndef minor |
155 | # define minor(dev) ((dev) & 0xff) |
159 | # define minor(dev) ((dev) & 0xff) |
156 | #endif |
160 | #endif |
157 | |
161 | |
158 | #ifndef PAGESIZE |
162 | #if PAGESIZE <= 0 |
159 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
163 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
160 | #endif |
164 | #endif |
161 | |
165 | |
162 | /*****************************************************************************/ |
166 | /*****************************************************************************/ |
163 | |
167 | |
… | |
… | |
198 | || !fiemap->fm_mapped_extents /* no more extents */ |
202 | || !fiemap->fm_mapped_extents /* no more extents */ |
199 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
203 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
200 | goto done; |
204 | goto done; |
201 | |
205 | |
202 | /* else we have to loop - |
206 | /* else we have to loop - |
203 | * it would be tempting (atcually I tried that first) to just query the |
207 | * it would be tempting (actually I tried that first) to just query the |
204 | * number of extents needed, but linux often feels like not returning all |
208 | * number of extents needed, but linux often feels like not returning all |
205 | * extents, without telling us it left any out. this complicates |
209 | * extents, without telling us it left any out. this complicates |
206 | * this quite a bit. |
210 | * this quite a bit. |
207 | */ |
211 | */ |
208 | |
212 | |
… | |
… | |
221 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
225 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
222 | |
226 | |
223 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
227 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
224 | return; |
228 | return; |
225 | |
229 | |
|
|
230 | if (!incmap->fm_mapped_extents) |
|
|
231 | goto done; |
|
|
232 | |
226 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
233 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
227 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
234 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
228 | errno = ENOMEM; |
235 | errno = ENOMEM; |
229 | if (!fiemap) |
236 | if (!fiemap) |
230 | return; |
237 | return; |
… | |
… | |
301 | } |
308 | } |
302 | |
309 | |
303 | static SV * |
310 | static SV * |
304 | newSVaio_wd (aio_wd wd) |
311 | newSVaio_wd (aio_wd wd) |
305 | { |
312 | { |
306 | return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); |
313 | return sv_bless (newRV_noinc (newSViv ((intptr_t)wd)), aio_wd_stash); |
307 | } |
314 | } |
308 | |
315 | |
309 | static aio_req |
316 | static aio_req |
310 | SvAIO_REQ (SV *sv) |
317 | SvAIO_REQ (SV *sv) |
311 | { |
318 | { |
… | |
… | |
330 | || SvTYPE (SvRV (sv)) != SVt_PVMG |
337 | || SvTYPE (SvRV (sv)) != SVt_PVMG |
331 | || SvSTASH (SvRV (sv)) != aio_wd_stash) |
338 | || SvSTASH (SvRV (sv)) != aio_wd_stash) |
332 | 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"); |
333 | |
340 | |
334 | 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; |
335 | } |
367 | } |
336 | |
368 | |
337 | static void |
369 | static void |
338 | aio_grp_feed (aio_req grp) |
370 | aio_grp_feed (aio_req grp) |
339 | { |
371 | { |
… | |
… | |
467 | 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)))); |
468 | } |
500 | } |
469 | break; |
501 | break; |
470 | |
502 | |
471 | case EIO_OPEN: |
503 | case EIO_OPEN: |
472 | { |
504 | PUSHs (newmortalFH (req->result, req->int1 & (O_RDONLY | O_WRONLY | O_RDWR))); |
473 | /* convert fd to fh */ |
|
|
474 | SV *fh = &PL_sv_undef; |
|
|
475 | |
|
|
476 | if (req->result >= 0) |
|
|
477 | { |
|
|
478 | GV *gv = (GV *)sv_newmortal (); |
|
|
479 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
|
|
480 | char sym [64]; |
|
|
481 | int symlen; |
|
|
482 | |
|
|
483 | symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result); |
|
|
484 | gv_init (gv, aio_stash, sym, symlen, 0); |
|
|
485 | |
|
|
486 | symlen = snprintf ( |
|
|
487 | sym, |
|
|
488 | sizeof (sym), |
|
|
489 | "%s&=%d", |
|
|
490 | flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<", |
|
|
491 | (int)req->result |
|
|
492 | ); |
|
|
493 | |
|
|
494 | if (do_open (gv, sym, symlen, 0, 0, 0, 0)) |
|
|
495 | fh = (SV *)gv; |
|
|
496 | } |
|
|
497 | |
|
|
498 | PUSHs (fh); |
|
|
499 | } |
|
|
500 | break; |
505 | break; |
501 | |
506 | |
502 | case EIO_STATVFS: |
507 | case EIO_STATVFS: |
503 | case EIO_FSTATVFS: |
508 | case EIO_FSTATVFS: |
504 | { |
509 | { |
… | |
… | |
928 | const_iv (O_SEARCH) |
933 | const_iv (O_SEARCH) |
929 | const_iv (O_DIRECTORY) |
934 | const_iv (O_DIRECTORY) |
930 | const_iv (O_DSYNC) |
935 | const_iv (O_DSYNC) |
931 | const_iv (O_RSYNC) |
936 | const_iv (O_RSYNC) |
932 | const_iv (O_SYNC) |
937 | const_iv (O_SYNC) |
|
|
938 | const_iv (O_PATH) |
|
|
939 | const_iv (O_TMPFILE) |
933 | const_iv (O_TTY_INIT) |
940 | const_iv (O_TTY_INIT) |
934 | |
941 | |
935 | const_iv (S_IFIFO) |
942 | const_iv (S_IFIFO) |
936 | const_iv (S_IFCHR) |
943 | const_iv (S_IFCHR) |
937 | const_iv (S_IFBLK) |
944 | const_iv (S_IFBLK) |
… | |
… | |
1026 | const_eio (SYNC_FILE_RANGE_WRITE) |
1033 | const_eio (SYNC_FILE_RANGE_WRITE) |
1027 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
1034 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
1028 | |
1035 | |
1029 | const_eio (FALLOC_FL_KEEP_SIZE) |
1036 | const_eio (FALLOC_FL_KEEP_SIZE) |
1030 | 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) |
1031 | |
1040 | |
1032 | const_eio (READDIR_DENTS) |
1041 | const_eio (READDIR_DENTS) |
1033 | const_eio (READDIR_DIRS_FIRST) |
1042 | const_eio (READDIR_DIRS_FIRST) |
1034 | const_eio (READDIR_STAT_ORDER) |
1043 | const_eio (READDIR_STAT_ORDER) |
1035 | const_eio (READDIR_FOUND_UNKNOWN) |
1044 | const_eio (READDIR_FOUND_UNKNOWN) |
… | |
… | |
1103 | PROTOTYPE: $ |
1112 | PROTOTYPE: $ |
1104 | CODE: |
1113 | CODE: |
1105 | max_outstanding = maxreqs; |
1114 | max_outstanding = maxreqs; |
1106 | |
1115 | |
1107 | void |
1116 | void |
1108 | aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) |
1117 | aio_wd (SV8 *pathname, SV *callback = &PL_sv_undef) |
1109 | PPCODE: |
1118 | PPCODE: |
1110 | { |
1119 | { |
1111 | dREQ; |
1120 | dREQ; |
1112 | |
1121 | |
1113 | req->type = EIO_WD_OPEN; |
1122 | req->type = EIO_WD_OPEN; |
… | |
… | |
1115 | |
1124 | |
1116 | REQ_SEND; |
1125 | REQ_SEND; |
1117 | } |
1126 | } |
1118 | |
1127 | |
1119 | void |
1128 | void |
1120 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
1129 | aio_open (SV8 *pathname, int flags, int mode, SV *callback = &PL_sv_undef) |
1121 | PPCODE: |
1130 | PPCODE: |
1122 | { |
1131 | { |
1123 | dREQ; |
1132 | dREQ; |
1124 | |
1133 | |
1125 | req->type = EIO_OPEN; |
1134 | req->type = EIO_OPEN; |
… | |
… | |
1129 | |
1138 | |
1130 | REQ_SEND; |
1139 | REQ_SEND; |
1131 | } |
1140 | } |
1132 | |
1141 | |
1133 | void |
1142 | void |
1134 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
1143 | aio_fsync (SV *fh, SV *callback = &PL_sv_undef) |
1135 | ALIAS: |
1144 | ALIAS: |
1136 | aio_fsync = EIO_FSYNC |
1145 | aio_fsync = EIO_FSYNC |
1137 | aio_fdatasync = EIO_FDATASYNC |
1146 | aio_fdatasync = EIO_FDATASYNC |
1138 | aio_syncfs = EIO_SYNCFS |
1147 | aio_syncfs = EIO_SYNCFS |
1139 | PPCODE: |
1148 | PPCODE: |
… | |
… | |
1147 | |
1156 | |
1148 | REQ_SEND; |
1157 | REQ_SEND; |
1149 | } |
1158 | } |
1150 | |
1159 | |
1151 | void |
1160 | void |
1152 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1161 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback = &PL_sv_undef) |
1153 | PPCODE: |
1162 | PPCODE: |
1154 | { |
1163 | { |
1155 | int fd = s_fileno_croak (fh, 0); |
1164 | int fd = s_fileno_croak (fh, 0); |
1156 | dREQ; |
1165 | dREQ; |
1157 | |
1166 | |
… | |
… | |
1164 | |
1173 | |
1165 | REQ_SEND; |
1174 | REQ_SEND; |
1166 | } |
1175 | } |
1167 | |
1176 | |
1168 | void |
1177 | void |
1169 | aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1178 | aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback = &PL_sv_undef) |
1170 | PPCODE: |
1179 | PPCODE: |
1171 | { |
1180 | { |
1172 | int fd = s_fileno_croak (fh, 0); |
1181 | int fd = s_fileno_croak (fh, 0); |
1173 | dREQ; |
1182 | dREQ; |
1174 | |
1183 | |
… | |
… | |
1181 | |
1190 | |
1182 | REQ_SEND; |
1191 | REQ_SEND; |
1183 | } |
1192 | } |
1184 | |
1193 | |
1185 | void |
1194 | void |
1186 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1195 | aio_close (SV *fh, SV *callback = &PL_sv_undef) |
1187 | PPCODE: |
1196 | PPCODE: |
1188 | { |
1197 | { |
1189 | 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 */ |
1190 | int fd = s_fileno_croak (fh, 0); |
1199 | int fd = s_fileno_croak (fh, 0); |
1191 | dREQ; |
1200 | dREQ; |
… | |
… | |
1215 | |
1224 | |
1216 | REQ_SEND; |
1225 | REQ_SEND; |
1217 | } |
1226 | } |
1218 | |
1227 | |
1219 | void |
1228 | void |
1220 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
1229 | aio_seek (SV *fh, SV *offset, int whence, SV *callback = &PL_sv_undef) |
1221 | PPCODE: |
1230 | PPCODE: |
1222 | { |
1231 | { |
1223 | int fd = s_fileno_croak (fh, 0); |
1232 | int fd = s_fileno_croak (fh, 0); |
1224 | dREQ; |
1233 | dREQ; |
1225 | |
1234 | |
… | |
… | |
1231 | |
1240 | |
1232 | REQ_SEND; |
1241 | REQ_SEND; |
1233 | } |
1242 | } |
1234 | |
1243 | |
1235 | void |
1244 | void |
1236 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
1245 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback = &PL_sv_undef) |
1237 | ALIAS: |
1246 | ALIAS: |
1238 | aio_read = EIO_READ |
1247 | aio_read = EIO_READ |
1239 | aio_write = EIO_WRITE |
1248 | aio_write = EIO_WRITE |
1240 | PPCODE: |
1249 | PPCODE: |
1241 | { |
1250 | { |
… | |
… | |
1257 | len = svlen - dataoffset; |
1266 | len = svlen - dataoffset; |
1258 | } |
1267 | } |
1259 | else |
1268 | else |
1260 | { |
1269 | { |
1261 | /* read: check type and grow scalar as necessary */ |
1270 | /* read: check type and grow scalar as necessary */ |
1262 | SvUPGRADE (data, SVt_PV); |
|
|
1263 | if (SvLEN (data) >= SvCUR (data)) |
1271 | if (!SvPOK (data) || SvLEN (data) >= SvCUR (data)) |
1264 | svptr = SvGROW (data, len + dataoffset + 1); |
1272 | svptr = sv_grow (data, len + dataoffset + 1); |
1265 | else if (SvCUR (data) < len + dataoffset) |
1273 | else if (SvCUR (data) < len + dataoffset) |
1266 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1274 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1267 | } |
1275 | } |
1268 | |
1276 | |
1269 | { |
1277 | { |
… | |
… | |
1287 | REQ_SEND; |
1295 | REQ_SEND; |
1288 | } |
1296 | } |
1289 | } |
1297 | } |
1290 | |
1298 | |
1291 | void |
1299 | void |
1292 | aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1300 | aio_readlink (SV8 *pathname, SV *callback = &PL_sv_undef) |
1293 | ALIAS: |
1301 | ALIAS: |
1294 | aio_readlink = EIO_READLINK |
1302 | aio_readlink = EIO_READLINK |
1295 | aio_realpath = EIO_REALPATH |
1303 | aio_realpath = EIO_REALPATH |
1296 | PPCODE: |
1304 | PPCODE: |
1297 | { |
1305 | { |
… | |
… | |
1302 | |
1310 | |
1303 | REQ_SEND; |
1311 | REQ_SEND; |
1304 | } |
1312 | } |
1305 | |
1313 | |
1306 | void |
1314 | void |
1307 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1315 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback = &PL_sv_undef) |
1308 | PPCODE: |
1316 | PPCODE: |
1309 | { |
1317 | { |
1310 | int ifd = s_fileno_croak (in_fh , 0); |
1318 | int ifd = s_fileno_croak (in_fh , 0); |
1311 | int ofd = s_fileno_croak (out_fh, 1); |
1319 | int ofd = s_fileno_croak (out_fh, 1); |
1312 | dREQ; |
1320 | dREQ; |
… | |
… | |
1321 | |
1329 | |
1322 | REQ_SEND; |
1330 | REQ_SEND; |
1323 | } |
1331 | } |
1324 | |
1332 | |
1325 | void |
1333 | void |
1326 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1334 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback = &PL_sv_undef) |
1327 | PPCODE: |
1335 | PPCODE: |
1328 | { |
1336 | { |
1329 | int fd = s_fileno_croak (fh, 0); |
1337 | int fd = s_fileno_croak (fh, 0); |
1330 | dREQ; |
1338 | dREQ; |
1331 | |
1339 | |
… | |
… | |
1337 | |
1345 | |
1338 | REQ_SEND; |
1346 | REQ_SEND; |
1339 | } |
1347 | } |
1340 | |
1348 | |
1341 | void |
1349 | void |
1342 | aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) |
1350 | aio_stat (SV8 *fh_or_path, SV *callback = &PL_sv_undef) |
1343 | ALIAS: |
1351 | ALIAS: |
1344 | aio_stat = EIO_STAT |
1352 | aio_stat = EIO_STAT |
1345 | aio_lstat = EIO_LSTAT |
1353 | aio_lstat = EIO_LSTAT |
1346 | aio_statvfs = EIO_STATVFS |
1354 | aio_statvfs = EIO_STATVFS |
1347 | PPCODE: |
1355 | PPCODE: |
… | |
… | |
1368 | RETVAL = makedev (maj, min); |
1376 | RETVAL = makedev (maj, min); |
1369 | OUTPUT: |
1377 | OUTPUT: |
1370 | RETVAL |
1378 | RETVAL |
1371 | |
1379 | |
1372 | void |
1380 | void |
1373 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1381 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback = &PL_sv_undef) |
1374 | PPCODE: |
1382 | PPCODE: |
1375 | { |
1383 | { |
1376 | dREQ; |
1384 | dREQ; |
1377 | |
1385 | |
1378 | req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; |
1386 | req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; |
… | |
… | |
1381 | |
1389 | |
1382 | REQ_SEND; |
1390 | REQ_SEND; |
1383 | } |
1391 | } |
1384 | |
1392 | |
1385 | void |
1393 | void |
1386 | aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) |
1394 | aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback = &PL_sv_undef) |
1387 | PPCODE: |
1395 | PPCODE: |
1388 | { |
1396 | { |
1389 | dREQ; |
1397 | dREQ; |
1390 | |
1398 | |
1391 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
1399 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
… | |
… | |
1393 | |
1401 | |
1394 | REQ_SEND; |
1402 | REQ_SEND; |
1395 | } |
1403 | } |
1396 | |
1404 | |
1397 | void |
1405 | void |
1398 | aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) |
1406 | aio_chmod (SV8 *fh_or_path, int mode, SV *callback = &PL_sv_undef) |
1399 | PPCODE: |
1407 | PPCODE: |
1400 | { |
1408 | { |
1401 | dREQ; |
1409 | dREQ; |
1402 | |
1410 | |
1403 | req->int2 = mode; |
1411 | req->int2 = mode; |
… | |
… | |
1405 | |
1413 | |
1406 | REQ_SEND; |
1414 | REQ_SEND; |
1407 | } |
1415 | } |
1408 | |
1416 | |
1409 | void |
1417 | void |
1410 | aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback=&PL_sv_undef) |
1418 | aio_chown (SV8 *fh_or_path, SV *uid, SV *gid, SV *callback = &PL_sv_undef) |
1411 | PPCODE: |
1419 | PPCODE: |
1412 | { |
1420 | { |
1413 | dREQ; |
1421 | dREQ; |
1414 | |
1422 | |
1415 | req->int2 = SvOK (uid) ? SvIV (uid) : -1; |
1423 | req->int2 = SvOK (uid) ? SvIV (uid) : -1; |
… | |
… | |
1418 | |
1426 | |
1419 | REQ_SEND; |
1427 | REQ_SEND; |
1420 | } |
1428 | } |
1421 | |
1429 | |
1422 | void |
1430 | void |
1423 | aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) |
1431 | aio_readdirx (SV8 *pathname, IV flags, SV *callback = &PL_sv_undef) |
1424 | PPCODE: |
1432 | PPCODE: |
1425 | { |
1433 | { |
1426 | dREQ; |
1434 | dREQ; |
1427 | |
1435 | |
1428 | req->type = EIO_READDIR; |
1436 | req->type = EIO_READDIR; |
… | |
… | |
1435 | |
1443 | |
1436 | REQ_SEND; |
1444 | REQ_SEND; |
1437 | } |
1445 | } |
1438 | |
1446 | |
1439 | void |
1447 | void |
1440 | aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) |
1448 | aio_mkdir (SV8 *pathname, int mode, SV *callback = &PL_sv_undef) |
1441 | PPCODE: |
1449 | PPCODE: |
1442 | { |
1450 | { |
1443 | dREQ; |
1451 | dREQ; |
1444 | |
1452 | |
1445 | req->type = EIO_MKDIR; |
1453 | req->type = EIO_MKDIR; |
… | |
… | |
1448 | |
1456 | |
1449 | REQ_SEND; |
1457 | REQ_SEND; |
1450 | } |
1458 | } |
1451 | |
1459 | |
1452 | void |
1460 | void |
1453 | aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1461 | aio_unlink (SV8 *pathname, SV *callback = &PL_sv_undef) |
1454 | ALIAS: |
1462 | ALIAS: |
1455 | aio_unlink = EIO_UNLINK |
1463 | aio_unlink = EIO_UNLINK |
1456 | aio_rmdir = EIO_RMDIR |
1464 | aio_rmdir = EIO_RMDIR |
1457 | aio_readdir = EIO_READDIR |
1465 | aio_readdir = EIO_READDIR |
1458 | PPCODE: |
1466 | PPCODE: |
… | |
… | |
1464 | |
1472 | |
1465 | REQ_SEND; |
1473 | REQ_SEND; |
1466 | } |
1474 | } |
1467 | |
1475 | |
1468 | void |
1476 | void |
1469 | aio_link (SV8 *oldpath, SV8 *newpath, SV *callback=&PL_sv_undef) |
1477 | aio_link (SV8 *oldpath, SV8 *newpath, SV *callback = &PL_sv_undef) |
1470 | ALIAS: |
1478 | ALIAS: |
1471 | aio_link = EIO_LINK |
1479 | aio_link = EIO_LINK |
1472 | aio_symlink = EIO_SYMLINK |
1480 | aio_symlink = EIO_SYMLINK |
1473 | aio_rename = EIO_RENAME |
1481 | aio_rename = EIO_RENAME |
1474 | PPCODE: |
1482 | PPCODE: |
… | |
… | |
1483 | |
1491 | |
1484 | REQ_SEND; |
1492 | REQ_SEND; |
1485 | } |
1493 | } |
1486 | |
1494 | |
1487 | void |
1495 | void |
1488 | aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback=&PL_sv_undef) |
1496 | aio_mknod (SV8 *pathname, int mode, UV dev, SV *callback = &PL_sv_undef) |
1489 | PPCODE: |
1497 | PPCODE: |
1490 | { |
1498 | { |
1491 | dREQ; |
1499 | dREQ; |
1492 | |
1500 | |
1493 | req->type = EIO_MKNOD; |
1501 | req->type = EIO_MKNOD; |
… | |
… | |
1497 | |
1505 | |
1498 | REQ_SEND; |
1506 | REQ_SEND; |
1499 | } |
1507 | } |
1500 | |
1508 | |
1501 | void |
1509 | void |
1502 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1510 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback = &PL_sv_undef) |
1503 | ALIAS: |
1511 | ALIAS: |
1504 | aio_mtouch = EIO_MTOUCH |
1512 | aio_mtouch = EIO_MTOUCH |
1505 | aio_msync = EIO_MSYNC |
1513 | aio_msync = EIO_MSYNC |
1506 | PPCODE: |
1514 | PPCODE: |
1507 | { |
1515 | { |
… | |
… | |
1530 | REQ_SEND; |
1538 | REQ_SEND; |
1531 | } |
1539 | } |
1532 | } |
1540 | } |
1533 | |
1541 | |
1534 | void |
1542 | void |
1535 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
1543 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback = &PL_sv_undef) |
1536 | PPCODE: |
1544 | PPCODE: |
1537 | { |
1545 | { |
1538 | STRLEN svlen; |
1546 | STRLEN svlen; |
1539 | char *svptr = SvPVbyte (data, svlen); |
1547 | char *svptr = SvPVbyte (data, svlen); |
1540 | UV len = SvUV (length); |
1548 | UV len = SvUV (length); |
… | |
… | |
1559 | REQ_SEND; |
1567 | REQ_SEND; |
1560 | } |
1568 | } |
1561 | } |
1569 | } |
1562 | |
1570 | |
1563 | void |
1571 | void |
1564 | aio_mlockall (IV flags, SV *callback=&PL_sv_undef) |
1572 | aio_mlockall (IV flags, SV *callback = &PL_sv_undef) |
1565 | PPCODE: |
1573 | PPCODE: |
1566 | { |
1574 | { |
1567 | dREQ; |
1575 | dREQ; |
1568 | |
1576 | |
1569 | req->type = EIO_MLOCKALL; |
1577 | req->type = EIO_MLOCKALL; |
… | |
… | |
1571 | |
1579 | |
1572 | REQ_SEND; |
1580 | REQ_SEND; |
1573 | } |
1581 | } |
1574 | |
1582 | |
1575 | void |
1583 | void |
1576 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1584 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback = &PL_sv_undef) |
1577 | PPCODE: |
1585 | PPCODE: |
1578 | { |
1586 | { |
1579 | int fd = s_fileno_croak (fh, 0); |
1587 | int fd = s_fileno_croak (fh, 0); |
1580 | dREQ; |
1588 | dREQ; |
1581 | |
1589 | |
… | |
… | |
1594 | |
1602 | |
1595 | REQ_SEND; |
1603 | REQ_SEND; |
1596 | } |
1604 | } |
1597 | |
1605 | |
1598 | void |
1606 | void |
1599 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1607 | aio_busy (double delay, SV *callback = &PL_sv_undef) |
1600 | PPCODE: |
1608 | PPCODE: |
1601 | { |
1609 | { |
1602 | dREQ; |
1610 | dREQ; |
1603 | |
1611 | |
1604 | req->type = EIO_BUSY; |
1612 | req->type = EIO_BUSY; |
… | |
… | |
1606 | |
1614 | |
1607 | REQ_SEND; |
1615 | REQ_SEND; |
1608 | } |
1616 | } |
1609 | |
1617 | |
1610 | void |
1618 | void |
1611 | aio_group (SV *callback=&PL_sv_undef) |
1619 | aio_group (SV *callback = &PL_sv_undef) |
1612 | PPCODE: |
1620 | PPCODE: |
1613 | { |
1621 | { |
1614 | dREQ; |
1622 | dREQ; |
1615 | |
1623 | |
1616 | req->type = EIO_GROUP; |
1624 | req->type = EIO_GROUP; |
1617 | |
1625 | |
|
|
1626 | PUTBACK; |
1618 | req_submit (req); |
1627 | req_submit (req); |
|
|
1628 | SPAGAIN; |
|
|
1629 | |
1619 | XPUSHs (req_sv (req, aio_grp_stash)); |
1630 | XPUSHs (req_sv (req, aio_grp_stash)); |
1620 | } |
1631 | } |
1621 | |
1632 | |
1622 | void |
1633 | void |
1623 | aio_nop (SV *callback=&PL_sv_undef) |
1634 | aio_nop (SV *callback = &PL_sv_undef) |
1624 | ALIAS: |
1635 | ALIAS: |
1625 | aio_nop = EIO_NOP |
1636 | aio_nop = EIO_NOP |
1626 | aio_sync = EIO_SYNC |
1637 | aio_sync = EIO_SYNC |
1627 | PPCODE: |
1638 | PPCODE: |
1628 | { |
1639 | { |
… | |
… | |
1632 | |
1643 | |
1633 | REQ_SEND; |
1644 | REQ_SEND; |
1634 | } |
1645 | } |
1635 | |
1646 | |
1636 | int |
1647 | int |
1637 | aioreq_pri (int pri = 0) |
1648 | aioreq_pri (int pri = NO_INIT) |
1638 | CODE: |
1649 | CODE: |
1639 | RETVAL = next_pri; |
1650 | RETVAL = next_pri; |
1640 | if (items > 0) |
1651 | if (items > 0) |
1641 | { |
1652 | { |
1642 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1653 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
… | |
… | |
1732 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1743 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1733 | OUTPUT: |
1744 | OUTPUT: |
1734 | RETVAL |
1745 | RETVAL |
1735 | |
1746 | |
1736 | void |
1747 | void |
1737 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1748 | mmap (SV *scalar, STRLEN length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1738 | PPCODE: |
1749 | PPCODE: |
1739 | sv_unmagic (scalar, MMAP_MAGIC); |
1750 | sv_unmagic (scalar, MMAP_MAGIC); |
1740 | { |
1751 | { |
1741 | 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; |
1742 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1753 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1769 | munmap (SV *scalar) |
1780 | munmap (SV *scalar) |
1770 | CODE: |
1781 | CODE: |
1771 | sv_unmagic (scalar, MMAP_MAGIC); |
1782 | sv_unmagic (scalar, MMAP_MAGIC); |
1772 | |
1783 | |
1773 | int |
1784 | int |
1774 | madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1785 | madvise (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1775 | ALIAS: |
1786 | ALIAS: |
1776 | mprotect = 1 |
1787 | mprotect = 1 |
1777 | CODE: |
1788 | CODE: |
1778 | { |
1789 | { |
1779 | STRLEN svlen; |
1790 | STRLEN svlen; |
1780 | void *addr = SvPVbyte (scalar, svlen); |
1791 | void *addr = SvPVbyte (scalar, svlen); |
1781 | size_t len = SvUV (length); |
1792 | STRLEN len = SvUV (length); |
1782 | |
1793 | |
1783 | if (offset < 0) |
1794 | if (offset < 0) |
1784 | offset += svlen; |
1795 | offset += svlen; |
1785 | |
1796 | |
1786 | if (offset < 0 || offset > svlen) |
1797 | if (offset < 0 || offset > svlen) |
… | |
… | |
1800 | } |
1811 | } |
1801 | OUTPUT: |
1812 | OUTPUT: |
1802 | RETVAL |
1813 | RETVAL |
1803 | |
1814 | |
1804 | int |
1815 | int |
1805 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1816 | munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef) |
1806 | CODE: |
1817 | CODE: |
1807 | { |
1818 | { |
1808 | STRLEN svlen; |
1819 | STRLEN svlen; |
1809 | void *addr = SvPVbyte (scalar, svlen); |
1820 | void *addr = SvPVbyte (scalar, svlen); |
1810 | size_t len = SvUV (length); |
1821 | size_t len = SvUV (length); |
… | |
… | |
1866 | #else |
1877 | #else |
1867 | RETVAL = EIO_ENOSYS (); |
1878 | RETVAL = EIO_ENOSYS (); |
1868 | #endif |
1879 | #endif |
1869 | OUTPUT: |
1880 | OUTPUT: |
1870 | RETVAL |
1881 | RETVAL |
|
|
1882 | |
|
|
1883 | int |
|
|
1884 | pipesize (aio_rfd rfh, int new_size = -1) |
|
|
1885 | PROTOTYPE: $;$ |
|
|
1886 | CODE: |
|
|
1887 | #if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) |
|
|
1888 | if (new_size >= 0) |
|
|
1889 | RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size); |
|
|
1890 | else |
|
|
1891 | RETVAL = fcntl (rfh, F_GETPIPE_SZ); |
|
|
1892 | #else |
|
|
1893 | errno = ENOSYS; |
|
|
1894 | RETVAL = -1; |
|
|
1895 | #endif |
|
|
1896 | OUTPUT: |
|
|
1897 | RETVAL |
|
|
1898 | |
|
|
1899 | void |
|
|
1900 | pipe2 (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 | } |
1871 | |
1923 | |
1872 | void _on_next_submit (SV *cb) |
1924 | void _on_next_submit (SV *cb) |
1873 | CODE: |
1925 | CODE: |
1874 | SvREFCNT_dec (on_next_submit); |
1926 | SvREFCNT_dec (on_next_submit); |
1875 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1927 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
… | |
… | |
1910 | cancel (aio_req_ornot req) |
1962 | cancel (aio_req_ornot req) |
1911 | CODE: |
1963 | CODE: |
1912 | eio_cancel (req); |
1964 | eio_cancel (req); |
1913 | |
1965 | |
1914 | void |
1966 | void |
1915 | cb (aio_req_ornot req, SV *callback=&PL_sv_undef) |
1967 | cb (aio_req_ornot req, SV *callback = NO_INIT) |
1916 | PPCODE: |
1968 | PPCODE: |
1917 | { |
1969 | { |
1918 | if (GIMME_V != G_VOID) |
1970 | if (GIMME_V != G_VOID) |
1919 | 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); |
1920 | |
1972 | |
1921 | if (items > 1) |
1973 | if (items > 1) |
1922 | { |
1974 | { |
1923 | SV *cb_cv =get_cb (callback); |
1975 | SV *cb_cv = get_cb (callback); |
1924 | |
1976 | |
1925 | SvREFCNT_dec (req->callback); |
1977 | SvREFCNT_dec (req->callback); |
1926 | req->callback = SvREFCNT_inc (cb_cv); |
1978 | req->callback = SvREFCNT_inc (cb_cv); |
1927 | } |
1979 | } |
1928 | } |
1980 | } |
… | |
… | |
1985 | limit (aio_req grp, int limit) |
2037 | limit (aio_req grp, int limit) |
1986 | CODE: |
2038 | CODE: |
1987 | eio_grp_limit (grp, limit); |
2039 | eio_grp_limit (grp, limit); |
1988 | |
2040 | |
1989 | void |
2041 | void |
1990 | feed (aio_req grp, SV *callback=&PL_sv_undef) |
2042 | feed (aio_req grp, SV *callback = &PL_sv_undef) |
1991 | CODE: |
2043 | CODE: |
1992 | { |
2044 | { |
1993 | SvREFCNT_dec (grp->sv2); |
2045 | SvREFCNT_dec (grp->sv2); |
1994 | grp->sv2 = newSVsv (callback); |
2046 | grp->sv2 = newSVsv (callback); |
1995 | grp->feed = aio_grp_feed; |
2047 | grp->feed = aio_grp_feed; |