… | |
… | |
165 | |
165 | |
166 | #if _XOPEN_SOURCE < 600 || NO_MADVISE |
166 | #if _XOPEN_SOURCE < 600 || NO_MADVISE |
167 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
167 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
168 | #endif |
168 | #endif |
169 | |
169 | |
|
|
170 | #ifndef PROT_NONE |
|
|
171 | # define PROT_NONE 0 |
|
|
172 | #endif |
|
|
173 | #ifndef PROT_READ |
|
|
174 | # define PROT_READ 0 |
|
|
175 | #endif |
|
|
176 | #ifndef PROT_WRITE |
|
|
177 | # define PROT_READ 0 |
|
|
178 | #endif |
|
|
179 | #ifndef PROT_EXEC |
|
|
180 | # define PROT_EXEC 0 |
|
|
181 | #endif |
|
|
182 | |
170 | #ifndef ST_NODEV |
183 | #ifndef ST_NODEV |
171 | # define ST_NODEV 0 |
184 | # define ST_NODEV 0 |
172 | #endif |
185 | #endif |
173 | #ifndef ST_NOEXEC |
186 | #ifndef ST_NOEXEC |
174 | # define ST_NOEXEC 0 |
187 | # define ST_NOEXEC 0 |
… | |
… | |
194 | #ifndef ST_NODIRATIME |
207 | #ifndef ST_NODIRATIME |
195 | # define ST_NODIRATIME 0 |
208 | # define ST_NODIRATIME 0 |
196 | #endif |
209 | #endif |
197 | #ifndef ST_RELATIME |
210 | #ifndef ST_RELATIME |
198 | # define ST_RELATIME 0 |
211 | # define ST_RELATIME 0 |
199 | #endif |
|
|
200 | |
|
|
201 | #ifndef MCL_CURRENT |
|
|
202 | # define MCL_CURRENT 0 |
|
|
203 | #endif |
|
|
204 | #ifndef MCL_FUTURE |
|
|
205 | # define MCL_FUTURE 0 |
|
|
206 | #endif |
212 | #endif |
207 | |
213 | |
208 | #ifndef MAP_ANONYMOUS |
214 | #ifndef MAP_ANONYMOUS |
209 | # ifdef MAP_ANON |
215 | # ifdef MAP_ANON |
210 | # define MAP_ANONYMOUS MAP_ANON |
216 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
631 | /*****************************************************************************/ |
637 | /*****************************************************************************/ |
632 | |
638 | |
633 | #if !_POSIX_MAPPED_FILES |
639 | #if !_POSIX_MAPPED_FILES |
634 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
640 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
635 | # define munmap(addr,length) (errno = ENOSYS, -1) |
641 | # define munmap(addr,length) (errno = ENOSYS, -1) |
|
|
642 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
636 | #endif |
643 | #endif |
637 | |
644 | |
638 | #define MMAP_MAGIC PERL_MAGIC_ext |
645 | #define MMAP_MAGIC PERL_MAGIC_ext |
639 | |
646 | |
640 | static int |
647 | static int |
… | |
… | |
743 | const_iv (ST_IMMUTABLE) |
750 | const_iv (ST_IMMUTABLE) |
744 | const_iv (ST_NOATIME) |
751 | const_iv (ST_NOATIME) |
745 | const_iv (ST_NODIRATIME) |
752 | const_iv (ST_NODIRATIME) |
746 | const_iv (ST_RELATIME) |
753 | const_iv (ST_RELATIME) |
747 | |
754 | |
|
|
755 | const_iv (PROT_NONE) |
748 | const_iv (PROT_EXEC) |
756 | const_iv (PROT_EXEC) |
749 | const_iv (PROT_NONE) |
|
|
750 | const_iv (PROT_READ) |
757 | const_iv (PROT_READ) |
751 | const_iv (PROT_WRITE) |
758 | const_iv (PROT_WRITE) |
752 | |
759 | |
753 | /*const_iv (MAP_FIXED)*/ |
760 | /*const_iv (MAP_FIXED)*/ |
754 | const_iv (MAP_PRIVATE) |
761 | const_iv (MAP_PRIVATE) |
… | |
… | |
760 | const_iv (MAP_LOCKED) |
767 | const_iv (MAP_LOCKED) |
761 | const_iv (MAP_NORESERVE) |
768 | const_iv (MAP_NORESERVE) |
762 | const_iv (MAP_POPULATE) |
769 | const_iv (MAP_POPULATE) |
763 | const_iv (MAP_NONBLOCK) |
770 | const_iv (MAP_NONBLOCK) |
764 | |
771 | |
765 | const_iv (MCL_FUTURE) |
772 | const_eio (MCL_FUTURE) |
766 | const_iv (MCL_CURRENT) |
773 | const_eio (MCL_CURRENT) |
767 | |
774 | |
768 | const_eio (MS_ASYNC) |
775 | const_eio (MS_ASYNC) |
769 | const_eio (MS_INVALIDATE) |
776 | const_eio (MS_INVALIDATE) |
770 | const_eio (MS_SYNC) |
777 | const_eio (MS_SYNC) |
771 | |
778 | |
… | |
… | |
845 | CODE: |
852 | CODE: |
846 | max_outstanding = maxreqs; |
853 | max_outstanding = maxreqs; |
847 | |
854 | |
848 | void |
855 | void |
849 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
856 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
850 | PROTOTYPE: $$$;$ |
|
|
851 | PPCODE: |
857 | PPCODE: |
852 | { |
858 | { |
853 | dREQ; |
859 | dREQ; |
854 | |
860 | |
855 | req->type = EIO_OPEN; |
861 | req->type = EIO_OPEN; |
… | |
… | |
861 | REQ_SEND; |
867 | REQ_SEND; |
862 | } |
868 | } |
863 | |
869 | |
864 | void |
870 | void |
865 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
871 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
866 | PROTOTYPE: $;$ |
|
|
867 | ALIAS: |
872 | ALIAS: |
868 | aio_fsync = EIO_FSYNC |
873 | aio_fsync = EIO_FSYNC |
869 | aio_fdatasync = EIO_FDATASYNC |
874 | aio_fdatasync = EIO_FDATASYNC |
870 | PPCODE: |
875 | PPCODE: |
871 | { |
876 | { |
… | |
… | |
879 | REQ_SEND (req); |
884 | REQ_SEND (req); |
880 | } |
885 | } |
881 | |
886 | |
882 | void |
887 | void |
883 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
888 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
884 | PROTOTYPE: $$$$;$ |
|
|
885 | PPCODE: |
889 | PPCODE: |
886 | { |
890 | { |
887 | int fd = s_fileno_croak (fh, 0); |
891 | int fd = s_fileno_croak (fh, 0); |
888 | dREQ; |
892 | dREQ; |
889 | |
893 | |
… | |
… | |
897 | REQ_SEND (req); |
901 | REQ_SEND (req); |
898 | } |
902 | } |
899 | |
903 | |
900 | void |
904 | void |
901 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
905 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
902 | PROTOTYPE: $;$ |
|
|
903 | PPCODE: |
906 | PPCODE: |
904 | { |
907 | { |
905 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
908 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
906 | int fd = s_fileno_croak (fh, 0); |
909 | int fd = s_fileno_croak (fh, 0); |
907 | dREQ; |
910 | dREQ; |
… | |
… | |
929 | void |
932 | void |
930 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
933 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
931 | ALIAS: |
934 | ALIAS: |
932 | aio_read = EIO_READ |
935 | aio_read = EIO_READ |
933 | aio_write = EIO_WRITE |
936 | aio_write = EIO_WRITE |
934 | PROTOTYPE: $$$$$;$ |
|
|
935 | PPCODE: |
937 | PPCODE: |
936 | { |
938 | { |
937 | STRLEN svlen; |
939 | STRLEN svlen; |
938 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
940 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
939 | char *svptr = SvPVbyte (data, svlen); |
941 | char *svptr = SvPVbyte (data, svlen); |
… | |
… | |
980 | } |
982 | } |
981 | } |
983 | } |
982 | |
984 | |
983 | void |
985 | void |
984 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
986 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
985 | PROTOTYPE: $$;$ |
|
|
986 | PPCODE: |
987 | PPCODE: |
987 | { |
988 | { |
988 | SV *data; |
989 | SV *data; |
989 | dREQ; |
990 | dREQ; |
990 | |
991 | |
… | |
… | |
995 | REQ_SEND; |
996 | REQ_SEND; |
996 | } |
997 | } |
997 | |
998 | |
998 | void |
999 | void |
999 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1000 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1000 | PROTOTYPE: $$$$;$ |
|
|
1001 | PPCODE: |
1001 | PPCODE: |
1002 | { |
1002 | { |
1003 | int ifd = s_fileno_croak (in_fh , 0); |
1003 | int ifd = s_fileno_croak (in_fh , 0); |
1004 | int ofd = s_fileno_croak (out_fh, 1); |
1004 | int ofd = s_fileno_croak (out_fh, 1); |
1005 | dREQ; |
1005 | dREQ; |
… | |
… | |
1015 | REQ_SEND; |
1015 | REQ_SEND; |
1016 | } |
1016 | } |
1017 | |
1017 | |
1018 | void |
1018 | void |
1019 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1019 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1020 | PROTOTYPE: $$$;$ |
|
|
1021 | PPCODE: |
1020 | PPCODE: |
1022 | { |
1021 | { |
1023 | int fd = s_fileno_croak (fh, 0); |
1022 | int fd = s_fileno_croak (fh, 0); |
1024 | dREQ; |
1023 | dREQ; |
1025 | |
1024 | |
… | |
… | |
1226 | void |
1225 | void |
1227 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1226 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1228 | ALIAS: |
1227 | ALIAS: |
1229 | aio_mtouch = EIO_MTOUCH |
1228 | aio_mtouch = EIO_MTOUCH |
1230 | aio_msync = EIO_MSYNC |
1229 | aio_msync = EIO_MSYNC |
1231 | PROTOTYPE: $$$$;$ |
|
|
1232 | PPCODE: |
1230 | PPCODE: |
1233 | { |
1231 | { |
1234 | STRLEN svlen; |
1232 | STRLEN svlen; |
|
|
1233 | char *svptr = SvPVbyte (data, svlen); |
1235 | UV len = SvUV (length); |
1234 | UV len = SvUV (length); |
1236 | char *svptr = SvPVbyte (data, svlen); |
|
|
1237 | |
1235 | |
1238 | if (offset < 0) |
1236 | if (offset < 0) |
1239 | offset += svlen; |
1237 | offset += svlen; |
1240 | |
1238 | |
1241 | if (offset < 0 || offset > svlen) |
1239 | if (offset < 0 || offset > svlen) |
… | |
… | |
1246 | |
1244 | |
1247 | { |
1245 | { |
1248 | dREQ; |
1246 | dREQ; |
1249 | |
1247 | |
1250 | req->type = ix; |
1248 | req->type = ix; |
1251 | req->size = len; |
|
|
1252 | req->sv2 = SvREFCNT_inc (data); |
1249 | req->sv2 = SvREFCNT_inc (data); |
1253 | req->ptr2 = (char *)svptr + offset; |
1250 | req->ptr2 = (char *)svptr + offset; |
|
|
1251 | req->size = len; |
1254 | req->int1 = flags; |
1252 | req->int1 = flags; |
1255 | |
1253 | |
1256 | REQ_SEND; |
1254 | REQ_SEND; |
1257 | } |
1255 | } |
1258 | } |
1256 | } |
1259 | |
1257 | |
1260 | void |
1258 | void |
|
|
1259 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
|
|
1260 | PPCODE: |
|
|
1261 | { |
|
|
1262 | |
|
|
1263 | STRLEN svlen; |
|
|
1264 | char *svptr = SvPVbyte (data, svlen); |
|
|
1265 | UV len = SvUV (length); |
|
|
1266 | |
|
|
1267 | if (offset < 0) |
|
|
1268 | offset += svlen; |
|
|
1269 | |
|
|
1270 | if (offset < 0 || offset > svlen) |
|
|
1271 | croak ("offset outside of scalar"); |
|
|
1272 | |
|
|
1273 | if (!SvOK (length) || len + offset > svlen) |
|
|
1274 | len = svlen - offset; |
|
|
1275 | |
|
|
1276 | { |
|
|
1277 | dREQ; |
|
|
1278 | |
|
|
1279 | req->type = EIO_MLOCK; |
|
|
1280 | req->sv2 = SvREFCNT_inc (data); |
|
|
1281 | req->ptr2 = (char *)svptr + offset; |
|
|
1282 | req->size = len; |
|
|
1283 | |
|
|
1284 | REQ_SEND; |
|
|
1285 | } |
|
|
1286 | } |
|
|
1287 | |
|
|
1288 | void |
|
|
1289 | aio_mlockall (IV flags, SV *callback=&PL_sv_undef) |
|
|
1290 | PPCODE: |
|
|
1291 | { |
|
|
1292 | dREQ; |
|
|
1293 | |
|
|
1294 | req->type = EIO_MLOCKALL; |
|
|
1295 | req->int1 = flags; |
|
|
1296 | |
|
|
1297 | REQ_SEND; |
|
|
1298 | } |
|
|
1299 | |
|
|
1300 | void |
1261 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1301 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1262 | PPCODE: |
1302 | PPCODE: |
1263 | { |
1303 | { |
1264 | dREQ; |
1304 | dREQ; |
1265 | |
1305 | |
… | |
… | |
1269 | REQ_SEND; |
1309 | REQ_SEND; |
1270 | } |
1310 | } |
1271 | |
1311 | |
1272 | void |
1312 | void |
1273 | aio_group (SV *callback=&PL_sv_undef) |
1313 | aio_group (SV *callback=&PL_sv_undef) |
1274 | PROTOTYPE: ;$ |
|
|
1275 | PPCODE: |
1314 | PPCODE: |
1276 | { |
1315 | { |
1277 | dREQ; |
1316 | dREQ; |
1278 | |
1317 | |
1279 | req->type = EIO_GROUP; |
1318 | req->type = EIO_GROUP; |
… | |
… | |
1296 | REQ_SEND; |
1335 | REQ_SEND; |
1297 | } |
1336 | } |
1298 | |
1337 | |
1299 | int |
1338 | int |
1300 | aioreq_pri (int pri = 0) |
1339 | aioreq_pri (int pri = 0) |
1301 | PROTOTYPE: ;$ |
|
|
1302 | CODE: |
1340 | CODE: |
1303 | RETVAL = next_pri; |
1341 | RETVAL = next_pri; |
1304 | if (items > 0) |
1342 | if (items > 0) |
1305 | { |
1343 | { |
1306 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1344 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
… | |
… | |
1318 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1356 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1319 | next_pri = nice; |
1357 | next_pri = nice; |
1320 | |
1358 | |
1321 | void |
1359 | void |
1322 | flush () |
1360 | flush () |
1323 | PROTOTYPE: |
|
|
1324 | CODE: |
1361 | CODE: |
1325 | while (eio_nreqs ()) |
1362 | while (eio_nreqs ()) |
1326 | { |
1363 | { |
1327 | poll_wait (); |
1364 | poll_wait (); |
1328 | poll_cb (); |
1365 | poll_cb (); |
1329 | } |
1366 | } |
1330 | |
1367 | |
1331 | int |
1368 | int |
1332 | poll() |
1369 | poll () |
1333 | PROTOTYPE: |
|
|
1334 | CODE: |
1370 | CODE: |
1335 | poll_wait (); |
1371 | poll_wait (); |
1336 | RETVAL = poll_cb (); |
1372 | RETVAL = poll_cb (); |
1337 | OUTPUT: |
1373 | OUTPUT: |
1338 | RETVAL |
1374 | RETVAL |
1339 | |
1375 | |
1340 | int |
1376 | int |
1341 | poll_fileno() |
1377 | poll_fileno () |
1342 | PROTOTYPE: |
|
|
1343 | CODE: |
1378 | CODE: |
1344 | RETVAL = s_epipe_fd (&respipe); |
1379 | RETVAL = s_epipe_fd (&respipe); |
1345 | OUTPUT: |
1380 | OUTPUT: |
1346 | RETVAL |
1381 | RETVAL |
1347 | |
1382 | |
1348 | int |
1383 | int |
1349 | poll_cb(...) |
1384 | poll_cb (...) |
1350 | PROTOTYPE: |
1385 | PROTOTYPE: |
1351 | CODE: |
1386 | CODE: |
1352 | RETVAL = poll_cb (); |
1387 | RETVAL = poll_cb (); |
1353 | OUTPUT: |
1388 | OUTPUT: |
1354 | RETVAL |
1389 | RETVAL |
1355 | |
1390 | |
1356 | void |
1391 | void |
1357 | poll_wait() |
1392 | poll_wait () |
1358 | PROTOTYPE: |
|
|
1359 | CODE: |
1393 | CODE: |
1360 | poll_wait (); |
1394 | poll_wait (); |
1361 | |
1395 | |
1362 | int |
1396 | int |
1363 | nreqs() |
1397 | nreqs () |
1364 | PROTOTYPE: |
|
|
1365 | CODE: |
1398 | CODE: |
1366 | RETVAL = eio_nreqs (); |
1399 | RETVAL = eio_nreqs (); |
1367 | OUTPUT: |
1400 | OUTPUT: |
1368 | RETVAL |
1401 | RETVAL |
1369 | |
1402 | |
1370 | int |
1403 | int |
1371 | nready() |
1404 | nready () |
1372 | PROTOTYPE: |
|
|
1373 | CODE: |
1405 | CODE: |
1374 | RETVAL = eio_nready (); |
1406 | RETVAL = eio_nready (); |
1375 | OUTPUT: |
1407 | OUTPUT: |
1376 | RETVAL |
1408 | RETVAL |
1377 | |
1409 | |
1378 | int |
1410 | int |
1379 | npending() |
1411 | npending () |
1380 | PROTOTYPE: |
|
|
1381 | CODE: |
1412 | CODE: |
1382 | RETVAL = eio_npending (); |
1413 | RETVAL = eio_npending (); |
1383 | OUTPUT: |
1414 | OUTPUT: |
1384 | RETVAL |
1415 | RETVAL |
1385 | |
1416 | |
1386 | int |
1417 | int |
1387 | nthreads() |
1418 | nthreads () |
1388 | PROTOTYPE: |
|
|
1389 | CODE: |
1419 | CODE: |
1390 | RETVAL = eio_nthreads (); |
1420 | RETVAL = eio_nthreads (); |
1391 | OUTPUT: |
1421 | OUTPUT: |
1392 | RETVAL |
1422 | RETVAL |
1393 | |
1423 | |
1394 | int |
1424 | int |
1395 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1425 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1396 | PROTOTYPE: $$$$ |
|
|
1397 | CODE: |
1426 | CODE: |
1398 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1427 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1399 | OUTPUT: |
1428 | OUTPUT: |
1400 | RETVAL |
1429 | RETVAL |
1401 | |
1430 | |
1402 | ssize_t |
1431 | ssize_t |
1403 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1432 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1404 | PROTOTYPE: $$$$ |
|
|
1405 | CODE: |
1433 | CODE: |
1406 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1434 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1407 | OUTPUT: |
1435 | OUTPUT: |
1408 | RETVAL |
1436 | RETVAL |
1409 | |
1437 | |
1410 | void |
1438 | void |
1411 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1439 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1412 | PROTOTYPE: $$$$$;$ |
|
|
1413 | PPCODE: |
1440 | PPCODE: |
1414 | sv_unmagic (scalar, MMAP_MAGIC); |
1441 | sv_unmagic (scalar, MMAP_MAGIC); |
1415 | { |
1442 | { |
1416 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1443 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1417 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1444 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1440 | XSRETURN_YES; |
1467 | XSRETURN_YES; |
1441 | } |
1468 | } |
1442 | |
1469 | |
1443 | void |
1470 | void |
1444 | munmap (SV *scalar) |
1471 | munmap (SV *scalar) |
1445 | PROTOTYPE: $ |
|
|
1446 | CODE: |
1472 | CODE: |
1447 | sv_unmagic (scalar, MMAP_MAGIC); |
1473 | sv_unmagic (scalar, MMAP_MAGIC); |
1448 | |
1474 | |
1449 | int |
1475 | int |
1450 | madvise (SV *scalar, off_t offset, off_t length, IV advice) |
1476 | madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1451 | PROTOTYPE: $$$$ |
1477 | ALIAS: |
|
|
1478 | mprotect = 1 |
1452 | CODE: |
1479 | CODE: |
1453 | { |
1480 | { |
1454 | char *addr = SvPV_nolen (scalar) + offset; |
1481 | STRLEN svlen; |
|
|
1482 | void *addr = SvPVbyte (scalar, svlen); |
|
|
1483 | size_t len = SvUV (length); |
1455 | |
1484 | |
1456 | if (!SvOK (ST (2))) |
1485 | if (offset < 0) |
|
|
1486 | offset += svlen; |
|
|
1487 | |
|
|
1488 | if (offset < 0 || offset > svlen) |
|
|
1489 | croak ("offset outside of scalar"); |
|
|
1490 | |
|
|
1491 | if (!SvOK (length) || len + offset > svlen) |
1457 | length = SvCUR (scalar) - offset; |
1492 | len = svlen - offset; |
1458 | |
1493 | |
1459 | if (addr >= SvEND (scalar) || length <= 0) |
1494 | addr = (void *)(((intptr_t)addr) + offset); |
1460 | XSRETURN_EMPTY; |
1495 | eio_page_align (&addr, &len); |
1461 | |
1496 | |
|
|
1497 | switch (ix) |
|
|
1498 | { |
1462 | RETVAL = posix_madvise (addr, length, advice); |
1499 | case 0: RETVAL = posix_madvise (addr, len, advice_or_prot); break; |
|
|
1500 | case 1: RETVAL = mprotect (addr, len, advice_or_prot); break; |
|
|
1501 | } |
1463 | } |
1502 | } |
1464 | OUTPUT: |
1503 | OUTPUT: |
1465 | RETVAL |
1504 | RETVAL |
1466 | |
1505 | |
1467 | int |
1506 | int |
1468 | mlockall (int flags) |
1507 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1469 | PROTOTYPE: $ |
|
|
1470 | CODE: |
1508 | CODE: |
|
|
1509 | { |
|
|
1510 | STRLEN svlen; |
|
|
1511 | void *addr = SvPVbyte (scalar, svlen); |
|
|
1512 | size_t len = SvUV (length); |
|
|
1513 | |
|
|
1514 | if (offset < 0) |
|
|
1515 | offset += svlen; |
|
|
1516 | |
|
|
1517 | if (offset < 0 || offset > svlen) |
|
|
1518 | croak ("offset outside of scalar"); |
|
|
1519 | |
|
|
1520 | if (!SvOK (length) || len + offset > svlen) |
|
|
1521 | len = svlen - offset; |
|
|
1522 | |
|
|
1523 | addr = (void *)(((intptr_t)addr) + offset); |
|
|
1524 | eio_page_align (&addr, &len); |
1471 | #if _POSIX_MEMLOCK |
1525 | #if _POSIX_MEMLOCK |
1472 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 |
1526 | RETVAL = munlock (addr, len); |
1473 | extern int mallopt (int, int); |
|
|
1474 | mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ |
|
|
1475 | #endif |
|
|
1476 | mlockall (flags); |
|
|
1477 | #else |
1527 | #else |
1478 | RETVAL = -1; |
1528 | RETVAL = ((errno = ENOSYS), -1); |
1479 | errno = ENOSYS; |
|
|
1480 | #endif |
1529 | #endif |
|
|
1530 | } |
1481 | OUTPUT: |
1531 | OUTPUT: |
1482 | RETVAL |
1532 | RETVAL |
1483 | |
1533 | |
1484 | int |
1534 | int |
1485 | munlockall () |
1535 | munlockall () |
1486 | PROTOTYPE: |
|
|
1487 | CODE: |
1536 | CODE: |
1488 | #if _POSIX_MEMLOCK |
1537 | #if _POSIX_MEMLOCK |
1489 | munlockall (); |
1538 | munlockall (); |
1490 | #else |
1539 | #else |
1491 | RETVAL = -1; |
1540 | RETVAL = -1; |