… | |
… | |
122 | |
122 | |
123 | #include "libeio/eio.h" |
123 | #include "libeio/eio.h" |
124 | |
124 | |
125 | #ifndef POSIX_FADV_NORMAL |
125 | #ifndef POSIX_FADV_NORMAL |
126 | # define POSIX_FADV_NORMAL 0 |
126 | # define POSIX_FADV_NORMAL 0 |
127 | # define NO_FADVISE 1 |
|
|
128 | #endif |
127 | #endif |
129 | #ifndef POSIX_FADV_SEQUENTIAL |
128 | #ifndef POSIX_FADV_SEQUENTIAL |
130 | # define POSIX_FADV_SEQUENTIAL 0 |
129 | # define POSIX_FADV_SEQUENTIAL 0 |
131 | #endif |
130 | #endif |
132 | #ifndef POSIX_FADV_RANDOM |
131 | #ifndef POSIX_FADV_RANDOM |
… | |
… | |
140 | #endif |
139 | #endif |
141 | #ifndef POSIX_FADV_DONTNEED |
140 | #ifndef POSIX_FADV_DONTNEED |
142 | # define POSIX_FADV_DONTNEED 0 |
141 | # define POSIX_FADV_DONTNEED 0 |
143 | #endif |
142 | #endif |
144 | |
143 | |
|
|
144 | #if !HAVE_POSIX_FADVISE |
|
|
145 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
|
|
146 | #endif |
|
|
147 | |
|
|
148 | #ifndef POSIX_MADV_NORMAL |
|
|
149 | # define POSIX_MADV_NORMAL 0 |
|
|
150 | #endif |
|
|
151 | #ifndef POSIX_MADV_SEQUENTIAL |
|
|
152 | # define POSIX_MADV_SEQUENTIAL 0 |
|
|
153 | #endif |
|
|
154 | #ifndef POSIX_MADV_RANDOM |
|
|
155 | # define POSIX_MADV_RANDOM 0 |
|
|
156 | #endif |
|
|
157 | #ifndef POSIX_MADV_WILLNEED |
|
|
158 | # define POSIX_MADV_WILLNEED 0 |
|
|
159 | #endif |
|
|
160 | #ifndef POSIX_MADV_DONTNEED |
|
|
161 | # define POSIX_MADV_DONTNEED 0 |
|
|
162 | #endif |
|
|
163 | |
|
|
164 | #if !HAVE_POSIX_MADVISE |
|
|
165 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
|
|
166 | #endif |
|
|
167 | |
|
|
168 | #ifndef PROT_NONE |
|
|
169 | # define PROT_NONE 0 |
|
|
170 | #endif |
|
|
171 | #ifndef PROT_READ |
|
|
172 | # define PROT_READ 0 |
|
|
173 | #endif |
|
|
174 | #ifndef PROT_WRITE |
|
|
175 | # define PROT_READ 0 |
|
|
176 | #endif |
|
|
177 | #ifndef PROT_EXEC |
|
|
178 | # define PROT_EXEC 0 |
|
|
179 | #endif |
|
|
180 | |
145 | #ifndef ST_NODEV |
181 | #ifndef ST_NODEV |
146 | # define ST_NODEV 0 |
182 | # define ST_NODEV 0 |
147 | #endif |
183 | #endif |
148 | #ifndef ST_NOEXEC |
184 | #ifndef ST_NOEXEC |
149 | # define ST_NOEXEC 0 |
185 | # define ST_NOEXEC 0 |
… | |
… | |
169 | #ifndef ST_NODIRATIME |
205 | #ifndef ST_NODIRATIME |
170 | # define ST_NODIRATIME 0 |
206 | # define ST_NODIRATIME 0 |
171 | #endif |
207 | #endif |
172 | #ifndef ST_RELATIME |
208 | #ifndef ST_RELATIME |
173 | # define ST_RELATIME 0 |
209 | # define ST_RELATIME 0 |
174 | #endif |
|
|
175 | |
|
|
176 | #ifndef MCL_CURRENT |
|
|
177 | # define MCL_CURRENT 0 |
|
|
178 | #endif |
|
|
179 | #ifndef MCL_FUTURE |
|
|
180 | # define MCL_FUTURE 0 |
|
|
181 | #endif |
210 | #endif |
182 | |
211 | |
183 | #ifndef MAP_ANONYMOUS |
212 | #ifndef MAP_ANONYMOUS |
184 | # ifdef MAP_ANON |
213 | # ifdef MAP_ANON |
185 | # define MAP_ANONYMOUS MAP_ANON |
214 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
606 | /*****************************************************************************/ |
635 | /*****************************************************************************/ |
607 | |
636 | |
608 | #if !_POSIX_MAPPED_FILES |
637 | #if !_POSIX_MAPPED_FILES |
609 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
638 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
610 | # define munmap(addr,length) (errno = ENOSYS, -1) |
639 | # define munmap(addr,length) (errno = ENOSYS, -1) |
|
|
640 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
|
|
641 | # define PROT_NONE 0 |
|
|
642 | # define PROT_WRITE 0 |
|
|
643 | # define MAP_PRIVATE 0 |
|
|
644 | # define MAP_SHARED 0 |
|
|
645 | # define MAP_FIXED 0 |
611 | #endif |
646 | #endif |
612 | |
647 | |
613 | #define MMAP_MAGIC PERL_MAGIC_ext |
648 | #define MMAP_MAGIC PERL_MAGIC_ext |
614 | |
649 | |
615 | static int |
650 | static int |
… | |
… | |
699 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
734 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
700 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
735 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
701 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
736 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
702 | const_niv (FADV_DONTNEED , POSIX_FADV_DONTNEED) |
737 | const_niv (FADV_DONTNEED , POSIX_FADV_DONTNEED) |
703 | |
738 | |
|
|
739 | const_niv (MADV_NORMAL , POSIX_MADV_NORMAL) |
|
|
740 | const_niv (MADV_SEQUENTIAL, POSIX_MADV_SEQUENTIAL) |
|
|
741 | const_niv (MADV_RANDOM , POSIX_MADV_RANDOM) |
|
|
742 | const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED) |
|
|
743 | const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED) |
|
|
744 | |
704 | const_iv (ST_RDONLY) |
745 | const_iv (ST_RDONLY) |
705 | const_iv (ST_NOSUID) |
746 | const_iv (ST_NOSUID) |
706 | const_iv (ST_NODEV) |
747 | const_iv (ST_NODEV) |
707 | const_iv (ST_NOEXEC) |
748 | const_iv (ST_NOEXEC) |
708 | const_iv (ST_SYNCHRONOUS) |
749 | const_iv (ST_SYNCHRONOUS) |
… | |
… | |
712 | const_iv (ST_IMMUTABLE) |
753 | const_iv (ST_IMMUTABLE) |
713 | const_iv (ST_NOATIME) |
754 | const_iv (ST_NOATIME) |
714 | const_iv (ST_NODIRATIME) |
755 | const_iv (ST_NODIRATIME) |
715 | const_iv (ST_RELATIME) |
756 | const_iv (ST_RELATIME) |
716 | |
757 | |
|
|
758 | const_iv (PROT_NONE) |
717 | const_iv (PROT_EXEC) |
759 | const_iv (PROT_EXEC) |
718 | const_iv (PROT_NONE) |
|
|
719 | const_iv (PROT_READ) |
760 | const_iv (PROT_READ) |
720 | const_iv (PROT_WRITE) |
761 | const_iv (PROT_WRITE) |
721 | |
762 | |
722 | /*const_iv (MAP_FIXED)*/ |
763 | /*const_iv (MAP_FIXED)*/ |
723 | const_iv (MAP_PRIVATE) |
764 | const_iv (MAP_PRIVATE) |
… | |
… | |
729 | const_iv (MAP_LOCKED) |
770 | const_iv (MAP_LOCKED) |
730 | const_iv (MAP_NORESERVE) |
771 | const_iv (MAP_NORESERVE) |
731 | const_iv (MAP_POPULATE) |
772 | const_iv (MAP_POPULATE) |
732 | const_iv (MAP_NONBLOCK) |
773 | const_iv (MAP_NONBLOCK) |
733 | |
774 | |
734 | const_iv (MCL_FUTURE) |
775 | const_eio (MCL_FUTURE) |
735 | const_iv (MCL_CURRENT) |
776 | const_eio (MCL_CURRENT) |
736 | |
777 | |
737 | const_eio (MS_ASYNC) |
778 | const_eio (MS_ASYNC) |
738 | const_eio (MS_INVALIDATE) |
779 | const_eio (MS_INVALIDATE) |
739 | const_eio (MS_SYNC) |
780 | const_eio (MS_SYNC) |
740 | |
781 | |
… | |
… | |
814 | CODE: |
855 | CODE: |
815 | max_outstanding = maxreqs; |
856 | max_outstanding = maxreqs; |
816 | |
857 | |
817 | void |
858 | void |
818 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
859 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
819 | PROTOTYPE: $$$;$ |
|
|
820 | PPCODE: |
860 | PPCODE: |
821 | { |
861 | { |
822 | dREQ; |
862 | dREQ; |
823 | |
863 | |
824 | req->type = EIO_OPEN; |
864 | req->type = EIO_OPEN; |
… | |
… | |
830 | REQ_SEND; |
870 | REQ_SEND; |
831 | } |
871 | } |
832 | |
872 | |
833 | void |
873 | void |
834 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
874 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
835 | PROTOTYPE: $;$ |
|
|
836 | ALIAS: |
875 | ALIAS: |
837 | aio_fsync = EIO_FSYNC |
876 | aio_fsync = EIO_FSYNC |
838 | aio_fdatasync = EIO_FDATASYNC |
877 | aio_fdatasync = EIO_FDATASYNC |
839 | PPCODE: |
878 | PPCODE: |
840 | { |
879 | { |
… | |
… | |
848 | REQ_SEND (req); |
887 | REQ_SEND (req); |
849 | } |
888 | } |
850 | |
889 | |
851 | void |
890 | void |
852 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
891 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
853 | PROTOTYPE: $$$$;$ |
|
|
854 | PPCODE: |
892 | PPCODE: |
855 | { |
893 | { |
856 | int fd = s_fileno_croak (fh, 0); |
894 | int fd = s_fileno_croak (fh, 0); |
857 | dREQ; |
895 | dREQ; |
858 | |
896 | |
… | |
… | |
866 | REQ_SEND (req); |
904 | REQ_SEND (req); |
867 | } |
905 | } |
868 | |
906 | |
869 | void |
907 | void |
870 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
908 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
871 | PROTOTYPE: $;$ |
|
|
872 | PPCODE: |
909 | PPCODE: |
873 | { |
910 | { |
874 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
911 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
875 | int fd = s_fileno_croak (fh, 0); |
912 | int fd = s_fileno_croak (fh, 0); |
876 | dREQ; |
913 | dREQ; |
… | |
… | |
898 | void |
935 | void |
899 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
936 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
900 | ALIAS: |
937 | ALIAS: |
901 | aio_read = EIO_READ |
938 | aio_read = EIO_READ |
902 | aio_write = EIO_WRITE |
939 | aio_write = EIO_WRITE |
903 | PROTOTYPE: $$$$$;$ |
|
|
904 | PPCODE: |
940 | PPCODE: |
905 | { |
941 | { |
906 | STRLEN svlen; |
942 | STRLEN svlen; |
907 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
943 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
908 | char *svptr = SvPVbyte (data, svlen); |
944 | char *svptr = SvPVbyte (data, svlen); |
… | |
… | |
949 | } |
985 | } |
950 | } |
986 | } |
951 | |
987 | |
952 | void |
988 | void |
953 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
989 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
954 | PROTOTYPE: $$;$ |
|
|
955 | PPCODE: |
990 | PPCODE: |
956 | { |
991 | { |
957 | SV *data; |
992 | SV *data; |
958 | dREQ; |
993 | dREQ; |
959 | |
994 | |
… | |
… | |
964 | REQ_SEND; |
999 | REQ_SEND; |
965 | } |
1000 | } |
966 | |
1001 | |
967 | void |
1002 | void |
968 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1003 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
969 | PROTOTYPE: $$$$;$ |
|
|
970 | PPCODE: |
1004 | PPCODE: |
971 | { |
1005 | { |
972 | int ifd = s_fileno_croak (in_fh , 0); |
1006 | int ifd = s_fileno_croak (in_fh , 0); |
973 | int ofd = s_fileno_croak (out_fh, 1); |
1007 | int ofd = s_fileno_croak (out_fh, 1); |
974 | dREQ; |
1008 | dREQ; |
… | |
… | |
984 | REQ_SEND; |
1018 | REQ_SEND; |
985 | } |
1019 | } |
986 | |
1020 | |
987 | void |
1021 | void |
988 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1022 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
989 | PROTOTYPE: $$$;$ |
|
|
990 | PPCODE: |
1023 | PPCODE: |
991 | { |
1024 | { |
992 | int fd = s_fileno_croak (fh, 0); |
1025 | int fd = s_fileno_croak (fh, 0); |
993 | dREQ; |
1026 | dREQ; |
994 | |
1027 | |
… | |
… | |
1195 | void |
1228 | void |
1196 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1229 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1197 | ALIAS: |
1230 | ALIAS: |
1198 | aio_mtouch = EIO_MTOUCH |
1231 | aio_mtouch = EIO_MTOUCH |
1199 | aio_msync = EIO_MSYNC |
1232 | aio_msync = EIO_MSYNC |
1200 | PROTOTYPE: $$$$;$ |
|
|
1201 | PPCODE: |
1233 | PPCODE: |
1202 | { |
1234 | { |
1203 | STRLEN svlen; |
1235 | STRLEN svlen; |
|
|
1236 | char *svptr = SvPVbyte (data, svlen); |
1204 | UV len = SvUV (length); |
1237 | UV len = SvUV (length); |
1205 | char *svptr = SvPVbyte (data, svlen); |
|
|
1206 | |
1238 | |
1207 | if (offset < 0) |
1239 | if (offset < 0) |
1208 | offset += svlen; |
1240 | offset += svlen; |
1209 | |
1241 | |
1210 | if (offset < 0 || offset > svlen) |
1242 | if (offset < 0 || offset > svlen) |
… | |
… | |
1215 | |
1247 | |
1216 | { |
1248 | { |
1217 | dREQ; |
1249 | dREQ; |
1218 | |
1250 | |
1219 | req->type = ix; |
1251 | req->type = ix; |
1220 | req->size = len; |
|
|
1221 | req->sv2 = SvREFCNT_inc (data); |
1252 | req->sv2 = SvREFCNT_inc (data); |
1222 | req->ptr2 = (char *)svptr + offset; |
1253 | req->ptr2 = (char *)svptr + offset; |
|
|
1254 | req->size = len; |
1223 | req->int1 = flags; |
1255 | req->int1 = flags; |
1224 | |
1256 | |
1225 | REQ_SEND; |
1257 | REQ_SEND; |
1226 | } |
1258 | } |
1227 | } |
1259 | } |
1228 | |
1260 | |
1229 | void |
1261 | void |
|
|
1262 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
|
|
1263 | PPCODE: |
|
|
1264 | { |
|
|
1265 | STRLEN svlen; |
|
|
1266 | char *svptr = SvPVbyte (data, svlen); |
|
|
1267 | UV len = SvUV (length); |
|
|
1268 | |
|
|
1269 | if (offset < 0) |
|
|
1270 | offset += svlen; |
|
|
1271 | |
|
|
1272 | if (offset < 0 || offset > svlen) |
|
|
1273 | croak ("offset outside of scalar"); |
|
|
1274 | |
|
|
1275 | if (!SvOK (length) || len + offset > svlen) |
|
|
1276 | len = svlen - offset; |
|
|
1277 | |
|
|
1278 | { |
|
|
1279 | dREQ; |
|
|
1280 | |
|
|
1281 | req->type = EIO_MLOCK; |
|
|
1282 | req->sv2 = SvREFCNT_inc (data); |
|
|
1283 | req->ptr2 = (char *)svptr + offset; |
|
|
1284 | req->size = len; |
|
|
1285 | |
|
|
1286 | REQ_SEND; |
|
|
1287 | } |
|
|
1288 | } |
|
|
1289 | |
|
|
1290 | void |
|
|
1291 | aio_mlockall (IV flags, SV *callback=&PL_sv_undef) |
|
|
1292 | PPCODE: |
|
|
1293 | { |
|
|
1294 | dREQ; |
|
|
1295 | |
|
|
1296 | req->type = EIO_MLOCKALL; |
|
|
1297 | req->int1 = flags; |
|
|
1298 | |
|
|
1299 | REQ_SEND; |
|
|
1300 | } |
|
|
1301 | |
|
|
1302 | void |
1230 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1303 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1231 | PPCODE: |
1304 | PPCODE: |
1232 | { |
1305 | { |
1233 | dREQ; |
1306 | dREQ; |
1234 | |
1307 | |
… | |
… | |
1238 | REQ_SEND; |
1311 | REQ_SEND; |
1239 | } |
1312 | } |
1240 | |
1313 | |
1241 | void |
1314 | void |
1242 | aio_group (SV *callback=&PL_sv_undef) |
1315 | aio_group (SV *callback=&PL_sv_undef) |
1243 | PROTOTYPE: ;$ |
|
|
1244 | PPCODE: |
1316 | PPCODE: |
1245 | { |
1317 | { |
1246 | dREQ; |
1318 | dREQ; |
1247 | |
1319 | |
1248 | req->type = EIO_GROUP; |
1320 | req->type = EIO_GROUP; |
… | |
… | |
1265 | REQ_SEND; |
1337 | REQ_SEND; |
1266 | } |
1338 | } |
1267 | |
1339 | |
1268 | int |
1340 | int |
1269 | aioreq_pri (int pri = 0) |
1341 | aioreq_pri (int pri = 0) |
1270 | PROTOTYPE: ;$ |
|
|
1271 | CODE: |
1342 | CODE: |
1272 | RETVAL = next_pri; |
1343 | RETVAL = next_pri; |
1273 | if (items > 0) |
1344 | if (items > 0) |
1274 | { |
1345 | { |
1275 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1346 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
… | |
… | |
1287 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1358 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1288 | next_pri = nice; |
1359 | next_pri = nice; |
1289 | |
1360 | |
1290 | void |
1361 | void |
1291 | flush () |
1362 | flush () |
1292 | PROTOTYPE: |
|
|
1293 | CODE: |
1363 | CODE: |
1294 | while (eio_nreqs ()) |
1364 | while (eio_nreqs ()) |
1295 | { |
1365 | { |
1296 | poll_wait (); |
1366 | poll_wait (); |
1297 | poll_cb (); |
1367 | poll_cb (); |
1298 | } |
1368 | } |
1299 | |
1369 | |
1300 | int |
1370 | int |
1301 | poll() |
1371 | poll () |
1302 | PROTOTYPE: |
|
|
1303 | CODE: |
1372 | CODE: |
1304 | poll_wait (); |
1373 | poll_wait (); |
1305 | RETVAL = poll_cb (); |
1374 | RETVAL = poll_cb (); |
1306 | OUTPUT: |
1375 | OUTPUT: |
1307 | RETVAL |
1376 | RETVAL |
1308 | |
1377 | |
1309 | int |
1378 | int |
1310 | poll_fileno() |
1379 | poll_fileno () |
1311 | PROTOTYPE: |
|
|
1312 | CODE: |
1380 | CODE: |
1313 | RETVAL = s_epipe_fd (&respipe); |
1381 | RETVAL = s_epipe_fd (&respipe); |
1314 | OUTPUT: |
1382 | OUTPUT: |
1315 | RETVAL |
1383 | RETVAL |
1316 | |
1384 | |
1317 | int |
1385 | int |
1318 | poll_cb(...) |
1386 | poll_cb (...) |
1319 | PROTOTYPE: |
1387 | PROTOTYPE: |
1320 | CODE: |
1388 | CODE: |
1321 | RETVAL = poll_cb (); |
1389 | RETVAL = poll_cb (); |
1322 | OUTPUT: |
1390 | OUTPUT: |
1323 | RETVAL |
1391 | RETVAL |
1324 | |
1392 | |
1325 | void |
1393 | void |
1326 | poll_wait() |
1394 | poll_wait () |
1327 | PROTOTYPE: |
|
|
1328 | CODE: |
1395 | CODE: |
1329 | poll_wait (); |
1396 | poll_wait (); |
1330 | |
1397 | |
1331 | int |
1398 | int |
1332 | nreqs() |
1399 | nreqs () |
1333 | PROTOTYPE: |
|
|
1334 | CODE: |
1400 | CODE: |
1335 | RETVAL = eio_nreqs (); |
1401 | RETVAL = eio_nreqs (); |
1336 | OUTPUT: |
1402 | OUTPUT: |
1337 | RETVAL |
1403 | RETVAL |
1338 | |
1404 | |
1339 | int |
1405 | int |
1340 | nready() |
1406 | nready () |
1341 | PROTOTYPE: |
|
|
1342 | CODE: |
1407 | CODE: |
1343 | RETVAL = eio_nready (); |
1408 | RETVAL = eio_nready (); |
1344 | OUTPUT: |
1409 | OUTPUT: |
1345 | RETVAL |
1410 | RETVAL |
1346 | |
1411 | |
1347 | int |
1412 | int |
1348 | npending() |
1413 | npending () |
1349 | PROTOTYPE: |
|
|
1350 | CODE: |
1414 | CODE: |
1351 | RETVAL = eio_npending (); |
1415 | RETVAL = eio_npending (); |
1352 | OUTPUT: |
1416 | OUTPUT: |
1353 | RETVAL |
1417 | RETVAL |
1354 | |
1418 | |
1355 | int |
1419 | int |
1356 | nthreads() |
1420 | nthreads () |
1357 | PROTOTYPE: |
|
|
1358 | CODE: |
1421 | CODE: |
1359 | RETVAL = eio_nthreads (); |
1422 | RETVAL = eio_nthreads (); |
1360 | OUTPUT: |
1423 | OUTPUT: |
1361 | RETVAL |
1424 | RETVAL |
1362 | |
1425 | |
1363 | int |
1426 | int |
1364 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1427 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1365 | PROTOTYPE: $$$$ |
|
|
1366 | CODE: |
1428 | CODE: |
1367 | #if _XOPEN_SOURCE >= 600 && !NO_FADVISE |
|
|
1368 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1429 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1369 | #else |
|
|
1370 | RETVAL = errno = ENOSYS; /* yes, this is actually correct */ |
|
|
1371 | #endif |
|
|
1372 | OUTPUT: |
1430 | OUTPUT: |
1373 | RETVAL |
1431 | RETVAL |
1374 | |
1432 | |
1375 | ssize_t |
1433 | ssize_t |
1376 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1434 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1377 | PROTOTYPE: $$$$ |
|
|
1378 | CODE: |
1435 | CODE: |
1379 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1436 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1380 | OUTPUT: |
1437 | OUTPUT: |
1381 | RETVAL |
1438 | RETVAL |
1382 | |
1439 | |
1383 | void |
1440 | void |
1384 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1441 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1385 | PROTOTYPE: $$$$$;$ |
|
|
1386 | PPCODE: |
1442 | PPCODE: |
1387 | sv_unmagic (scalar, MMAP_MAGIC); |
1443 | sv_unmagic (scalar, MMAP_MAGIC); |
1388 | { |
1444 | { |
1389 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1445 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1390 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1446 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1413 | XSRETURN_YES; |
1469 | XSRETURN_YES; |
1414 | } |
1470 | } |
1415 | |
1471 | |
1416 | void |
1472 | void |
1417 | munmap (SV *scalar) |
1473 | munmap (SV *scalar) |
1418 | PROTOTYPE: $ |
|
|
1419 | CODE: |
1474 | CODE: |
1420 | sv_unmagic (scalar, MMAP_MAGIC); |
1475 | sv_unmagic (scalar, MMAP_MAGIC); |
1421 | |
1476 | |
1422 | int |
1477 | int |
1423 | mlockall (int flags) |
1478 | madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1424 | PROTOTYPE: $ |
1479 | ALIAS: |
|
|
1480 | mprotect = 1 |
1425 | CODE: |
1481 | CODE: |
|
|
1482 | { |
|
|
1483 | STRLEN svlen; |
|
|
1484 | void *addr = SvPVbyte (scalar, svlen); |
|
|
1485 | size_t len = SvUV (length); |
|
|
1486 | |
|
|
1487 | if (offset < 0) |
|
|
1488 | offset += svlen; |
|
|
1489 | |
|
|
1490 | if (offset < 0 || offset > svlen) |
|
|
1491 | croak ("offset outside of scalar"); |
|
|
1492 | |
|
|
1493 | if (!SvOK (length) || len + offset > svlen) |
|
|
1494 | len = svlen - offset; |
|
|
1495 | |
|
|
1496 | addr = (void *)(((intptr_t)addr) + offset); |
|
|
1497 | eio_page_align (&addr, &len); |
|
|
1498 | |
|
|
1499 | switch (ix) |
|
|
1500 | { |
|
|
1501 | case 0: RETVAL = posix_madvise (addr, len, advice_or_prot); break; |
|
|
1502 | case 1: RETVAL = mprotect (addr, len, advice_or_prot); break; |
|
|
1503 | } |
|
|
1504 | } |
|
|
1505 | OUTPUT: |
|
|
1506 | RETVAL |
|
|
1507 | |
|
|
1508 | int |
|
|
1509 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
|
|
1510 | CODE: |
|
|
1511 | { |
|
|
1512 | STRLEN svlen; |
|
|
1513 | void *addr = SvPVbyte (scalar, svlen); |
|
|
1514 | size_t len = SvUV (length); |
|
|
1515 | |
|
|
1516 | if (offset < 0) |
|
|
1517 | offset += svlen; |
|
|
1518 | |
|
|
1519 | if (offset < 0 || offset > svlen) |
|
|
1520 | croak ("offset outside of scalar"); |
|
|
1521 | |
|
|
1522 | if (!SvOK (length) || len + offset > svlen) |
|
|
1523 | len = svlen - offset; |
|
|
1524 | |
|
|
1525 | addr = (void *)(((intptr_t)addr) + offset); |
|
|
1526 | eio_page_align (&addr, &len); |
1426 | #if _POSIX_MEMLOCK |
1527 | #if _POSIX_MEMLOCK |
1427 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 |
1528 | RETVAL = munlock (addr, len); |
1428 | extern int mallopt (int, int); |
|
|
1429 | mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ |
|
|
1430 | #endif |
|
|
1431 | mlockall (flags); |
|
|
1432 | #else |
1529 | #else |
1433 | RETVAL = -1; |
1530 | RETVAL = ((errno = ENOSYS), -1); |
1434 | errno = ENOSYS; |
|
|
1435 | #endif |
1531 | #endif |
|
|
1532 | } |
1436 | OUTPUT: |
1533 | OUTPUT: |
1437 | RETVAL |
1534 | RETVAL |
1438 | |
1535 | |
1439 | int |
1536 | int |
1440 | munlockall () |
1537 | munlockall () |
1441 | PROTOTYPE: |
|
|
1442 | CODE: |
1538 | CODE: |
1443 | #if _POSIX_MEMLOCK |
1539 | #if _POSIX_MEMLOCK |
1444 | munlockall (); |
1540 | munlockall (); |
1445 | #else |
1541 | #else |
1446 | RETVAL = -1; |
1542 | RETVAL = -1; |