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.221 by root, Wed Aug 22 22:28:03 2012 UTC vs.
Revision 1.232 by root, Sat Jun 13 00:06:13 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
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
189 fiemap->fm_start = req->offs; 193 fiemap->fm_start = req->offs;
190 fiemap->fm_length = req->size; 194 fiemap->fm_length = req->size;
191 fiemap->fm_flags = req->int2; 195 fiemap->fm_flags = req->int2;
192 fiemap->fm_extent_count = count; 196 fiemap->fm_extent_count = count;
193 197
194 if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) 198 if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap) < 0)
195 return; 199 return;
196 200
197 if (req->int3 >= 0 /* not autosizing */ 201 if (req->int3 >= 0 /* not autosizing */
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
218 + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length; 222 + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length;
219 incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start); 223 incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start);
220 incmap->fm_flags = fiemap->fm_flags; 224 incmap->fm_flags = fiemap->fm_flags;
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)) 227 if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0)
224 return; 228 return;
229
230 if (!incmap->fm_mapped_extents)
231 goto done;
225 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)
301} 308}
302 309
303static SV * 310static SV *
304newSVaio_wd (aio_wd wd) 311newSVaio_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
309static aio_req 316static aio_req
310SvAIO_REQ (SV *sv) 317SvAIO_REQ (SV *sv)
311{ 318{
507#ifndef _WIN32 514#ifndef _WIN32
508 if (req->result >= 0) 515 if (req->result >= 0)
509 { 516 {
510 EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); 517 EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req);
511 HV *hv = newHV (); 518 HV *hv = newHV ();
519 /* POSIX requires fsid to be unsigned long, but AIX in its infinite wisdom
520 * chooses to make it a struct.
521 */
522 unsigned long fsid = 0;
523 memcpy (&fsid, &f->f_fsid, sizeof (unsigned long) < sizeof (f->f_fsid) ? sizeof (unsigned long) : sizeof (f->f_fsid));
512 524
513 rv = sv_2mortal (newRV_noinc ((SV *)hv)); 525 rv = sv_2mortal (newRV_noinc ((SV *)hv));
514 526
515 hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); 527 hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0);
516 hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); 528 hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0);
518 hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); 530 hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0);
519 hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); 531 hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0);
520 hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); 532 hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0);
521 hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); 533 hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0);
522 hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); 534 hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0);
523 hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); 535 hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (fsid ), 0);
524 hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); 536 hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0);
525 hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); 537 hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0);
526 } 538 }
527#endif 539#endif
528 540
1021 const_eio (SYNC_FILE_RANGE_WRITE) 1033 const_eio (SYNC_FILE_RANGE_WRITE)
1022 const_eio (SYNC_FILE_RANGE_WAIT_AFTER) 1034 const_eio (SYNC_FILE_RANGE_WAIT_AFTER)
1023 1035
1024 const_eio (FALLOC_FL_KEEP_SIZE) 1036 const_eio (FALLOC_FL_KEEP_SIZE)
1025 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)
1026 1040
1027 const_eio (READDIR_DENTS) 1041 const_eio (READDIR_DENTS)
1028 const_eio (READDIR_DIRS_FIRST) 1042 const_eio (READDIR_DIRS_FIRST)
1029 const_eio (READDIR_STAT_ORDER) 1043 const_eio (READDIR_STAT_ORDER)
1030 const_eio (READDIR_FOUND_UNKNOWN) 1044 const_eio (READDIR_FOUND_UNKNOWN)
1098 PROTOTYPE: $ 1112 PROTOTYPE: $
1099 CODE: 1113 CODE:
1100 max_outstanding = maxreqs; 1114 max_outstanding = maxreqs;
1101 1115
1102void 1116void
1103aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) 1117aio_wd (SV8 *pathname, SV *callback = &PL_sv_undef)
1104 PPCODE: 1118 PPCODE:
1105{ 1119{
1106 dREQ; 1120 dREQ;
1107 1121
1108 req->type = EIO_WD_OPEN; 1122 req->type = EIO_WD_OPEN;
1110 1124
1111 REQ_SEND; 1125 REQ_SEND;
1112} 1126}
1113 1127
1114void 1128void
1115aio_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)
1116 PPCODE: 1130 PPCODE:
1117{ 1131{
1118 dREQ; 1132 dREQ;
1119 1133
1120 req->type = EIO_OPEN; 1134 req->type = EIO_OPEN;
1124 1138
1125 REQ_SEND; 1139 REQ_SEND;
1126} 1140}
1127 1141
1128void 1142void
1129aio_fsync (SV *fh, SV *callback=&PL_sv_undef) 1143aio_fsync (SV *fh, SV *callback = &PL_sv_undef)
1130 ALIAS: 1144 ALIAS:
1131 aio_fsync = EIO_FSYNC 1145 aio_fsync = EIO_FSYNC
1132 aio_fdatasync = EIO_FDATASYNC 1146 aio_fdatasync = EIO_FDATASYNC
1133 aio_syncfs = EIO_SYNCFS 1147 aio_syncfs = EIO_SYNCFS
1134 PPCODE: 1148 PPCODE:
1142 1156
1143 REQ_SEND; 1157 REQ_SEND;
1144} 1158}
1145 1159
1146void 1160void
1147aio_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)
1148 PPCODE: 1162 PPCODE:
1149{ 1163{
1150 int fd = s_fileno_croak (fh, 0); 1164 int fd = s_fileno_croak (fh, 0);
1151 dREQ; 1165 dREQ;
1152 1166
1159 1173
1160 REQ_SEND; 1174 REQ_SEND;
1161} 1175}
1162 1176
1163void 1177void
1164aio_fallocate (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)
1165 PPCODE: 1179 PPCODE:
1166{ 1180{
1167 int fd = s_fileno_croak (fh, 0); 1181 int fd = s_fileno_croak (fh, 0);
1168 dREQ; 1182 dREQ;
1169 1183
1176 1190
1177 REQ_SEND; 1191 REQ_SEND;
1178} 1192}
1179 1193
1180void 1194void
1181aio_close (SV *fh, SV *callback=&PL_sv_undef) 1195aio_close (SV *fh, SV *callback = &PL_sv_undef)
1182 PPCODE: 1196 PPCODE:
1183{ 1197{
1184 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 */
1185 int fd = s_fileno_croak (fh, 0); 1199 int fd = s_fileno_croak (fh, 0);
1186 dREQ; 1200 dREQ;
1210 1224
1211 REQ_SEND; 1225 REQ_SEND;
1212} 1226}
1213 1227
1214void 1228void
1215aio_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)
1216 PPCODE: 1230 PPCODE:
1217{ 1231{
1218 int fd = s_fileno_croak (fh, 0); 1232 int fd = s_fileno_croak (fh, 0);
1219 dREQ; 1233 dREQ;
1220 1234
1226 1240
1227 REQ_SEND; 1241 REQ_SEND;
1228} 1242}
1229 1243
1230void 1244void
1231aio_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)
1232 ALIAS: 1246 ALIAS:
1233 aio_read = EIO_READ 1247 aio_read = EIO_READ
1234 aio_write = EIO_WRITE 1248 aio_write = EIO_WRITE
1235 PPCODE: 1249 PPCODE:
1236{ 1250{
1252 len = svlen - dataoffset; 1266 len = svlen - dataoffset;
1253 } 1267 }
1254 else 1268 else
1255 { 1269 {
1256 /* read: check type and grow scalar as necessary */ 1270 /* read: check type and grow scalar as necessary */
1257 SvUPGRADE (data, SVt_PV);
1258 if (SvLEN (data) >= SvCUR (data)) 1271 if (!SvPOK (data) || SvLEN (data) >= SvCUR (data))
1259 svptr = SvGROW (data, len + dataoffset + 1); 1272 svptr = sv_grow (data, len + dataoffset + 1);
1260 else if (SvCUR (data) < len + dataoffset) 1273 else if (SvCUR (data) < len + dataoffset)
1261 croak ("length + dataoffset outside of scalar, and cannot grow"); 1274 croak ("length + dataoffset outside of scalar, and cannot grow");
1262 } 1275 }
1263 1276
1264 { 1277 {
1282 REQ_SEND; 1295 REQ_SEND;
1283 } 1296 }
1284} 1297}
1285 1298
1286void 1299void
1287aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1300aio_readlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1288 ALIAS: 1301 ALIAS:
1289 aio_readlink = EIO_READLINK 1302 aio_readlink = EIO_READLINK
1290 aio_realpath = EIO_REALPATH 1303 aio_realpath = EIO_REALPATH
1291 PPCODE: 1304 PPCODE:
1292{ 1305{
1297 1310
1298 REQ_SEND; 1311 REQ_SEND;
1299} 1312}
1300 1313
1301void 1314void
1302aio_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)
1303 PPCODE: 1316 PPCODE:
1304{ 1317{
1305 int ifd = s_fileno_croak (in_fh , 0); 1318 int ifd = s_fileno_croak (in_fh , 0);
1306 int ofd = s_fileno_croak (out_fh, 1); 1319 int ofd = s_fileno_croak (out_fh, 1);
1307 dREQ; 1320 dREQ;
1316 1329
1317 REQ_SEND; 1330 REQ_SEND;
1318} 1331}
1319 1332
1320void 1333void
1321aio_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)
1322 PPCODE: 1335 PPCODE:
1323{ 1336{
1324 int fd = s_fileno_croak (fh, 0); 1337 int fd = s_fileno_croak (fh, 0);
1325 dREQ; 1338 dREQ;
1326 1339
1332 1345
1333 REQ_SEND; 1346 REQ_SEND;
1334} 1347}
1335 1348
1336void 1349void
1337aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) 1350aio_stat (SV8 *fh_or_path, SV *callback = &PL_sv_undef)
1338 ALIAS: 1351 ALIAS:
1339 aio_stat = EIO_STAT 1352 aio_stat = EIO_STAT
1340 aio_lstat = EIO_LSTAT 1353 aio_lstat = EIO_LSTAT
1341 aio_statvfs = EIO_STATVFS 1354 aio_statvfs = EIO_STATVFS
1342 PPCODE: 1355 PPCODE:
1363 RETVAL = makedev (maj, min); 1376 RETVAL = makedev (maj, min);
1364 OUTPUT: 1377 OUTPUT:
1365 RETVAL 1378 RETVAL
1366 1379
1367void 1380void
1368aio_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)
1369 PPCODE: 1382 PPCODE:
1370{ 1383{
1371 dREQ; 1384 dREQ;
1372 1385
1373 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; 1386 req->nv1 = SvOK (atime) ? SvNV (atime) : -1.;
1376 1389
1377 REQ_SEND; 1390 REQ_SEND;
1378} 1391}
1379 1392
1380void 1393void
1381aio_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)
1382 PPCODE: 1395 PPCODE:
1383{ 1396{
1384 dREQ; 1397 dREQ;
1385 1398
1386 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; 1399 req->offs = SvOK (offset) ? SvVAL64 (offset) : -1;
1388 1401
1389 REQ_SEND; 1402 REQ_SEND;
1390} 1403}
1391 1404
1392void 1405void
1393aio_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)
1394 PPCODE: 1407 PPCODE:
1395{ 1408{
1396 dREQ; 1409 dREQ;
1397 1410
1398 req->int2 = mode; 1411 req->int2 = mode;
1400 1413
1401 REQ_SEND; 1414 REQ_SEND;
1402} 1415}
1403 1416
1404void 1417void
1405aio_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)
1406 PPCODE: 1419 PPCODE:
1407{ 1420{
1408 dREQ; 1421 dREQ;
1409 1422
1410 req->int2 = SvOK (uid) ? SvIV (uid) : -1; 1423 req->int2 = SvOK (uid) ? SvIV (uid) : -1;
1413 1426
1414 REQ_SEND; 1427 REQ_SEND;
1415} 1428}
1416 1429
1417void 1430void
1418aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) 1431aio_readdirx (SV8 *pathname, IV flags, SV *callback = &PL_sv_undef)
1419 PPCODE: 1432 PPCODE:
1420{ 1433{
1421 dREQ; 1434 dREQ;
1422 1435
1423 req->type = EIO_READDIR; 1436 req->type = EIO_READDIR;
1430 1443
1431 REQ_SEND; 1444 REQ_SEND;
1432} 1445}
1433 1446
1434void 1447void
1435aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) 1448aio_mkdir (SV8 *pathname, int mode, SV *callback = &PL_sv_undef)
1436 PPCODE: 1449 PPCODE:
1437{ 1450{
1438 dREQ; 1451 dREQ;
1439 1452
1440 req->type = EIO_MKDIR; 1453 req->type = EIO_MKDIR;
1443 1456
1444 REQ_SEND; 1457 REQ_SEND;
1445} 1458}
1446 1459
1447void 1460void
1448aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) 1461aio_unlink (SV8 *pathname, SV *callback = &PL_sv_undef)
1449 ALIAS: 1462 ALIAS:
1450 aio_unlink = EIO_UNLINK 1463 aio_unlink = EIO_UNLINK
1451 aio_rmdir = EIO_RMDIR 1464 aio_rmdir = EIO_RMDIR
1452 aio_readdir = EIO_READDIR 1465 aio_readdir = EIO_READDIR
1453 PPCODE: 1466 PPCODE:
1459 1472
1460 REQ_SEND; 1473 REQ_SEND;
1461} 1474}
1462 1475
1463void 1476void
1464aio_link (SV8 *oldpath, SV8 *newpath, SV *callback=&PL_sv_undef) 1477aio_link (SV8 *oldpath, SV8 *newpath, SV *callback = &PL_sv_undef)
1465 ALIAS: 1478 ALIAS:
1466 aio_link = EIO_LINK 1479 aio_link = EIO_LINK
1467 aio_symlink = EIO_SYMLINK 1480 aio_symlink = EIO_SYMLINK
1468 aio_rename = EIO_RENAME 1481 aio_rename = EIO_RENAME
1469 PPCODE: 1482 PPCODE:
1478 1491
1479 REQ_SEND; 1492 REQ_SEND;
1480} 1493}
1481 1494
1482void 1495void
1483aio_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)
1484 PPCODE: 1497 PPCODE:
1485{ 1498{
1486 dREQ; 1499 dREQ;
1487 1500
1488 req->type = EIO_MKNOD; 1501 req->type = EIO_MKNOD;
1492 1505
1493 REQ_SEND; 1506 REQ_SEND;
1494} 1507}
1495 1508
1496void 1509void
1497aio_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)
1498 ALIAS: 1511 ALIAS:
1499 aio_mtouch = EIO_MTOUCH 1512 aio_mtouch = EIO_MTOUCH
1500 aio_msync = EIO_MSYNC 1513 aio_msync = EIO_MSYNC
1501 PPCODE: 1514 PPCODE:
1502{ 1515{
1525 REQ_SEND; 1538 REQ_SEND;
1526 } 1539 }
1527} 1540}
1528 1541
1529void 1542void
1530aio_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)
1531 PPCODE: 1544 PPCODE:
1532{ 1545{
1533 STRLEN svlen; 1546 STRLEN svlen;
1534 char *svptr = SvPVbyte (data, svlen); 1547 char *svptr = SvPVbyte (data, svlen);
1535 UV len = SvUV (length); 1548 UV len = SvUV (length);
1554 REQ_SEND; 1567 REQ_SEND;
1555 } 1568 }
1556} 1569}
1557 1570
1558void 1571void
1559aio_mlockall (IV flags, SV *callback=&PL_sv_undef) 1572aio_mlockall (IV flags, SV *callback = &PL_sv_undef)
1560 PPCODE: 1573 PPCODE:
1561{ 1574{
1562 dREQ; 1575 dREQ;
1563 1576
1564 req->type = EIO_MLOCKALL; 1577 req->type = EIO_MLOCKALL;
1566 1579
1567 REQ_SEND; 1580 REQ_SEND;
1568} 1581}
1569 1582
1570void 1583void
1571aio_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)
1572 PPCODE: 1585 PPCODE:
1573{ 1586{
1574 int fd = s_fileno_croak (fh, 0); 1587 int fd = s_fileno_croak (fh, 0);
1575 dREQ; 1588 dREQ;
1576 1589
1589 1602
1590 REQ_SEND; 1603 REQ_SEND;
1591} 1604}
1592 1605
1593void 1606void
1594aio_busy (double delay, SV *callback=&PL_sv_undef) 1607aio_busy (double delay, SV *callback = &PL_sv_undef)
1595 PPCODE: 1608 PPCODE:
1596{ 1609{
1597 dREQ; 1610 dREQ;
1598 1611
1599 req->type = EIO_BUSY; 1612 req->type = EIO_BUSY;
1601 1614
1602 REQ_SEND; 1615 REQ_SEND;
1603} 1616}
1604 1617
1605void 1618void
1606aio_group (SV *callback=&PL_sv_undef) 1619aio_group (SV *callback = &PL_sv_undef)
1607 PPCODE: 1620 PPCODE:
1608{ 1621{
1609 dREQ; 1622 dREQ;
1610 1623
1611 req->type = EIO_GROUP; 1624 req->type = EIO_GROUP;
1612 1625
1626 PUTBACK;
1613 req_submit (req); 1627 req_submit (req);
1628 SPAGAIN;
1629
1614 XPUSHs (req_sv (req, aio_grp_stash)); 1630 XPUSHs (req_sv (req, aio_grp_stash));
1615} 1631}
1616 1632
1617void 1633void
1618aio_nop (SV *callback=&PL_sv_undef) 1634aio_nop (SV *callback = &PL_sv_undef)
1619 ALIAS: 1635 ALIAS:
1620 aio_nop = EIO_NOP 1636 aio_nop = EIO_NOP
1621 aio_sync = EIO_SYNC 1637 aio_sync = EIO_SYNC
1622 PPCODE: 1638 PPCODE:
1623{ 1639{
1627 1643
1628 REQ_SEND; 1644 REQ_SEND;
1629} 1645}
1630 1646
1631int 1647int
1632aioreq_pri (int pri = 0) 1648aioreq_pri (int pri = NO_INIT)
1633 CODE: 1649 CODE:
1634 RETVAL = next_pri; 1650 RETVAL = next_pri;
1635 if (items > 0) 1651 if (items > 0)
1636 { 1652 {
1637 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; 1653 if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN;
1727 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); 1743 RETVAL = eio_sendfile_sync (ofh, ifh, offset, count);
1728 OUTPUT: 1744 OUTPUT:
1729 RETVAL 1745 RETVAL
1730 1746
1731void 1747void
1732mmap (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)
1733 PPCODE: 1749 PPCODE:
1734 sv_unmagic (scalar, MMAP_MAGIC); 1750 sv_unmagic (scalar, MMAP_MAGIC);
1735{ 1751{
1736 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;
1737 void *addr = (void *)mmap (0, length, prot, flags, fd, offset); 1753 void *addr = (void *)mmap (0, length, prot, flags, fd, offset);
1764munmap (SV *scalar) 1780munmap (SV *scalar)
1765 CODE: 1781 CODE:
1766 sv_unmagic (scalar, MMAP_MAGIC); 1782 sv_unmagic (scalar, MMAP_MAGIC);
1767 1783
1768int 1784int
1769madvise (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)
1770 ALIAS: 1786 ALIAS:
1771 mprotect = 1 1787 mprotect = 1
1772 CODE: 1788 CODE:
1773{ 1789{
1774 STRLEN svlen; 1790 STRLEN svlen;
1775 void *addr = SvPVbyte (scalar, svlen); 1791 void *addr = SvPVbyte (scalar, svlen);
1776 size_t len = SvUV (length); 1792 STRLEN len = SvUV (length);
1777 1793
1778 if (offset < 0) 1794 if (offset < 0)
1779 offset += svlen; 1795 offset += svlen;
1780 1796
1781 if (offset < 0 || offset > svlen) 1797 if (offset < 0 || offset > svlen)
1795} 1811}
1796 OUTPUT: 1812 OUTPUT:
1797 RETVAL 1813 RETVAL
1798 1814
1799int 1815int
1800munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) 1816munlock (SV *scalar, STRLEN offset = 0, SV *length = &PL_sv_undef)
1801 CODE: 1817 CODE:
1802{ 1818{
1803 STRLEN svlen; 1819 STRLEN svlen;
1804 void *addr = SvPVbyte (scalar, svlen); 1820 void *addr = SvPVbyte (scalar, svlen);
1805 size_t len = SvUV (length); 1821 size_t len = SvUV (length);
1860 RETVAL = tee (rfh, wfh, length, flags); 1876 RETVAL = tee (rfh, wfh, length, flags);
1861#else 1877#else
1862 RETVAL = EIO_ENOSYS (); 1878 RETVAL = EIO_ENOSYS ();
1863#endif 1879#endif
1864 OUTPUT: 1880 OUTPUT:
1881 RETVAL
1882
1883int
1884pipesize (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:
1865 RETVAL 1897 RETVAL
1866 1898
1867void _on_next_submit (SV *cb) 1899void _on_next_submit (SV *cb)
1868 CODE: 1900 CODE:
1869 SvREFCNT_dec (on_next_submit); 1901 SvREFCNT_dec (on_next_submit);
1905cancel (aio_req_ornot req) 1937cancel (aio_req_ornot req)
1906 CODE: 1938 CODE:
1907 eio_cancel (req); 1939 eio_cancel (req);
1908 1940
1909void 1941void
1910cb (aio_req_ornot req, SV *callback=&PL_sv_undef) 1942cb (aio_req_ornot req, SV *callback = NO_INIT)
1911 PPCODE: 1943 PPCODE:
1912{ 1944{
1913 if (GIMME_V != G_VOID) 1945 if (GIMME_V != G_VOID)
1914 XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef); 1946 XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef);
1915 1947
1916 if (items > 1) 1948 if (items > 1)
1917 { 1949 {
1918 SV *cb_cv =get_cb (callback); 1950 SV *cb_cv = get_cb (callback);
1919 1951
1920 SvREFCNT_dec (req->callback); 1952 SvREFCNT_dec (req->callback);
1921 req->callback = SvREFCNT_inc (cb_cv); 1953 req->callback = SvREFCNT_inc (cb_cv);
1922 } 1954 }
1923} 1955}
1980limit (aio_req grp, int limit) 2012limit (aio_req grp, int limit)
1981 CODE: 2013 CODE:
1982 eio_grp_limit (grp, limit); 2014 eio_grp_limit (grp, limit);
1983 2015
1984void 2016void
1985feed (aio_req grp, SV *callback=&PL_sv_undef) 2017feed (aio_req grp, SV *callback = &PL_sv_undef)
1986 CODE: 2018 CODE:
1987{ 2019{
1988 SvREFCNT_dec (grp->sv2); 2020 SvREFCNT_dec (grp->sv2);
1989 grp->sv2 = newSVsv (callback); 2021 grp->sv2 = newSVsv (callback);
1990 grp->feed = aio_grp_feed; 2022 grp->feed = aio_grp_feed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines