… | |
… | |
16 | #include <sys/statvfs.h> |
16 | #include <sys/statvfs.h> |
17 | #include <limits.h> |
17 | #include <limits.h> |
18 | #include <fcntl.h> |
18 | #include <fcntl.h> |
19 | #include <sched.h> |
19 | #include <sched.h> |
20 | |
20 | |
21 | #if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES |
21 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
22 | # include <sys/mman.h> |
22 | # include <sys/mman.h> |
23 | #endif |
23 | #endif |
24 | |
24 | |
25 | /* perl namespace pollution */ |
25 | /* perl namespace pollution */ |
26 | #undef VERSION |
26 | #undef VERSION |
… | |
… | |
118 | STRLEN stroffset; \ |
118 | STRLEN stroffset; \ |
119 | SV *self; |
119 | SV *self; |
120 | |
120 | |
121 | #define EIO_NO_WRAPPERS 1 |
121 | #define EIO_NO_WRAPPERS 1 |
122 | |
122 | |
|
|
123 | #include "libeio/config.h" |
123 | #include "libeio/eio.h" |
124 | #include "libeio/eio.h" |
124 | |
125 | |
125 | #ifndef POSIX_FADV_NORMAL |
126 | #ifndef POSIX_FADV_NORMAL |
126 | # define POSIX_FADV_NORMAL 0 |
127 | # define POSIX_FADV_NORMAL 0 |
127 | # define NO_FADVISE 1 |
|
|
128 | #endif |
128 | #endif |
129 | #ifndef POSIX_FADV_SEQUENTIAL |
129 | #ifndef POSIX_FADV_SEQUENTIAL |
130 | # define POSIX_FADV_SEQUENTIAL 0 |
130 | # define POSIX_FADV_SEQUENTIAL 0 |
131 | #endif |
131 | #endif |
132 | #ifndef POSIX_FADV_RANDOM |
132 | #ifndef POSIX_FADV_RANDOM |
… | |
… | |
140 | #endif |
140 | #endif |
141 | #ifndef POSIX_FADV_DONTNEED |
141 | #ifndef POSIX_FADV_DONTNEED |
142 | # define POSIX_FADV_DONTNEED 0 |
142 | # define POSIX_FADV_DONTNEED 0 |
143 | #endif |
143 | #endif |
144 | |
144 | |
145 | #if _XOPEN_SOURCE < 600 || NO_FADVISE |
145 | #if !HAVE_POSIX_FADVISE |
146 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
146 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
147 | #endif |
147 | #endif |
148 | |
148 | |
149 | #ifndef POSIX_MADV_NORMAL |
149 | #ifndef POSIX_MADV_NORMAL |
150 | # define POSIX_MADV_NORMAL 0 |
150 | # define POSIX_MADV_NORMAL 0 |
151 | # define NO_MADVISE 1 |
|
|
152 | #endif |
151 | #endif |
153 | #ifndef POSIX_MADV_SEQUENTIAL |
152 | #ifndef POSIX_MADV_SEQUENTIAL |
154 | # define POSIX_MADV_SEQUENTIAL 0 |
153 | # define POSIX_MADV_SEQUENTIAL 0 |
155 | #endif |
154 | #endif |
156 | #ifndef POSIX_MADV_RANDOM |
155 | #ifndef POSIX_MADV_RANDOM |
… | |
… | |
161 | #endif |
160 | #endif |
162 | #ifndef POSIX_MADV_DONTNEED |
161 | #ifndef POSIX_MADV_DONTNEED |
163 | # define POSIX_MADV_DONTNEED 0 |
162 | # define POSIX_MADV_DONTNEED 0 |
164 | #endif |
163 | #endif |
165 | |
164 | |
166 | #if _XOPEN_SOURCE < 600 || NO_MADVISE |
165 | #if !HAVE_POSIX_MADVISE |
167 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
166 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
|
|
167 | #endif |
|
|
168 | |
|
|
169 | #ifndef PROT_NONE |
|
|
170 | # define PROT_NONE 0 |
|
|
171 | #endif |
|
|
172 | #ifndef PROT_READ |
|
|
173 | # define PROT_READ 0 |
|
|
174 | #endif |
|
|
175 | #ifndef PROT_WRITE |
|
|
176 | # define PROT_READ 0 |
|
|
177 | #endif |
|
|
178 | #ifndef PROT_EXEC |
|
|
179 | # define PROT_EXEC 0 |
168 | #endif |
180 | #endif |
169 | |
181 | |
170 | #ifndef ST_NODEV |
182 | #ifndef ST_NODEV |
171 | # define ST_NODEV 0 |
183 | # define ST_NODEV 0 |
172 | #endif |
184 | #endif |
… | |
… | |
194 | #ifndef ST_NODIRATIME |
206 | #ifndef ST_NODIRATIME |
195 | # define ST_NODIRATIME 0 |
207 | # define ST_NODIRATIME 0 |
196 | #endif |
208 | #endif |
197 | #ifndef ST_RELATIME |
209 | #ifndef ST_RELATIME |
198 | # define ST_RELATIME 0 |
210 | # 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 |
211 | #endif |
207 | |
212 | |
208 | #ifndef MAP_ANONYMOUS |
213 | #ifndef MAP_ANONYMOUS |
209 | # ifdef MAP_ANON |
214 | # ifdef MAP_ANON |
210 | # define MAP_ANONYMOUS MAP_ANON |
215 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
348 | /* do not recreate the result IV from scratch each time */ |
353 | /* do not recreate the result IV from scratch each time */ |
349 | if (expect_true (sv_result_cache)) |
354 | if (expect_true (sv_result_cache)) |
350 | { |
355 | { |
351 | sv_result = sv_result_cache; sv_result_cache = 0; |
356 | sv_result = sv_result_cache; sv_result_cache = 0; |
352 | SvIV_set (sv_result, req->result); |
357 | SvIV_set (sv_result, req->result); |
|
|
358 | SvIOK_only (sv_result); |
353 | } |
359 | } |
354 | else |
360 | else |
355 | { |
361 | { |
356 | sv_result = newSViv (req->result); |
362 | sv_result = newSViv (req->result); |
357 | SvREADONLY_on (sv_result); |
363 | SvREADONLY_on (sv_result); |
… | |
… | |
521 | SvSETMAGIC (req->sv2); |
527 | SvSETMAGIC (req->sv2); |
522 | PUSHs (sv_result); |
528 | PUSHs (sv_result); |
523 | } |
529 | } |
524 | break; |
530 | break; |
525 | |
531 | |
526 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ |
532 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ |
527 | if (req->result > 0) |
533 | if (req->result > 0) |
528 | SvIV_set (sv_result, 0); |
534 | SvIV_set (sv_result, 0); |
529 | /* FALLTHROUGH */ |
535 | /* FALLTHROUGH */ |
530 | |
536 | |
531 | default: |
537 | default: |
… | |
… | |
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 | #endif |
|
|
643 | |
|
|
644 | #if !_POSIX_MEMORY_PROTECTION |
|
|
645 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
|
|
646 | # define PROT_NONE 0 |
|
|
647 | # define PROT_WRITE 0 |
|
|
648 | # define MAP_PRIVATE 0 |
|
|
649 | # define MAP_SHARED 0 |
|
|
650 | # define MAP_FIXED 0 |
636 | #endif |
651 | #endif |
637 | |
652 | |
638 | #define MMAP_MAGIC PERL_MAGIC_ext |
653 | #define MMAP_MAGIC PERL_MAGIC_ext |
639 | |
654 | |
640 | static int |
655 | static int |
… | |
… | |
743 | const_iv (ST_IMMUTABLE) |
758 | const_iv (ST_IMMUTABLE) |
744 | const_iv (ST_NOATIME) |
759 | const_iv (ST_NOATIME) |
745 | const_iv (ST_NODIRATIME) |
760 | const_iv (ST_NODIRATIME) |
746 | const_iv (ST_RELATIME) |
761 | const_iv (ST_RELATIME) |
747 | |
762 | |
|
|
763 | const_iv (PROT_NONE) |
748 | const_iv (PROT_EXEC) |
764 | const_iv (PROT_EXEC) |
749 | const_iv (PROT_NONE) |
|
|
750 | const_iv (PROT_READ) |
765 | const_iv (PROT_READ) |
751 | const_iv (PROT_WRITE) |
766 | const_iv (PROT_WRITE) |
752 | |
767 | |
753 | /*const_iv (MAP_FIXED)*/ |
768 | /*const_iv (MAP_FIXED)*/ |
754 | const_iv (MAP_PRIVATE) |
769 | const_iv (MAP_PRIVATE) |
… | |
… | |
760 | const_iv (MAP_LOCKED) |
775 | const_iv (MAP_LOCKED) |
761 | const_iv (MAP_NORESERVE) |
776 | const_iv (MAP_NORESERVE) |
762 | const_iv (MAP_POPULATE) |
777 | const_iv (MAP_POPULATE) |
763 | const_iv (MAP_NONBLOCK) |
778 | const_iv (MAP_NONBLOCK) |
764 | |
779 | |
765 | const_iv (MCL_FUTURE) |
780 | const_eio (MCL_FUTURE) |
766 | const_iv (MCL_CURRENT) |
781 | const_eio (MCL_CURRENT) |
767 | |
782 | |
768 | const_eio (MS_ASYNC) |
783 | const_eio (MS_ASYNC) |
769 | const_eio (MS_INVALIDATE) |
784 | const_eio (MS_INVALIDATE) |
770 | const_eio (MS_SYNC) |
785 | const_eio (MS_SYNC) |
771 | |
786 | |
… | |
… | |
845 | CODE: |
860 | CODE: |
846 | max_outstanding = maxreqs; |
861 | max_outstanding = maxreqs; |
847 | |
862 | |
848 | void |
863 | void |
849 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
864 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
850 | PROTOTYPE: $$$;$ |
|
|
851 | PPCODE: |
865 | PPCODE: |
852 | { |
866 | { |
853 | dREQ; |
867 | dREQ; |
854 | |
868 | |
855 | req->type = EIO_OPEN; |
869 | req->type = EIO_OPEN; |
… | |
… | |
861 | REQ_SEND; |
875 | REQ_SEND; |
862 | } |
876 | } |
863 | |
877 | |
864 | void |
878 | void |
865 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
879 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
866 | PROTOTYPE: $;$ |
|
|
867 | ALIAS: |
880 | ALIAS: |
868 | aio_fsync = EIO_FSYNC |
881 | aio_fsync = EIO_FSYNC |
869 | aio_fdatasync = EIO_FDATASYNC |
882 | aio_fdatasync = EIO_FDATASYNC |
870 | PPCODE: |
883 | PPCODE: |
871 | { |
884 | { |
… | |
… | |
879 | REQ_SEND (req); |
892 | REQ_SEND (req); |
880 | } |
893 | } |
881 | |
894 | |
882 | void |
895 | void |
883 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
896 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
884 | PROTOTYPE: $$$$;$ |
|
|
885 | PPCODE: |
897 | PPCODE: |
886 | { |
898 | { |
887 | int fd = s_fileno_croak (fh, 0); |
899 | int fd = s_fileno_croak (fh, 0); |
888 | dREQ; |
900 | dREQ; |
889 | |
901 | |
… | |
… | |
897 | REQ_SEND (req); |
909 | REQ_SEND (req); |
898 | } |
910 | } |
899 | |
911 | |
900 | void |
912 | void |
901 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
913 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
902 | PROTOTYPE: $;$ |
|
|
903 | PPCODE: |
914 | PPCODE: |
904 | { |
915 | { |
905 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
916 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
906 | int fd = s_fileno_croak (fh, 0); |
917 | int fd = s_fileno_croak (fh, 0); |
907 | dREQ; |
918 | dREQ; |
… | |
… | |
929 | void |
940 | void |
930 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
941 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
931 | ALIAS: |
942 | ALIAS: |
932 | aio_read = EIO_READ |
943 | aio_read = EIO_READ |
933 | aio_write = EIO_WRITE |
944 | aio_write = EIO_WRITE |
934 | PROTOTYPE: $$$$$;$ |
|
|
935 | PPCODE: |
945 | PPCODE: |
936 | { |
946 | { |
937 | STRLEN svlen; |
947 | STRLEN svlen; |
938 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
948 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
939 | char *svptr = SvPVbyte (data, svlen); |
949 | char *svptr = SvPVbyte (data, svlen); |
… | |
… | |
980 | } |
990 | } |
981 | } |
991 | } |
982 | |
992 | |
983 | void |
993 | void |
984 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
994 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
985 | PROTOTYPE: $$;$ |
|
|
986 | PPCODE: |
995 | PPCODE: |
987 | { |
996 | { |
988 | SV *data; |
997 | SV *data; |
989 | dREQ; |
998 | dREQ; |
990 | |
999 | |
… | |
… | |
995 | REQ_SEND; |
1004 | REQ_SEND; |
996 | } |
1005 | } |
997 | |
1006 | |
998 | void |
1007 | void |
999 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1008 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
1000 | PROTOTYPE: $$$$;$ |
|
|
1001 | PPCODE: |
1009 | PPCODE: |
1002 | { |
1010 | { |
1003 | int ifd = s_fileno_croak (in_fh , 0); |
1011 | int ifd = s_fileno_croak (in_fh , 0); |
1004 | int ofd = s_fileno_croak (out_fh, 1); |
1012 | int ofd = s_fileno_croak (out_fh, 1); |
1005 | dREQ; |
1013 | dREQ; |
… | |
… | |
1015 | REQ_SEND; |
1023 | REQ_SEND; |
1016 | } |
1024 | } |
1017 | |
1025 | |
1018 | void |
1026 | void |
1019 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1027 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
1020 | PROTOTYPE: $$$;$ |
|
|
1021 | PPCODE: |
1028 | PPCODE: |
1022 | { |
1029 | { |
1023 | int fd = s_fileno_croak (fh, 0); |
1030 | int fd = s_fileno_croak (fh, 0); |
1024 | dREQ; |
1031 | dREQ; |
1025 | |
1032 | |
… | |
… | |
1226 | void |
1233 | void |
1227 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1234 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
1228 | ALIAS: |
1235 | ALIAS: |
1229 | aio_mtouch = EIO_MTOUCH |
1236 | aio_mtouch = EIO_MTOUCH |
1230 | aio_msync = EIO_MSYNC |
1237 | aio_msync = EIO_MSYNC |
1231 | PROTOTYPE: $$$$;$ |
|
|
1232 | PPCODE: |
1238 | PPCODE: |
1233 | { |
1239 | { |
1234 | STRLEN svlen; |
1240 | STRLEN svlen; |
|
|
1241 | char *svptr = SvPVbyte (data, svlen); |
1235 | UV len = SvUV (length); |
1242 | UV len = SvUV (length); |
1236 | char *svptr = SvPVbyte (data, svlen); |
|
|
1237 | |
1243 | |
1238 | if (offset < 0) |
1244 | if (offset < 0) |
1239 | offset += svlen; |
1245 | offset += svlen; |
1240 | |
1246 | |
1241 | if (offset < 0 || offset > svlen) |
1247 | if (offset < 0 || offset > svlen) |
… | |
… | |
1246 | |
1252 | |
1247 | { |
1253 | { |
1248 | dREQ; |
1254 | dREQ; |
1249 | |
1255 | |
1250 | req->type = ix; |
1256 | req->type = ix; |
1251 | req->size = len; |
|
|
1252 | req->sv2 = SvREFCNT_inc (data); |
1257 | req->sv2 = SvREFCNT_inc (data); |
1253 | req->ptr2 = (char *)svptr + offset; |
1258 | req->ptr2 = (char *)svptr + offset; |
|
|
1259 | req->size = len; |
1254 | req->int1 = flags; |
1260 | req->int1 = flags; |
1255 | |
1261 | |
1256 | REQ_SEND; |
1262 | REQ_SEND; |
1257 | } |
1263 | } |
1258 | } |
1264 | } |
1259 | |
1265 | |
1260 | void |
1266 | void |
|
|
1267 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
|
|
1268 | PPCODE: |
|
|
1269 | { |
|
|
1270 | STRLEN svlen; |
|
|
1271 | char *svptr = SvPVbyte (data, svlen); |
|
|
1272 | UV len = SvUV (length); |
|
|
1273 | |
|
|
1274 | if (offset < 0) |
|
|
1275 | offset += svlen; |
|
|
1276 | |
|
|
1277 | if (offset < 0 || offset > svlen) |
|
|
1278 | croak ("offset outside of scalar"); |
|
|
1279 | |
|
|
1280 | if (!SvOK (length) || len + offset > svlen) |
|
|
1281 | len = svlen - offset; |
|
|
1282 | |
|
|
1283 | { |
|
|
1284 | dREQ; |
|
|
1285 | |
|
|
1286 | req->type = EIO_MLOCK; |
|
|
1287 | req->sv2 = SvREFCNT_inc (data); |
|
|
1288 | req->ptr2 = (char *)svptr + offset; |
|
|
1289 | req->size = len; |
|
|
1290 | |
|
|
1291 | REQ_SEND; |
|
|
1292 | } |
|
|
1293 | } |
|
|
1294 | |
|
|
1295 | void |
|
|
1296 | aio_mlockall (IV flags, SV *callback=&PL_sv_undef) |
|
|
1297 | PPCODE: |
|
|
1298 | { |
|
|
1299 | dREQ; |
|
|
1300 | |
|
|
1301 | req->type = EIO_MLOCKALL; |
|
|
1302 | req->int1 = flags; |
|
|
1303 | |
|
|
1304 | REQ_SEND; |
|
|
1305 | } |
|
|
1306 | |
|
|
1307 | void |
1261 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1308 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1262 | PPCODE: |
1309 | PPCODE: |
1263 | { |
1310 | { |
1264 | dREQ; |
1311 | dREQ; |
1265 | |
1312 | |
… | |
… | |
1269 | REQ_SEND; |
1316 | REQ_SEND; |
1270 | } |
1317 | } |
1271 | |
1318 | |
1272 | void |
1319 | void |
1273 | aio_group (SV *callback=&PL_sv_undef) |
1320 | aio_group (SV *callback=&PL_sv_undef) |
1274 | PROTOTYPE: ;$ |
|
|
1275 | PPCODE: |
1321 | PPCODE: |
1276 | { |
1322 | { |
1277 | dREQ; |
1323 | dREQ; |
1278 | |
1324 | |
1279 | req->type = EIO_GROUP; |
1325 | req->type = EIO_GROUP; |
… | |
… | |
1296 | REQ_SEND; |
1342 | REQ_SEND; |
1297 | } |
1343 | } |
1298 | |
1344 | |
1299 | int |
1345 | int |
1300 | aioreq_pri (int pri = 0) |
1346 | aioreq_pri (int pri = 0) |
1301 | PROTOTYPE: ;$ |
|
|
1302 | CODE: |
1347 | CODE: |
1303 | RETVAL = next_pri; |
1348 | RETVAL = next_pri; |
1304 | if (items > 0) |
1349 | if (items > 0) |
1305 | { |
1350 | { |
1306 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1351 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
… | |
… | |
1318 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1363 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1319 | next_pri = nice; |
1364 | next_pri = nice; |
1320 | |
1365 | |
1321 | void |
1366 | void |
1322 | flush () |
1367 | flush () |
1323 | PROTOTYPE: |
|
|
1324 | CODE: |
1368 | CODE: |
1325 | while (eio_nreqs ()) |
1369 | while (eio_nreqs ()) |
1326 | { |
1370 | { |
1327 | poll_wait (); |
1371 | poll_wait (); |
1328 | poll_cb (); |
1372 | poll_cb (); |
1329 | } |
1373 | } |
1330 | |
1374 | |
1331 | int |
1375 | int |
1332 | poll() |
1376 | poll () |
1333 | PROTOTYPE: |
|
|
1334 | CODE: |
1377 | CODE: |
1335 | poll_wait (); |
1378 | poll_wait (); |
1336 | RETVAL = poll_cb (); |
1379 | RETVAL = poll_cb (); |
1337 | OUTPUT: |
1380 | OUTPUT: |
1338 | RETVAL |
1381 | RETVAL |
1339 | |
1382 | |
1340 | int |
1383 | int |
1341 | poll_fileno() |
1384 | poll_fileno () |
1342 | PROTOTYPE: |
|
|
1343 | CODE: |
1385 | CODE: |
1344 | RETVAL = s_epipe_fd (&respipe); |
1386 | RETVAL = s_epipe_fd (&respipe); |
1345 | OUTPUT: |
1387 | OUTPUT: |
1346 | RETVAL |
1388 | RETVAL |
1347 | |
1389 | |
1348 | int |
1390 | int |
1349 | poll_cb(...) |
1391 | poll_cb (...) |
1350 | PROTOTYPE: |
1392 | PROTOTYPE: |
1351 | CODE: |
1393 | CODE: |
1352 | RETVAL = poll_cb (); |
1394 | RETVAL = poll_cb (); |
1353 | OUTPUT: |
1395 | OUTPUT: |
1354 | RETVAL |
1396 | RETVAL |
1355 | |
1397 | |
1356 | void |
1398 | void |
1357 | poll_wait() |
1399 | poll_wait () |
1358 | PROTOTYPE: |
|
|
1359 | CODE: |
1400 | CODE: |
1360 | poll_wait (); |
1401 | poll_wait (); |
1361 | |
1402 | |
1362 | int |
1403 | int |
1363 | nreqs() |
1404 | nreqs () |
1364 | PROTOTYPE: |
|
|
1365 | CODE: |
1405 | CODE: |
1366 | RETVAL = eio_nreqs (); |
1406 | RETVAL = eio_nreqs (); |
1367 | OUTPUT: |
1407 | OUTPUT: |
1368 | RETVAL |
1408 | RETVAL |
1369 | |
1409 | |
1370 | int |
1410 | int |
1371 | nready() |
1411 | nready () |
1372 | PROTOTYPE: |
|
|
1373 | CODE: |
1412 | CODE: |
1374 | RETVAL = eio_nready (); |
1413 | RETVAL = eio_nready (); |
1375 | OUTPUT: |
1414 | OUTPUT: |
1376 | RETVAL |
1415 | RETVAL |
1377 | |
1416 | |
1378 | int |
1417 | int |
1379 | npending() |
1418 | npending () |
1380 | PROTOTYPE: |
|
|
1381 | CODE: |
1419 | CODE: |
1382 | RETVAL = eio_npending (); |
1420 | RETVAL = eio_npending (); |
1383 | OUTPUT: |
1421 | OUTPUT: |
1384 | RETVAL |
1422 | RETVAL |
1385 | |
1423 | |
1386 | int |
1424 | int |
1387 | nthreads() |
1425 | nthreads () |
1388 | PROTOTYPE: |
|
|
1389 | CODE: |
1426 | CODE: |
1390 | RETVAL = eio_nthreads (); |
1427 | RETVAL = eio_nthreads (); |
1391 | OUTPUT: |
1428 | OUTPUT: |
1392 | RETVAL |
1429 | RETVAL |
1393 | |
1430 | |
1394 | int |
1431 | int |
1395 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1432 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
1396 | PROTOTYPE: $$$$ |
|
|
1397 | CODE: |
1433 | CODE: |
1398 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1434 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1399 | OUTPUT: |
1435 | OUTPUT: |
1400 | RETVAL |
1436 | RETVAL |
1401 | |
1437 | |
1402 | ssize_t |
1438 | ssize_t |
1403 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1439 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1404 | PROTOTYPE: $$$$ |
|
|
1405 | CODE: |
1440 | CODE: |
1406 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1441 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1407 | OUTPUT: |
1442 | OUTPUT: |
1408 | RETVAL |
1443 | RETVAL |
1409 | |
1444 | |
1410 | void |
1445 | void |
1411 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1446 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
1412 | PROTOTYPE: $$$$$;$ |
|
|
1413 | PPCODE: |
1447 | PPCODE: |
1414 | sv_unmagic (scalar, MMAP_MAGIC); |
1448 | sv_unmagic (scalar, MMAP_MAGIC); |
1415 | { |
1449 | { |
1416 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1450 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1417 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1451 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
… | |
… | |
1440 | XSRETURN_YES; |
1474 | XSRETURN_YES; |
1441 | } |
1475 | } |
1442 | |
1476 | |
1443 | void |
1477 | void |
1444 | munmap (SV *scalar) |
1478 | munmap (SV *scalar) |
1445 | PROTOTYPE: $ |
|
|
1446 | CODE: |
1479 | CODE: |
1447 | sv_unmagic (scalar, MMAP_MAGIC); |
1480 | sv_unmagic (scalar, MMAP_MAGIC); |
1448 | |
1481 | |
1449 | int |
1482 | int |
1450 | madvise (SV *scalar, off_t offset, off_t length, IV advice) |
1483 | madvise (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef, IV advice_or_prot) |
1451 | PROTOTYPE: $$$$ |
1484 | ALIAS: |
|
|
1485 | mprotect = 1 |
1452 | CODE: |
1486 | CODE: |
1453 | { |
1487 | { |
1454 | char *addr = SvPV_nolen (scalar) + offset; |
1488 | STRLEN svlen; |
|
|
1489 | void *addr = SvPVbyte (scalar, svlen); |
|
|
1490 | size_t len = SvUV (length); |
1455 | |
1491 | |
1456 | if (!SvOK (ST (2))) |
1492 | if (offset < 0) |
|
|
1493 | offset += svlen; |
|
|
1494 | |
|
|
1495 | if (offset < 0 || offset > svlen) |
|
|
1496 | croak ("offset outside of scalar"); |
|
|
1497 | |
|
|
1498 | if (!SvOK (length) || len + offset > svlen) |
1457 | length = SvCUR (scalar) - offset; |
1499 | len = svlen - offset; |
1458 | |
1500 | |
1459 | if (addr >= SvEND (scalar) || length <= 0) |
1501 | addr = (void *)(((intptr_t)addr) + offset); |
1460 | XSRETURN_EMPTY; |
1502 | eio_page_align (&addr, &len); |
1461 | |
1503 | |
|
|
1504 | switch (ix) |
|
|
1505 | { |
1462 | RETVAL = posix_madvise (addr, length, advice); |
1506 | case 0: RETVAL = posix_madvise (addr, len, advice_or_prot); break; |
|
|
1507 | case 1: RETVAL = mprotect (addr, len, advice_or_prot); break; |
|
|
1508 | } |
1463 | } |
1509 | } |
1464 | OUTPUT: |
1510 | OUTPUT: |
1465 | RETVAL |
1511 | RETVAL |
1466 | |
1512 | |
1467 | int |
1513 | int |
1468 | mlockall (int flags) |
1514 | munlock (SV *scalar, off_t offset = 0, SV *length = &PL_sv_undef) |
1469 | PROTOTYPE: $ |
|
|
1470 | CODE: |
1515 | CODE: |
|
|
1516 | { |
|
|
1517 | STRLEN svlen; |
|
|
1518 | void *addr = SvPVbyte (scalar, svlen); |
|
|
1519 | size_t len = SvUV (length); |
|
|
1520 | |
|
|
1521 | if (offset < 0) |
|
|
1522 | offset += svlen; |
|
|
1523 | |
|
|
1524 | if (offset < 0 || offset > svlen) |
|
|
1525 | croak ("offset outside of scalar"); |
|
|
1526 | |
|
|
1527 | if (!SvOK (length) || len + offset > svlen) |
|
|
1528 | len = svlen - offset; |
|
|
1529 | |
|
|
1530 | addr = (void *)(((intptr_t)addr) + offset); |
|
|
1531 | eio_page_align (&addr, &len); |
1471 | #if _POSIX_MEMLOCK |
1532 | #if _POSIX_MEMLOCK_RANGE |
1472 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 |
1533 | 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 |
1534 | #else |
1478 | RETVAL = -1; |
1535 | RETVAL = ((errno = ENOSYS), -1); |
1479 | errno = ENOSYS; |
|
|
1480 | #endif |
1536 | #endif |
|
|
1537 | } |
1481 | OUTPUT: |
1538 | OUTPUT: |
1482 | RETVAL |
1539 | RETVAL |
1483 | |
1540 | |
1484 | int |
1541 | int |
1485 | munlockall () |
1542 | munlockall () |
1486 | PROTOTYPE: |
|
|
1487 | CODE: |
1543 | CODE: |
1488 | #if _POSIX_MEMLOCK |
1544 | #if _POSIX_MEMLOCK |
1489 | munlockall (); |
1545 | munlockall (); |
1490 | #else |
1546 | #else |
1491 | RETVAL = -1; |
1547 | RETVAL = -1; |