… | |
… | |
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 |
… | |
… | |
496 | SvSETMAGIC (req->sv2); |
525 | SvSETMAGIC (req->sv2); |
497 | PUSHs (sv_result); |
526 | PUSHs (sv_result); |
498 | } |
527 | } |
499 | break; |
528 | break; |
500 | |
529 | |
501 | case EIO_DUP2: |
530 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ |
502 | if (req->result > 0) |
531 | if (req->result > 0) |
503 | SvIV_set (sv_result, 0); |
532 | SvIV_set (sv_result, 0); |
504 | /* FALLTHROUGH */ |
533 | /* FALLTHROUGH */ |
505 | |
534 | |
506 | default: |
535 | default: |
… | |
… | |
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 |
… | |
… | |
620 | errno = old_errno; |
655 | errno = old_errno; |
621 | |
656 | |
622 | mg->mg_obj = 0; /* just in case */ |
657 | mg->mg_obj = 0; /* just in case */ |
623 | |
658 | |
624 | SvREADONLY_off (sv); |
659 | SvREADONLY_off (sv); |
|
|
660 | |
|
|
661 | if (SvPVX (sv) != mg->mg_ptr) |
|
|
662 | croak ("ERROR: IO::AIO::mmap-mapped scalar changed location, detected"); |
|
|
663 | |
625 | SvCUR_set (sv, 0); |
664 | SvCUR_set (sv, 0); |
626 | SvLEN_set (sv, 0); |
|
|
627 | SvPVX (sv) = 0; |
665 | SvPVX (sv) = 0; |
628 | SvOK_off (sv); |
666 | SvOK_off (sv); |
629 | |
667 | |
630 | return 0; |
668 | return 0; |
631 | } |
669 | } |
… | |
… | |
696 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
734 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
697 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
735 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
698 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
736 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
699 | const_niv (FADV_DONTNEED , POSIX_FADV_DONTNEED) |
737 | const_niv (FADV_DONTNEED , POSIX_FADV_DONTNEED) |
700 | |
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 | |
701 | const_iv (ST_RDONLY) |
745 | const_iv (ST_RDONLY) |
702 | const_iv (ST_NOSUID) |
746 | const_iv (ST_NOSUID) |
703 | const_iv (ST_NODEV) |
747 | const_iv (ST_NODEV) |
704 | const_iv (ST_NOEXEC) |
748 | const_iv (ST_NOEXEC) |
705 | const_iv (ST_SYNCHRONOUS) |
749 | const_iv (ST_SYNCHRONOUS) |
… | |
… | |
709 | const_iv (ST_IMMUTABLE) |
753 | const_iv (ST_IMMUTABLE) |
710 | const_iv (ST_NOATIME) |
754 | const_iv (ST_NOATIME) |
711 | const_iv (ST_NODIRATIME) |
755 | const_iv (ST_NODIRATIME) |
712 | const_iv (ST_RELATIME) |
756 | const_iv (ST_RELATIME) |
713 | |
757 | |
|
|
758 | const_iv (PROT_NONE) |
714 | const_iv (PROT_EXEC) |
759 | const_iv (PROT_EXEC) |
715 | const_iv (PROT_NONE) |
|
|
716 | const_iv (PROT_READ) |
760 | const_iv (PROT_READ) |
717 | const_iv (PROT_WRITE) |
761 | const_iv (PROT_WRITE) |
718 | |
762 | |
719 | /*const_iv (MAP_FIXED)*/ |
763 | /*const_iv (MAP_FIXED)*/ |
720 | const_iv (MAP_PRIVATE) |
764 | const_iv (MAP_PRIVATE) |
… | |
… | |
726 | const_iv (MAP_LOCKED) |
770 | const_iv (MAP_LOCKED) |
727 | const_iv (MAP_NORESERVE) |
771 | const_iv (MAP_NORESERVE) |
728 | const_iv (MAP_POPULATE) |
772 | const_iv (MAP_POPULATE) |
729 | const_iv (MAP_NONBLOCK) |
773 | const_iv (MAP_NONBLOCK) |
730 | |
774 | |
731 | const_iv (MCL_FUTURE) |
775 | const_eio (MCL_FUTURE) |
732 | const_iv (MCL_CURRENT) |
776 | const_eio (MCL_CURRENT) |
733 | |
777 | |
734 | const_eio (MS_ASYNC) |
778 | const_eio (MS_ASYNC) |
735 | const_eio (MS_INVALIDATE) |
779 | const_eio (MS_INVALIDATE) |
736 | const_eio (MS_SYNC) |
780 | const_eio (MS_SYNC) |
737 | |
781 | |
… | |
… | |
811 | CODE: |
855 | CODE: |
812 | max_outstanding = maxreqs; |
856 | max_outstanding = maxreqs; |
813 | |
857 | |
814 | void |
858 | void |
815 | 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) |
816 | PROTOTYPE: $$$;$ |
|
|
817 | PPCODE: |
860 | PPCODE: |
818 | { |
861 | { |
819 | dREQ; |
862 | dREQ; |
820 | |
863 | |
821 | req->type = EIO_OPEN; |
864 | req->type = EIO_OPEN; |
… | |
… | |
827 | REQ_SEND; |
870 | REQ_SEND; |
828 | } |
871 | } |
829 | |
872 | |
830 | void |
873 | void |
831 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
874 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
832 | PROTOTYPE: $;$ |
|
|
833 | ALIAS: |
875 | ALIAS: |
834 | aio_fsync = EIO_FSYNC |
876 | aio_fsync = EIO_FSYNC |
835 | aio_fdatasync = EIO_FDATASYNC |
877 | aio_fdatasync = EIO_FDATASYNC |
836 | PPCODE: |
878 | PPCODE: |
837 | { |
879 | { |
… | |
… | |
845 | REQ_SEND (req); |
887 | REQ_SEND (req); |
846 | } |
888 | } |
847 | |
889 | |
848 | void |
890 | void |
849 | 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) |
850 | PROTOTYPE: $$$$;$ |
|
|
851 | PPCODE: |
892 | PPCODE: |
852 | { |
893 | { |
853 | int fd = s_fileno_croak (fh, 0); |
894 | int fd = s_fileno_croak (fh, 0); |
854 | dREQ; |
895 | dREQ; |
855 | |
896 | |
… | |
… | |
863 | REQ_SEND (req); |
904 | REQ_SEND (req); |
864 | } |
905 | } |
865 | |
906 | |
866 | void |
907 | void |
867 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
908 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
868 | PROTOTYPE: $;$ |
|
|
869 | PPCODE: |
909 | PPCODE: |
870 | { |
910 | { |
871 | 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 */ |
872 | int fd = s_fileno_croak (fh, 0); |
912 | int fd = s_fileno_croak (fh, 0); |
873 | dREQ; |
913 | dREQ; |
… | |
… | |
895 | void |
935 | void |
896 | 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) |
897 | ALIAS: |
937 | ALIAS: |
898 | aio_read = EIO_READ |
938 | aio_read = EIO_READ |
899 | aio_write = EIO_WRITE |
939 | aio_write = EIO_WRITE |
900 | PROTOTYPE: $$$$$;$ |
|
|
901 | PPCODE: |
940 | PPCODE: |
902 | { |
941 | { |
903 | STRLEN svlen; |
942 | STRLEN svlen; |
904 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
943 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
905 | char *svptr = SvPVbyte (data, svlen); |
944 | char *svptr = SvPVbyte (data, svlen); |
… | |
… | |
946 | } |
985 | } |
947 | } |
986 | } |
948 | |
987 | |
949 | void |
988 | void |
950 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
989 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
951 | PROTOTYPE: $$;$ |
|
|
952 | PPCODE: |
990 | PPCODE: |
953 | { |
991 | { |
954 | SV *data; |
992 | SV *data; |
955 | dREQ; |
993 | dREQ; |
956 | |
994 | |
… | |
… | |
961 | REQ_SEND; |
999 | REQ_SEND; |
962 | } |
1000 | } |
963 | |
1001 | |
964 | void |
1002 | void |
965 | 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) |
966 | PROTOTYPE: $$$$;$ |
|
|
967 | PPCODE: |
1004 | PPCODE: |
968 | { |
1005 | { |
969 | int ifd = s_fileno_croak (in_fh , 0); |
1006 | int ifd = s_fileno_croak (in_fh , 0); |
970 | int ofd = s_fileno_croak (out_fh, 1); |
1007 | int ofd = s_fileno_croak (out_fh, 1); |
971 | dREQ; |
1008 | dREQ; |
… | |
… | |
981 | REQ_SEND; |
1018 | REQ_SEND; |
982 | } |
1019 | } |
983 | |
1020 | |
984 | void |
1021 | void |
985 | 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) |
986 | PROTOTYPE: $$$;$ |
|
|
987 | PPCODE: |
1023 | PPCODE: |
988 | { |
1024 | { |
989 | int fd = s_fileno_croak (fh, 0); |
1025 | int fd = s_fileno_croak (fh, 0); |
990 | dREQ; |
1026 | dREQ; |
991 | |
1027 | |
… | |
… | |
1192 | void |
1228 | void |
1193 | 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) |
1194 | ALIAS: |
1230 | ALIAS: |
1195 | aio_mtouch = EIO_MTOUCH |
1231 | aio_mtouch = EIO_MTOUCH |
1196 | aio_msync = EIO_MSYNC |
1232 | aio_msync = EIO_MSYNC |
1197 | PROTOTYPE: $$$$;$ |
|
|
1198 | PPCODE: |
1233 | PPCODE: |
1199 | { |
1234 | { |
1200 | STRLEN svlen; |
1235 | STRLEN svlen; |
|
|
1236 | char *svptr = SvPVbyte (data, svlen); |
1201 | UV len = SvUV (length); |
1237 | UV len = SvUV (length); |
1202 | char *svptr = SvPVbyte (data, svlen); |
|
|
1203 | |
1238 | |
1204 | if (offset < 0) |
1239 | if (offset < 0) |
1205 | offset += svlen; |
1240 | offset += svlen; |
1206 | |
1241 | |
1207 | if (offset < 0 || offset > svlen) |
1242 | if (offset < 0 || offset > svlen) |
… | |
… | |
1212 | |
1247 | |
1213 | { |
1248 | { |
1214 | dREQ; |
1249 | dREQ; |
1215 | |
1250 | |
1216 | req->type = ix; |
1251 | req->type = ix; |
1217 | req->size = len; |
|
|
1218 | req->sv2 = SvREFCNT_inc (data); |
1252 | req->sv2 = SvREFCNT_inc (data); |
1219 | req->ptr2 = (char *)svptr + offset; |
1253 | req->ptr2 = (char *)svptr + offset; |
|
|
1254 | req->size = len; |
1220 | req->int1 = flags; |
1255 | req->int1 = flags; |
1221 | |
1256 | |
1222 | REQ_SEND; |
1257 | REQ_SEND; |
1223 | } |
1258 | } |
1224 | } |
1259 | } |
1225 | |
1260 | |
1226 | 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 |
1227 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1303 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1228 | PPCODE: |
1304 | PPCODE: |
1229 | { |
1305 | { |
1230 | dREQ; |
1306 | dREQ; |
1231 | |
1307 | |
… | |
… | |
1235 | REQ_SEND; |
1311 | REQ_SEND; |
1236 | } |
1312 | } |
1237 | |
1313 | |
1238 | void |
1314 | void |
1239 | aio_group (SV *callback=&PL_sv_undef) |
1315 | aio_group (SV *callback=&PL_sv_undef) |
1240 | PROTOTYPE: ;$ |
|
|
1241 | PPCODE: |
1316 | PPCODE: |
1242 | { |
1317 | { |
1243 | dREQ; |
1318 | dREQ; |
1244 | |
1319 | |
1245 | req->type = EIO_GROUP; |
1320 | req->type = EIO_GROUP; |
… | |
… | |
1262 | REQ_SEND; |
1337 | REQ_SEND; |
1263 | } |
1338 | } |
1264 | |
1339 | |
1265 | int |
1340 | int |
1266 | aioreq_pri (int pri = 0) |
1341 | aioreq_pri (int pri = 0) |
1267 | PROTOTYPE: ;$ |
|
|
1268 | CODE: |
1342 | CODE: |
1269 | RETVAL = next_pri; |
1343 | RETVAL = next_pri; |
1270 | if (items > 0) |
1344 | if (items > 0) |
1271 | { |
1345 | { |
1272 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1346 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
… | |
… | |
1284 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1358 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1285 | next_pri = nice; |
1359 | next_pri = nice; |
1286 | |
1360 | |
1287 | void |
1361 | void |
1288 | flush () |
1362 | flush () |
1289 | PROTOTYPE: |
|
|
1290 | CODE: |
1363 | CODE: |
1291 | while (eio_nreqs ()) |
1364 | while (eio_nreqs ()) |
1292 | { |
1365 | { |
1293 | poll_wait (); |
1366 | poll_wait (); |
1294 | poll_cb (); |
1367 | poll_cb (); |
1295 | } |
1368 | } |
1296 | |
1369 | |
1297 | int |
1370 | int |
1298 | poll() |
1371 | poll () |
1299 | PROTOTYPE: |
|
|
1300 | CODE: |
1372 | CODE: |
1301 | poll_wait (); |
1373 | poll_wait (); |
1302 | RETVAL = poll_cb (); |
1374 | RETVAL = poll_cb (); |
1303 | OUTPUT: |
1375 | OUTPUT: |
1304 | RETVAL |
1376 | RETVAL |
1305 | |
1377 | |
1306 | int |
1378 | int |
1307 | poll_fileno() |
1379 | poll_fileno () |
1308 | PROTOTYPE: |
|
|
1309 | CODE: |
1380 | CODE: |
1310 | RETVAL = s_epipe_fd (&respipe); |
1381 | RETVAL = s_epipe_fd (&respipe); |
1311 | OUTPUT: |
1382 | OUTPUT: |
1312 | RETVAL |
1383 | RETVAL |
1313 | |
1384 | |
1314 | int |
1385 | int |
1315 | poll_cb(...) |
1386 | poll_cb (...) |
1316 | PROTOTYPE: |
1387 | PROTOTYPE: |
1317 | CODE: |
1388 | CODE: |
1318 | RETVAL = poll_cb (); |
1389 | RETVAL = poll_cb (); |
1319 | OUTPUT: |
1390 | OUTPUT: |
1320 | RETVAL |
1391 | RETVAL |
1321 | |
1392 | |
1322 | void |
1393 | void |
1323 | poll_wait() |
1394 | poll_wait () |
1324 | PROTOTYPE: |
|
|
1325 | CODE: |
1395 | CODE: |
1326 | poll_wait (); |
1396 | poll_wait (); |
1327 | |
1397 | |
1328 | int |
1398 | int |
1329 | nreqs() |
1399 | nreqs () |
1330 | PROTOTYPE: |
|
|
1331 | CODE: |
1400 | CODE: |
1332 | RETVAL = eio_nreqs (); |
1401 | RETVAL = eio_nreqs (); |
1333 | OUTPUT: |
1402 | OUTPUT: |
1334 | RETVAL |
1403 | RETVAL |
1335 | |
1404 | |
1336 | int |
1405 | int |
1337 | nready() |
1406 | nready () |
1338 | PROTOTYPE: |
|
|
1339 | CODE: |
1407 | CODE: |
1340 | RETVAL = eio_nready (); |
1408 | RETVAL = eio_nready (); |
1341 | OUTPUT: |
1409 | OUTPUT: |
1342 | RETVAL |
1410 | RETVAL |
1343 | |
1411 | |
1344 | int |
1412 | int |
1345 | npending() |
1413 | npending () |
1346 | PROTOTYPE: |
|
|
1347 | CODE: |
1414 | CODE: |
1348 | RETVAL = eio_npending (); |
1415 | RETVAL = eio_npending (); |
1349 | OUTPUT: |
1416 | OUTPUT: |
1350 | RETVAL |
1417 | RETVAL |
1351 | |
1418 | |
1352 | int |
1419 | int |
1353 | nthreads() |
1420 | nthreads () |
1354 | PROTOTYPE: |
|
|
1355 | CODE: |
1421 | CODE: |
1356 | RETVAL = eio_nthreads (); |
1422 | RETVAL = eio_nthreads (); |
1357 | OUTPUT: |
1423 | OUTPUT: |
1358 | RETVAL |
1424 | RETVAL |
1359 | |
1425 | |
1360 | int |
1426 | int |
1361 | 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) |
1362 | PROTOTYPE: $$$$ |
|
|
1363 | CODE: |
1428 | CODE: |
1364 | #if _XOPEN_SOURCE >= 600 && !NO_FADVISE |
|
|
1365 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1429 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1366 | #else |
|
|
1367 | RETVAL = errno = ENOSYS; /* yes, this is actually correct */ |
|
|
1368 | #endif |
|
|
1369 | OUTPUT: |
1430 | OUTPUT: |
1370 | RETVAL |
1431 | RETVAL |
1371 | |
1432 | |
1372 | ssize_t |
1433 | ssize_t |
1373 | 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) |
1374 | PROTOTYPE: $$$$ |
|
|
1375 | CODE: |
1435 | CODE: |
1376 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1436 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1377 | OUTPUT: |
1437 | OUTPUT: |
1378 | RETVAL |
1438 | RETVAL |
1379 | |
1439 | |
1380 | void |
1440 | void |
1381 | 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) |
1382 | PROTOTYPE: $$$$$;$ |
|
|
1383 | PPCODE: |
1442 | PPCODE: |
1384 | sv_unmagic (scalar, MMAP_MAGIC); |
1443 | sv_unmagic (scalar, MMAP_MAGIC); |
1385 | { |
1444 | { |
1386 | 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; |
1387 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1446 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1388 | if (addr == (void *)-1) |
1447 | if (addr == (void *)-1) |
1389 | XSRETURN_NO; |
1448 | XSRETURN_NO; |
1390 | |
1449 | |
|
|
1450 | sv_force_normal (scalar); |
|
|
1451 | |
1391 | /* we store the length in mg_obj, as namlen is I32 :/ */ |
1452 | /* we store the length in mg_obj, as namlen is I32 :/ */ |
1392 | sv_magicext (scalar, 0, MMAP_MAGIC, &mmap_vtbl, (char *)addr, 0) |
1453 | sv_magicext (scalar, 0, MMAP_MAGIC, &mmap_vtbl, (char *)addr, 0) |
1393 | ->mg_obj = (SV *)length; |
1454 | ->mg_obj = (SV *)length; |
1394 | |
1455 | |
1395 | SvUPGRADE (scalar, SVt_PV); /* nop... */ |
1456 | SvUPGRADE (scalar, SVt_PV); /* nop... */ |
|
|
1457 | |
1396 | if (!(prot & PROT_WRITE)) |
1458 | if (!(prot & PROT_WRITE)) |
1397 | SvREADONLY_on (scalar); |
1459 | SvREADONLY_on (scalar); |
|
|
1460 | |
|
|
1461 | if (SvLEN (scalar)) |
|
|
1462 | Safefree (SvPVX (scalar)); |
1398 | |
1463 | |
1399 | SvPVX (scalar) = (char *)addr; |
1464 | SvPVX (scalar) = (char *)addr; |
1400 | SvCUR_set (scalar, length); |
1465 | SvCUR_set (scalar, length); |
1401 | SvLEN_set (scalar, 0); |
1466 | SvLEN_set (scalar, 0); |
1402 | SvPOK_only (scalar); |
1467 | SvPOK_only (scalar); |
… | |
… | |
1404 | XSRETURN_YES; |
1469 | XSRETURN_YES; |
1405 | } |
1470 | } |
1406 | |
1471 | |
1407 | void |
1472 | void |
1408 | munmap (SV *scalar) |
1473 | munmap (SV *scalar) |
1409 | PROTOTYPE: $ |
|
|
1410 | CODE: |
1474 | CODE: |
1411 | sv_unmagic (scalar, MMAP_MAGIC); |
1475 | sv_unmagic (scalar, MMAP_MAGIC); |
1412 | |
1476 | |
1413 | int |
1477 | int |
1414 | mlockall (int flags) |
1478 | madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1415 | PROTOTYPE: $ |
1479 | ALIAS: |
|
|
1480 | mprotect = 1 |
1416 | 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); |
1417 | #if _POSIX_MEMLOCK |
1527 | #if _POSIX_MEMLOCK |
1418 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 |
1528 | RETVAL = munlock (addr, len); |
1419 | extern int mallopt (int, int); |
|
|
1420 | mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ |
|
|
1421 | #endif |
|
|
1422 | mlockall (flags); |
|
|
1423 | #else |
1529 | #else |
1424 | RETVAL = -1; |
1530 | RETVAL = ((errno = ENOSYS), -1); |
1425 | errno = ENOSYS; |
|
|
1426 | #endif |
1531 | #endif |
|
|
1532 | } |
1427 | OUTPUT: |
1533 | OUTPUT: |
1428 | RETVAL |
1534 | RETVAL |
1429 | |
1535 | |
1430 | int |
1536 | int |
1431 | munlockall () |
1537 | munlockall () |
1432 | PROTOTYPE: |
|
|
1433 | CODE: |
1538 | CODE: |
1434 | #if _POSIX_MEMLOCK |
1539 | #if _POSIX_MEMLOCK |
1435 | munlockall (); |
1540 | munlockall (); |
1436 | #else |
1541 | #else |
1437 | RETVAL = -1; |
1542 | RETVAL = -1; |