… | |
… | |
22 | #endif |
22 | #endif |
23 | |
23 | |
24 | #if __linux__ |
24 | #if __linux__ |
25 | # include <linux/fs.h> |
25 | # include <linux/fs.h> |
26 | # ifdef FS_IOC_FIEMAP |
26 | # ifdef FS_IOC_FIEMAP |
|
|
27 | # include <linux/types.h> |
27 | # include <linux/fiemap.h> |
28 | # include <linux/fiemap.h> |
28 | # define HAVE_FIEMAP 1 |
29 | # define HAVE_FIEMAP 1 |
29 | # endif |
30 | # endif |
30 | #endif |
31 | #endif |
31 | |
32 | |
… | |
… | |
152 | #endif |
153 | #endif |
153 | #ifndef minor |
154 | #ifndef minor |
154 | # define minor(dev) ((dev) & 0xff) |
155 | # define minor(dev) ((dev) & 0xff) |
155 | #endif |
156 | #endif |
156 | |
157 | |
157 | #ifndef PAGESIZE |
158 | #if PAGESIZE <= 0 |
158 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
159 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
159 | #endif |
160 | #endif |
160 | |
161 | |
161 | /*****************************************************************************/ |
162 | /*****************************************************************************/ |
162 | |
163 | |
… | |
… | |
164 | fiemap (eio_req *req) |
165 | fiemap (eio_req *req) |
165 | { |
166 | { |
166 | req->result = -1; |
167 | req->result = -1; |
167 | |
168 | |
168 | #if HAVE_FIEMAP |
169 | #if HAVE_FIEMAP |
|
|
170 | /* assume some c99 */ |
|
|
171 | struct fiemap *fiemap = 0; |
|
|
172 | size_t end_offset; |
169 | int count = req->int3; |
173 | int count = req->int3; |
170 | |
174 | |
171 | /* heuristic: first try with 64 extents if we don't know how many, */ |
175 | req->flags |= EIO_FLAG_PTR1_FREE; |
172 | /* as most files have (hopefully) fewer than this many extents */ |
176 | |
173 | /* in fact, most should have <= 2, so maybe the 72 below is probably overkill */ |
177 | /* heuristic: start with 512 bytes (8 extents), and if that isn't enough, */ |
|
|
178 | /* increase in 3.5kb steps */ |
174 | if (count < 0) |
179 | if (count < 0) |
175 | count = 72; /* for what it's worth, 72 extents fit nicely into 4kb */ |
180 | count = 8; |
|
|
181 | |
|
|
182 | fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
|
|
183 | errno = ENOMEM; |
|
|
184 | if (!fiemap) |
|
|
185 | return; |
|
|
186 | |
|
|
187 | req->ptr1 = fiemap; |
|
|
188 | |
|
|
189 | fiemap->fm_start = req->offs; |
|
|
190 | fiemap->fm_length = req->size; |
|
|
191 | fiemap->fm_flags = req->int2; |
|
|
192 | fiemap->fm_extent_count = count; |
|
|
193 | |
|
|
194 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap) < 0) |
|
|
195 | return; |
|
|
196 | |
|
|
197 | if (req->int3 >= 0 /* not autosizing */ |
|
|
198 | || !fiemap->fm_mapped_extents /* no more extents */ |
|
|
199 | || fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST /* hit eof */) |
|
|
200 | goto done; |
|
|
201 | |
|
|
202 | /* else we have to loop - |
|
|
203 | * 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 |
|
|
205 | * extents, without telling us it left any out. this complicates |
|
|
206 | * this quite a bit. |
|
|
207 | */ |
|
|
208 | |
|
|
209 | end_offset = fiemap->fm_length + (fiemap->fm_length == FIEMAP_MAX_OFFSET ? 0 : fiemap->fm_start); |
176 | |
210 | |
177 | for (;;) |
211 | for (;;) |
178 | { |
212 | { |
|
|
213 | /* we go in 54 extent steps - 3kb, in the hope that this fits nicely on the eio stack (normally 16+ kb) */ |
|
|
214 | char scratch[3072]; |
|
|
215 | struct fiemap *incmap = (struct fiemap *)scratch; |
|
|
216 | |
|
|
217 | incmap->fm_start = fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_logical |
|
|
218 | + fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_length; |
|
|
219 | incmap->fm_length = fiemap->fm_length - (incmap->fm_start - fiemap->fm_start); |
|
|
220 | incmap->fm_flags = fiemap->fm_flags; |
|
|
221 | incmap->fm_extent_count = (sizeof (scratch) - sizeof (struct fiemap)) / sizeof (struct fiemap_extent); |
|
|
222 | |
|
|
223 | if (ioctl (req->int1, FS_IOC_FIEMAP, incmap) < 0) |
|
|
224 | return; |
|
|
225 | |
|
|
226 | if (!incmap->fm_mapped_extents) |
|
|
227 | goto done; |
|
|
228 | |
|
|
229 | count = fiemap->fm_mapped_extents + incmap->fm_mapped_extents; |
179 | struct fiemap *fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
230 | fiemap = realloc (fiemap, sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
180 | errno = ENOMEM; |
231 | errno = ENOMEM; |
181 | if (!fiemap) |
232 | if (!fiemap) |
182 | return; |
233 | return; |
183 | |
234 | |
184 | req->ptr1 = fiemap; |
235 | req->ptr1 = fiemap; |
185 | req->flags |= EIO_FLAG_PTR1_FREE; |
|
|
186 | |
236 | |
187 | fiemap->fm_start = req->offs; |
237 | for (count = 0; count < incmap->fm_mapped_extents; ++count) |
188 | fiemap->fm_length = req->size; |
238 | { |
189 | fiemap->fm_flags = req->int2; |
239 | struct fiemap_extent *e = incmap->fm_extents + count; |
190 | fiemap->fm_extent_count = count; |
|
|
191 | |
240 | |
192 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
241 | if (e->fe_logical + e->fe_length >= end_offset) |
193 | return; |
242 | goto done; |
194 | |
243 | |
195 | if (req->int3 >= 0) |
244 | fiemap->fm_extents [fiemap->fm_mapped_extents++] = *e; |
196 | break; /* when not autosizing we are done */ |
|
|
197 | |
245 | |
198 | if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) |
246 | if (e->fe_flags & FIEMAP_EXTENT_LAST) |
199 | break; /* autosizing successful, we are done */ |
247 | goto done; |
200 | |
248 | |
201 | fiemap->fm_flags = req->int2; |
249 | } |
202 | fiemap->fm_extent_count = 0; |
|
|
203 | |
|
|
204 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
|
|
205 | return; |
|
|
206 | |
|
|
207 | count = fiemap->fm_mapped_extents; |
|
|
208 | |
|
|
209 | free (fiemap); |
|
|
210 | } |
250 | } |
211 | |
251 | |
|
|
252 | done: |
212 | req->result = 0; |
253 | req->result = 0; |
213 | |
254 | |
214 | #else |
255 | #else |
215 | errno = ENOSYS; |
256 | errno = ENOSYS; |
216 | #endif |
257 | #endif |
… | |
… | |
469 | #ifndef _WIN32 |
510 | #ifndef _WIN32 |
470 | if (req->result >= 0) |
511 | if (req->result >= 0) |
471 | { |
512 | { |
472 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
513 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
473 | HV *hv = newHV (); |
514 | HV *hv = newHV (); |
|
|
515 | /* POSIX requires fsid to be unsigned long, but AIX in its infinite wisdom |
|
|
516 | * chooses to make it a struct. |
|
|
517 | */ |
|
|
518 | unsigned long fsid = 0; |
|
|
519 | memcpy (&fsid, &f->f_fsid, sizeof (unsigned long) < sizeof (f->f_fsid) ? sizeof (unsigned long) : sizeof (f->f_fsid)); |
474 | |
520 | |
475 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
521 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
476 | |
522 | |
477 | hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); |
523 | hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); |
478 | hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); |
524 | hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); |
… | |
… | |
480 | hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); |
526 | hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); |
481 | hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); |
527 | hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); |
482 | hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); |
528 | hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); |
483 | hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); |
529 | hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); |
484 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
530 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
485 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
531 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (fsid ), 0); |
486 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
532 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
487 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
533 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
488 | } |
534 | } |
489 | #endif |
535 | #endif |
490 | |
536 | |
… | |
… | |
697 | } |
743 | } |
698 | |
744 | |
699 | /*****************************************************************************/ |
745 | /*****************************************************************************/ |
700 | |
746 | |
701 | #if !_POSIX_MAPPED_FILES |
747 | #if !_POSIX_MAPPED_FILES |
702 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
748 | # define mmap(addr,length,prot,flags,fd,offs) EIO_ENOSYS () |
703 | # define munmap(addr,length) (errno = ENOSYS, -1) |
749 | # define munmap(addr,length) EIO_ENOSYS () |
704 | #endif |
750 | #endif |
705 | |
751 | |
706 | #if !_POSIX_MEMORY_PROTECTION |
752 | #if !_POSIX_MEMORY_PROTECTION |
707 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
753 | # define mprotect(addr,len,prot) EIO_ENOSYS () |
708 | # define PROT_NONE 0 |
754 | # define PROT_NONE 0 |
709 | # define PROT_WRITE 0 |
755 | # define PROT_WRITE 0 |
710 | # define MAP_PRIVATE 0 |
756 | # define MAP_PRIVATE 0 |
711 | # define MAP_SHARED 0 |
757 | # define MAP_SHARED 0 |
712 | # define MAP_FIXED 0 |
758 | # define MAP_FIXED 0 |
… | |
… | |
955 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
1001 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
956 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
1002 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
957 | const_iv (FIEMAP_EXTENT_MERGED) |
1003 | const_iv (FIEMAP_EXTENT_MERGED) |
958 | const_iv (FIEMAP_EXTENT_SHARED) |
1004 | const_iv (FIEMAP_EXTENT_SHARED) |
959 | |
1005 | |
|
|
1006 | const_iv (SPLICE_F_MOVE) |
|
|
1007 | const_iv (SPLICE_F_NONBLOCK) |
|
|
1008 | const_iv (SPLICE_F_MORE) |
|
|
1009 | const_iv (SPLICE_F_GIFT) |
|
|
1010 | |
|
|
1011 | const_iv (SEEK_DATA) |
|
|
1012 | const_iv (SEEK_HOLE) |
|
|
1013 | |
|
|
1014 | /* libeio constants */ |
960 | const_eio (SEEK_SET) |
1015 | const_eio (SEEK_SET) |
961 | const_eio (SEEK_CUR) |
1016 | const_eio (SEEK_CUR) |
962 | const_eio (SEEK_END) |
1017 | const_eio (SEEK_END) |
963 | |
1018 | |
964 | const_eio (MCL_FUTURE) |
1019 | const_eio (MCL_FUTURE) |
… | |
… | |
973 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
1028 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
974 | const_eio (SYNC_FILE_RANGE_WRITE) |
1029 | const_eio (SYNC_FILE_RANGE_WRITE) |
975 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
1030 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
976 | |
1031 | |
977 | const_eio (FALLOC_FL_KEEP_SIZE) |
1032 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
1033 | const_eio (FALLOC_FL_PUNCH_HOLE) |
978 | |
1034 | |
979 | const_eio (READDIR_DENTS) |
1035 | const_eio (READDIR_DENTS) |
980 | const_eio (READDIR_DIRS_FIRST) |
1036 | const_eio (READDIR_DIRS_FIRST) |
981 | const_eio (READDIR_STAT_ORDER) |
1037 | const_eio (READDIR_STAT_ORDER) |
982 | const_eio (READDIR_FOUND_UNKNOWN) |
1038 | const_eio (READDIR_FOUND_UNKNOWN) |
… | |
… | |
1083 | aio_fsync = EIO_FSYNC |
1139 | aio_fsync = EIO_FSYNC |
1084 | aio_fdatasync = EIO_FDATASYNC |
1140 | aio_fdatasync = EIO_FDATASYNC |
1085 | aio_syncfs = EIO_SYNCFS |
1141 | aio_syncfs = EIO_SYNCFS |
1086 | PPCODE: |
1142 | PPCODE: |
1087 | { |
1143 | { |
1088 | int fd = s_fileno_croak (fh, 0); |
1144 | int fd = s_fileno_croak (fh, 0); |
1089 | dREQ; |
1145 | dREQ; |
1090 | |
1146 | |
1091 | req->type = ix; |
1147 | req->type = ix; |
1092 | req->sv1 = newSVsv (fh); |
1148 | req->sv1 = newSVsv (fh); |
1093 | req->int1 = fd; |
1149 | req->int1 = fd; |
… | |
… | |
1097 | |
1153 | |
1098 | void |
1154 | void |
1099 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1155 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1100 | PPCODE: |
1156 | PPCODE: |
1101 | { |
1157 | { |
1102 | int fd = s_fileno_croak (fh, 0); |
1158 | int fd = s_fileno_croak (fh, 0); |
1103 | dREQ; |
1159 | dREQ; |
1104 | |
1160 | |
1105 | req->type = EIO_SYNC_FILE_RANGE; |
1161 | req->type = EIO_SYNC_FILE_RANGE; |
1106 | req->sv1 = newSVsv (fh); |
1162 | req->sv1 = newSVsv (fh); |
1107 | req->int1 = fd; |
1163 | req->int1 = fd; |
… | |
… | |
1111 | |
1167 | |
1112 | REQ_SEND; |
1168 | REQ_SEND; |
1113 | } |
1169 | } |
1114 | |
1170 | |
1115 | void |
1171 | void |
1116 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1172 | aio_allocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1117 | PPCODE: |
1173 | PPCODE: |
1118 | { |
1174 | { |
1119 | int fd = s_fileno_croak (fh, 0); |
1175 | int fd = s_fileno_croak (fh, 0); |
1120 | dREQ; |
1176 | dREQ; |
1121 | |
1177 | |
1122 | req->type = EIO_FALLOCATE; |
1178 | req->type = EIO_FALLOCATE; |
1123 | req->sv1 = newSVsv (fh); |
1179 | req->sv1 = newSVsv (fh); |
1124 | req->int1 = fd; |
1180 | req->int1 = fd; |
… | |
… | |
1132 | void |
1188 | void |
1133 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1189 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1134 | PPCODE: |
1190 | PPCODE: |
1135 | { |
1191 | { |
1136 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1192 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1137 | int fd = s_fileno_croak (fh, 0); |
1193 | int fd = s_fileno_croak (fh, 0); |
1138 | dREQ; |
1194 | dREQ; |
1139 | |
1195 | |
1140 | if (expect_false (close_fd < 0)) |
1196 | if (expect_false (close_fd < 0)) |
1141 | { |
1197 | { |
1142 | int pipefd [2]; |
1198 | int pipefd [2]; |
… | |
… | |
1205 | } |
1261 | } |
1206 | else |
1262 | else |
1207 | { |
1263 | { |
1208 | /* read: check type and grow scalar as necessary */ |
1264 | /* read: check type and grow scalar as necessary */ |
1209 | SvUPGRADE (data, SVt_PV); |
1265 | SvUPGRADE (data, SVt_PV); |
|
|
1266 | if (SvLEN (data) >= SvCUR (data)) |
1210 | svptr = SvGROW (data, len + dataoffset + 1); |
1267 | svptr = SvGROW (data, len + dataoffset + 1); |
|
|
1268 | else if (SvCUR (data) < len + dataoffset) |
|
|
1269 | croak ("length + dataoffset outside of scalar, and cannot grow"); |
1211 | } |
1270 | } |
1212 | |
1271 | |
1213 | { |
1272 | { |
1214 | dREQ; |
1273 | dREQ; |
1215 | |
1274 | |
… | |
… | |
1249 | |
1308 | |
1250 | void |
1309 | void |
1251 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1310 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1252 | PPCODE: |
1311 | PPCODE: |
1253 | { |
1312 | { |
1254 | int ifd = s_fileno_croak (in_fh , 0); |
1313 | int ifd = s_fileno_croak (in_fh , 0); |
1255 | int ofd = s_fileno_croak (out_fh, 1); |
1314 | int ofd = s_fileno_croak (out_fh, 1); |
1256 | dREQ; |
1315 | dREQ; |
1257 | |
1316 | |
1258 | req->type = EIO_SENDFILE; |
1317 | req->type = EIO_SENDFILE; |
1259 | req->sv1 = newSVsv (out_fh); |
1318 | req->sv1 = newSVsv (out_fh); |
1260 | req->int1 = ofd; |
1319 | req->int1 = ofd; |
… | |
… | |
1268 | |
1327 | |
1269 | void |
1328 | void |
1270 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1329 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1271 | PPCODE: |
1330 | PPCODE: |
1272 | { |
1331 | { |
1273 | int fd = s_fileno_croak (fh, 0); |
1332 | int fd = s_fileno_croak (fh, 0); |
1274 | dREQ; |
1333 | dREQ; |
1275 | |
1334 | |
1276 | req->type = EIO_READAHEAD; |
1335 | req->type = EIO_READAHEAD; |
1277 | req->sv1 = newSVsv (fh); |
1336 | req->sv1 = newSVsv (fh); |
1278 | req->int1 = fd; |
1337 | req->int1 = fd; |
… | |
… | |
1518 | |
1577 | |
1519 | void |
1578 | void |
1520 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1579 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
1521 | PPCODE: |
1580 | PPCODE: |
1522 | { |
1581 | { |
1523 | int fd = s_fileno_croak (fh, 0); |
1582 | int fd = s_fileno_croak (fh, 0); |
1524 | dREQ; |
1583 | dREQ; |
1525 | |
1584 | |
1526 | req->type = EIO_CUSTOM; |
1585 | req->type = EIO_CUSTOM; |
1527 | req->sv1 = newSVsv (fh); |
1586 | req->sv1 = newSVsv (fh); |
1528 | req->int1 = fd; |
1587 | req->int1 = fd; |
… | |
… | |
1557 | { |
1616 | { |
1558 | dREQ; |
1617 | dREQ; |
1559 | |
1618 | |
1560 | req->type = EIO_GROUP; |
1619 | req->type = EIO_GROUP; |
1561 | |
1620 | |
|
|
1621 | PUTBACK; |
1562 | req_submit (req); |
1622 | req_submit (req); |
|
|
1623 | SPAGAIN; |
|
|
1624 | |
1563 | XPUSHs (req_sv (req, aio_grp_stash)); |
1625 | XPUSHs (req_sv (req, aio_grp_stash)); |
1564 | } |
1626 | } |
1565 | |
1627 | |
1566 | void |
1628 | void |
1567 | aio_nop (SV *callback=&PL_sv_undef) |
1629 | aio_nop (SV *callback=&PL_sv_undef) |
… | |
… | |
1676 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1738 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1677 | OUTPUT: |
1739 | OUTPUT: |
1678 | RETVAL |
1740 | RETVAL |
1679 | |
1741 | |
1680 | void |
1742 | void |
1681 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1743 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh = &PL_sv_undef, off_t offset = 0) |
1682 | PPCODE: |
1744 | PPCODE: |
1683 | sv_unmagic (scalar, MMAP_MAGIC); |
1745 | sv_unmagic (scalar, MMAP_MAGIC); |
1684 | { |
1746 | { |
1685 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1747 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1686 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1748 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1719 | ALIAS: |
1781 | ALIAS: |
1720 | mprotect = 1 |
1782 | mprotect = 1 |
1721 | CODE: |
1783 | CODE: |
1722 | { |
1784 | { |
1723 | STRLEN svlen; |
1785 | STRLEN svlen; |
1724 | void *addr = SvPVbyte (scalar, svlen); |
1786 | void *addr = SvPVbyte (scalar, svlen); |
1725 | size_t len = SvUV (length); |
1787 | size_t len = SvUV (length); |
1726 | |
1788 | |
1727 | if (offset < 0) |
1789 | if (offset < 0) |
1728 | offset += svlen; |
1790 | offset += svlen; |
1729 | |
1791 | |
… | |
… | |
1748 | int |
1810 | int |
1749 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1811 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1750 | CODE: |
1812 | CODE: |
1751 | { |
1813 | { |
1752 | STRLEN svlen; |
1814 | STRLEN svlen; |
1753 | void *addr = SvPVbyte (scalar, svlen); |
1815 | void *addr = SvPVbyte (scalar, svlen); |
1754 | size_t len = SvUV (length); |
1816 | size_t len = SvUV (length); |
1755 | |
1817 | |
1756 | if (offset < 0) |
1818 | if (offset < 0) |
1757 | offset += svlen; |
1819 | offset += svlen; |
1758 | |
1820 | |
… | |
… | |
1765 | addr = (void *)(((intptr_t)addr) + offset); |
1827 | addr = (void *)(((intptr_t)addr) + offset); |
1766 | eio_page_align (&addr, &len); |
1828 | eio_page_align (&addr, &len); |
1767 | #if _POSIX_MEMLOCK_RANGE |
1829 | #if _POSIX_MEMLOCK_RANGE |
1768 | RETVAL = munlock (addr, len); |
1830 | RETVAL = munlock (addr, len); |
1769 | #else |
1831 | #else |
1770 | RETVAL = ((errno = ENOSYS), -1); |
1832 | RETVAL = EIO_ENOSYS (); |
1771 | #endif |
1833 | #endif |
1772 | } |
1834 | } |
1773 | OUTPUT: |
1835 | OUTPUT: |
1774 | RETVAL |
1836 | RETVAL |
1775 | |
1837 | |
… | |
… | |
1777 | munlockall () |
1839 | munlockall () |
1778 | CODE: |
1840 | CODE: |
1779 | #if _POSIX_MEMLOCK |
1841 | #if _POSIX_MEMLOCK |
1780 | munlockall (); |
1842 | munlockall (); |
1781 | #else |
1843 | #else |
|
|
1844 | RETVAL = EIO_ENOSYS (); |
|
|
1845 | #endif |
|
|
1846 | OUTPUT: |
|
|
1847 | RETVAL |
|
|
1848 | |
|
|
1849 | int |
|
|
1850 | splice (aio_rfd rfh, SV *off_in, aio_wfd wfh, SV *off_out, size_t length, unsigned int flags) |
|
|
1851 | CODE: |
|
|
1852 | { |
|
|
1853 | #if HAVE_LINUX_SPLICE |
|
|
1854 | loff_t off_in_, off_out_; |
|
|
1855 | RETVAL = splice ( |
|
|
1856 | rfh, SvOK (off_in ) ? (off_in_ = SvVAL64 (off_in )), &off_in_ : 0, |
|
|
1857 | wfh, SvOK (off_out) ? (off_out_ = SvVAL64 (off_out)), &off_out_ : 0, |
|
|
1858 | length, flags |
|
|
1859 | ); |
|
|
1860 | #else |
|
|
1861 | RETVAL = EIO_ENOSYS (); |
|
|
1862 | #endif |
|
|
1863 | } |
|
|
1864 | OUTPUT: |
|
|
1865 | RETVAL |
|
|
1866 | |
|
|
1867 | int |
|
|
1868 | tee (aio_rfd rfh, aio_wfd wfh, size_t length, unsigned int flags) |
|
|
1869 | CODE: |
|
|
1870 | #if HAVE_LINUX_SPLICE |
|
|
1871 | RETVAL = tee (rfh, wfh, length, flags); |
|
|
1872 | #else |
|
|
1873 | RETVAL = EIO_ENOSYS (); |
|
|
1874 | #endif |
|
|
1875 | OUTPUT: |
|
|
1876 | RETVAL |
|
|
1877 | |
|
|
1878 | int |
|
|
1879 | pipesize (aio_rfd rfh, int new_size = -1) |
|
|
1880 | PROTOTYPE: $;$ |
|
|
1881 | CODE: |
|
|
1882 | #if defined(F_SETPIPE_SZ) && defined(F_GETPIPE_SZ) |
|
|
1883 | if (new_size >= 0) |
|
|
1884 | RETVAL = fcntl (rfh, F_SETPIPE_SZ, new_size); |
|
|
1885 | else |
|
|
1886 | RETVAL = fcntl (rfh, F_GETPIPE_SZ); |
|
|
1887 | #else |
|
|
1888 | errno = ENOSYS; |
1782 | RETVAL = -1; |
1889 | RETVAL = -1; |
1783 | errno = ENOSYS; |
|
|
1784 | #endif |
1890 | #endif |
1785 | OUTPUT: |
1891 | OUTPUT: |
1786 | RETVAL |
1892 | RETVAL |
1787 | |
1893 | |
1788 | void _on_next_submit (SV *cb) |
1894 | void _on_next_submit (SV *cb) |