… | |
… | |
11 | #include <stddef.h> |
11 | #include <stddef.h> |
12 | #include <stdlib.h> |
12 | #include <stdlib.h> |
13 | #include <errno.h> |
13 | #include <errno.h> |
14 | #include <sys/types.h> |
14 | #include <sys/types.h> |
15 | #include <sys/stat.h> |
15 | #include <sys/stat.h> |
16 | #include <sys/statvfs.h> |
|
|
17 | #include <limits.h> |
16 | #include <limits.h> |
18 | #include <fcntl.h> |
17 | #include <fcntl.h> |
19 | #include <sched.h> |
18 | #include <sched.h> |
20 | |
19 | |
21 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
22 | # include <sys/mman.h> |
21 | # include <sys/mman.h> |
23 | #endif |
22 | #endif |
24 | |
23 | |
25 | /* perl namespace pollution */ |
24 | /* perl namespace pollution */ |
26 | #undef VERSION |
25 | #undef VERSION |
27 | |
|
|
28 | #ifdef _WIN32 |
|
|
29 | |
|
|
30 | # define EIO_STRUCT_DIRENT Direntry_t |
|
|
31 | # undef malloc |
|
|
32 | # undef free |
|
|
33 | |
|
|
34 | // perl overrides all those nice win32 functions |
|
|
35 | # undef open |
|
|
36 | # undef read |
|
|
37 | # undef write |
|
|
38 | # undef send |
|
|
39 | # undef recv |
|
|
40 | # undef stat |
|
|
41 | # undef fstat |
|
|
42 | # define lstat stat |
|
|
43 | # undef truncate |
|
|
44 | # undef ftruncate |
|
|
45 | # undef open |
|
|
46 | # undef close |
|
|
47 | # undef unlink |
|
|
48 | # undef rmdir |
|
|
49 | # undef rename |
|
|
50 | # undef lseek |
|
|
51 | |
|
|
52 | # define chown(a,b,c) (errno = ENOSYS, -1) |
|
|
53 | # define fchown(a,b,c) (errno = ENOSYS, -1) |
|
|
54 | # define fchmod(a,b) (errno = ENOSYS, -1) |
|
|
55 | # define symlink(a,b) (errno = ENOSYS, -1) |
|
|
56 | # define readlink(a,b,c) (errno = ENOSYS, -1) |
|
|
57 | # define mknod(a,b,c) (errno = ENOSYS, -1) |
|
|
58 | # define truncate(a,b) (errno = ENOSYS, -1) |
|
|
59 | # define ftruncate(fd,o) chsize ((fd), (o)) |
|
|
60 | # define fsync(fd) _commit (fd) |
|
|
61 | # define opendir(fd) (errno = ENOSYS, 0) |
|
|
62 | # define readdir(fd) (errno = ENOSYS, -1) |
|
|
63 | # define closedir(fd) (errno = ENOSYS, -1) |
|
|
64 | # define mkdir(a,b) mkdir (a) |
|
|
65 | |
|
|
66 | #else |
|
|
67 | |
|
|
68 | # include <sys/time.h> |
|
|
69 | # include <sys/select.h> |
|
|
70 | # include <unistd.h> |
|
|
71 | # include <utime.h> |
|
|
72 | # include <signal.h> |
|
|
73 | # define EIO_STRUCT_DIRENT struct dirent |
|
|
74 | |
|
|
75 | #endif |
|
|
76 | |
26 | |
77 | /* perl stupidly overrides readdir and maybe others */ |
27 | /* perl stupidly overrides readdir and maybe others */ |
78 | /* with thread-unsafe versions, imagine that :( */ |
28 | /* with thread-unsafe versions, imagine that :( */ |
79 | #undef readdir |
29 | #undef readdir |
80 | #undef opendir |
30 | #undef opendir |
81 | #undef closedir |
31 | #undef closedir |
|
|
32 | |
|
|
33 | #ifdef _WIN32 |
|
|
34 | |
|
|
35 | #define EIO_STRUCT_DIRENT Direntry_t |
|
|
36 | #undef malloc |
|
|
37 | #undef free |
|
|
38 | |
|
|
39 | // perl overrides all those nice libc functions |
|
|
40 | #undef open |
|
|
41 | #undef read |
|
|
42 | #undef write |
|
|
43 | #undef send |
|
|
44 | #undef recv |
|
|
45 | #undef stat |
|
|
46 | #undef lstat |
|
|
47 | #undef fstat |
|
|
48 | #undef truncate |
|
|
49 | #undef ftruncate |
|
|
50 | #undef open |
|
|
51 | #undef link |
|
|
52 | #undef close |
|
|
53 | #undef unlink |
|
|
54 | #undef mkdir |
|
|
55 | #undef rmdir |
|
|
56 | #undef rename |
|
|
57 | #undef lseek |
|
|
58 | #undef opendir |
|
|
59 | #undef readdir |
|
|
60 | #undef closedir |
|
|
61 | #undef chmod |
|
|
62 | #undef fchmod |
|
|
63 | #undef dup |
|
|
64 | #undef dup2 |
|
|
65 | #undef abort |
|
|
66 | #undef pipe |
|
|
67 | |
|
|
68 | #else |
|
|
69 | |
|
|
70 | #include <sys/time.h> |
|
|
71 | #include <sys/select.h> |
|
|
72 | #include <unistd.h> |
|
|
73 | #include <utime.h> |
|
|
74 | #include <signal.h> |
|
|
75 | |
|
|
76 | #endif |
82 | |
77 | |
83 | #define EIO_STRUCT_STAT Stat_t |
78 | #define EIO_STRUCT_STAT Stat_t |
84 | |
79 | |
85 | /* use NV for 32 bit perls as it allows larger offsets */ |
80 | /* use NV for 32 bit perls as it allows larger offsets */ |
86 | #if IVSIZE >= 8 |
81 | #if IVSIZE >= 8 |
… | |
… | |
121 | #define EIO_NO_WRAPPERS 1 |
116 | #define EIO_NO_WRAPPERS 1 |
122 | |
117 | |
123 | #include "libeio/config.h" |
118 | #include "libeio/config.h" |
124 | #include "libeio/eio.h" |
119 | #include "libeio/eio.h" |
125 | |
120 | |
|
|
121 | static int req_invoke (eio_req *req); |
|
|
122 | #define EIO_FINISH(req) req_invoke (req) |
|
|
123 | static void req_destroy (eio_req *grp); |
|
|
124 | #define EIO_DESTROY(req) req_destroy (req) |
|
|
125 | |
|
|
126 | #include "libeio/eio.c" |
|
|
127 | |
|
|
128 | /* Linux/others */ |
|
|
129 | #ifndef O_ASYNC |
|
|
130 | # define O_ASYNC 0 |
|
|
131 | #endif |
|
|
132 | #ifndef O_DIRECT |
|
|
133 | # define O_DIRECT 0 |
|
|
134 | #endif |
|
|
135 | #ifndef O_NOATIME |
|
|
136 | # define O_NOATIME 0 |
|
|
137 | #endif |
|
|
138 | |
|
|
139 | /* POSIX */ |
|
|
140 | #ifndef O_CLOEXEC |
|
|
141 | # define O_CLOEXEC 0 |
|
|
142 | #endif |
|
|
143 | #ifndef O_NOFOLLOW |
|
|
144 | # define O_NOFOLLOW 0 |
|
|
145 | #endif |
|
|
146 | #ifndef O_NOCTTY |
|
|
147 | # define O_NOCTTY 0 |
|
|
148 | #endif |
|
|
149 | #ifndef O_NONBLOCK |
|
|
150 | # define O_NONBLOCK 0 |
|
|
151 | #endif |
|
|
152 | #ifndef O_EXEC |
|
|
153 | # define O_EXEC 0 |
|
|
154 | #endif |
|
|
155 | #ifndef O_SEARCH |
|
|
156 | # define O_SEARCH 0 |
|
|
157 | #endif |
|
|
158 | #ifndef O_DIRECTORY |
|
|
159 | # define O_DIRECTORY 0 |
|
|
160 | #endif |
|
|
161 | #ifndef O_DSYNC |
|
|
162 | # define O_DSYNC 0 |
|
|
163 | #endif |
|
|
164 | #ifndef O_RSYNC |
|
|
165 | # define O_RSYNC 0 |
|
|
166 | #endif |
|
|
167 | #ifndef O_SYNC |
|
|
168 | # define O_SYNC 0 |
|
|
169 | #endif |
|
|
170 | #ifndef O_TTY_INIT |
|
|
171 | # define O_TTY_INIT 0 |
|
|
172 | #endif |
|
|
173 | |
126 | #ifndef POSIX_FADV_NORMAL |
174 | #ifndef POSIX_FADV_NORMAL |
127 | # define POSIX_FADV_NORMAL 0 |
175 | # define POSIX_FADV_NORMAL 0 |
128 | #endif |
176 | #endif |
129 | #ifndef POSIX_FADV_SEQUENTIAL |
177 | #ifndef POSIX_FADV_SEQUENTIAL |
130 | # define POSIX_FADV_SEQUENTIAL 0 |
178 | # define POSIX_FADV_SEQUENTIAL 0 |
… | |
… | |
177 | #endif |
225 | #endif |
178 | #ifndef PROT_EXEC |
226 | #ifndef PROT_EXEC |
179 | # define PROT_EXEC 0 |
227 | # define PROT_EXEC 0 |
180 | #endif |
228 | #endif |
181 | |
229 | |
|
|
230 | #ifndef ST_RDONLY |
|
|
231 | # define ST_RDONLY 0 |
|
|
232 | #endif |
|
|
233 | #ifndef ST_NOSUID |
|
|
234 | # define ST_NOSUID 0 |
|
|
235 | #endif |
182 | #ifndef ST_NODEV |
236 | #ifndef ST_NODEV |
183 | # define ST_NODEV 0 |
237 | # define ST_NODEV 0 |
184 | #endif |
238 | #endif |
185 | #ifndef ST_NOEXEC |
239 | #ifndef ST_NOEXEC |
186 | # define ST_NOEXEC 0 |
240 | # define ST_NOEXEC 0 |
… | |
… | |
206 | #ifndef ST_NODIRATIME |
260 | #ifndef ST_NODIRATIME |
207 | # define ST_NODIRATIME 0 |
261 | # define ST_NODIRATIME 0 |
208 | #endif |
262 | #endif |
209 | #ifndef ST_RELATIME |
263 | #ifndef ST_RELATIME |
210 | # define ST_RELATIME 0 |
264 | # define ST_RELATIME 0 |
|
|
265 | #endif |
|
|
266 | |
|
|
267 | #ifndef S_IFIFO |
|
|
268 | # define S_IFIFO 0 |
|
|
269 | #endif |
|
|
270 | #ifndef S_IFCHR |
|
|
271 | # define S_IFCHR 0 |
|
|
272 | #endif |
|
|
273 | #ifndef S_IFBLK |
|
|
274 | # define S_IFBLK 0 |
|
|
275 | #endif |
|
|
276 | #ifndef S_IFLNK |
|
|
277 | # define S_IFLNK 0 |
|
|
278 | #endif |
|
|
279 | #ifndef S_IFREG |
|
|
280 | # define S_IFREG 0 |
|
|
281 | #endif |
|
|
282 | #ifndef S_IFDIR |
|
|
283 | # define S_IFDIR 0 |
|
|
284 | #endif |
|
|
285 | #ifndef S_IFWHT |
|
|
286 | # define S_IFWHT 0 |
|
|
287 | #endif |
|
|
288 | #ifndef S_IFSOCK |
|
|
289 | # define S_IFSOCK 0 |
211 | #endif |
290 | #endif |
212 | |
291 | |
213 | #ifndef MAP_ANONYMOUS |
292 | #ifndef MAP_ANONYMOUS |
214 | # ifdef MAP_ANON |
293 | # ifdef MAP_ANON |
215 | # define MAP_ANONYMOUS MAP_ANON |
294 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
231 | #endif |
310 | #endif |
232 | #ifndef MAP_NONBLOCK |
311 | #ifndef MAP_NONBLOCK |
233 | # define MAP_NONBLOCK 0 |
312 | # define MAP_NONBLOCK 0 |
234 | #endif |
313 | #endif |
235 | |
314 | |
|
|
315 | #ifndef makedev |
|
|
316 | # define makedev(maj,min) (((maj) << 8) | (min)) |
|
|
317 | #endif |
|
|
318 | #ifndef major |
|
|
319 | # define major(dev) ((dev) >> 8) |
|
|
320 | #endif |
|
|
321 | #ifndef minor |
|
|
322 | # define minor(dev) ((dev) & 0xff) |
|
|
323 | #endif |
|
|
324 | |
236 | #ifndef PAGESIZE |
325 | #ifndef PAGESIZE |
237 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
326 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
238 | #endif |
327 | #endif |
239 | |
|
|
240 | static int req_invoke (eio_req *req); |
|
|
241 | #define EIO_FINISH(req) req_invoke (req) |
|
|
242 | static void req_destroy (eio_req *grp); |
|
|
243 | #define EIO_DESTROY(req) req_destroy (req) |
|
|
244 | |
328 | |
245 | enum { |
329 | enum { |
246 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
330 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
247 | }; |
331 | }; |
248 | |
|
|
249 | #include "libeio/eio.c" |
|
|
250 | |
332 | |
251 | typedef eio_req *aio_req; |
333 | typedef eio_req *aio_req; |
252 | typedef eio_req *aio_req_ornot; |
334 | typedef eio_req *aio_req_ornot; |
253 | |
335 | |
254 | static SV *on_next_submit; |
336 | static SV *on_next_submit; |
… | |
… | |
460 | case EIO_STATVFS: |
542 | case EIO_STATVFS: |
461 | case EIO_FSTATVFS: |
543 | case EIO_FSTATVFS: |
462 | { |
544 | { |
463 | SV *rv = &PL_sv_undef; |
545 | SV *rv = &PL_sv_undef; |
464 | |
546 | |
|
|
547 | #ifndef _WIN32 |
465 | if (req->result >= 0) |
548 | if (req->result >= 0) |
466 | { |
549 | { |
467 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
550 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
468 | HV *hv = newHV (); |
551 | HV *hv = newHV (); |
469 | |
552 | |
… | |
… | |
479 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
562 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
480 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
563 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
481 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
564 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
482 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
565 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
483 | } |
566 | } |
|
|
567 | #endif |
484 | |
568 | |
485 | PUSHs (rv); |
569 | PUSHs (rv); |
486 | } |
570 | } |
487 | |
571 | |
488 | break; |
572 | break; |
… | |
… | |
504 | case EIO_NOP: |
588 | case EIO_NOP: |
505 | case EIO_BUSY: |
589 | case EIO_BUSY: |
506 | break; |
590 | break; |
507 | |
591 | |
508 | case EIO_READLINK: |
592 | case EIO_READLINK: |
|
|
593 | case EIO_REALPATH: |
509 | if (req->result > 0) |
594 | if (req->result > 0) |
510 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
595 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
511 | break; |
596 | break; |
512 | |
597 | |
513 | case EIO_STAT: |
598 | case EIO_STAT: |
514 | case EIO_LSTAT: |
599 | case EIO_LSTAT: |
515 | case EIO_FSTAT: |
600 | case EIO_FSTAT: |
516 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
601 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
517 | PL_laststatval = req->result; |
602 | PL_laststatval = req->result; |
|
|
603 | /* if compilation fails here then perl's Stat_t is not struct _stati64 */ |
518 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
604 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
519 | PUSHs (sv_result); |
605 | PUSHs (sv_result); |
520 | break; |
606 | break; |
521 | |
607 | |
522 | case EIO_READ: |
608 | case EIO_READ: |
… | |
… | |
574 | Safefree (req); |
660 | Safefree (req); |
575 | } |
661 | } |
576 | |
662 | |
577 | static void req_cancel_subs (aio_req grp) |
663 | static void req_cancel_subs (aio_req grp) |
578 | { |
664 | { |
579 | aio_req sub; |
|
|
580 | |
|
|
581 | if (grp->type != EIO_GROUP) |
665 | if (grp->type != EIO_GROUP) |
582 | return; |
666 | return; |
583 | |
667 | |
584 | SvREFCNT_dec (grp->sv2); |
668 | SvREFCNT_dec (grp->sv2); |
585 | grp->sv2 = 0; |
669 | grp->sv2 = 0; |
586 | |
670 | |
587 | eio_grp_cancel (grp); |
671 | eio_grp_cancel (grp); |
588 | } |
672 | } |
589 | |
673 | |
590 | static void |
|
|
591 | create_respipe (void) |
674 | static void create_respipe (void) |
592 | { |
675 | { |
593 | if (s_epipe_renew (&respipe)) |
676 | if (s_epipe_renew (&respipe)) |
594 | croak ("IO::AIO: unable to initialize result pipe"); |
677 | croak ("IO::AIO: unable to initialize result pipe"); |
595 | } |
678 | } |
596 | |
679 | |
… | |
… | |
650 | # define MAP_FIXED 0 |
733 | # define MAP_FIXED 0 |
651 | #endif |
734 | #endif |
652 | |
735 | |
653 | #define MMAP_MAGIC PERL_MAGIC_ext |
736 | #define MMAP_MAGIC PERL_MAGIC_ext |
654 | |
737 | |
655 | static int |
|
|
656 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
738 | static int mmap_free (pTHX_ SV *sv, MAGIC *mg) |
657 | { |
739 | { |
658 | int old_errno = errno; |
740 | int old_errno = errno; |
659 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
741 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
660 | errno = old_errno; |
742 | errno = old_errno; |
661 | |
743 | |
… | |
… | |
677 | 0, 0, 0, 0, mmap_free |
759 | 0, 0, 0, 0, mmap_free |
678 | }; |
760 | }; |
679 | |
761 | |
680 | /*****************************************************************************/ |
762 | /*****************************************************************************/ |
681 | |
763 | |
682 | static SV * |
|
|
683 | get_cb (SV *cb_sv) |
764 | static SV * get_cb (SV *cb_sv) |
684 | { |
765 | { |
685 | SvGETMAGIC (cb_sv); |
766 | SvGETMAGIC (cb_sv); |
686 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
767 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
687 | } |
768 | } |
688 | |
769 | |
… | |
… | |
729 | const_iv (O_RDWR) |
810 | const_iv (O_RDWR) |
730 | const_iv (O_CREAT) |
811 | const_iv (O_CREAT) |
731 | const_iv (O_TRUNC) |
812 | const_iv (O_TRUNC) |
732 | const_iv (O_EXCL) |
813 | const_iv (O_EXCL) |
733 | const_iv (O_APPEND) |
814 | const_iv (O_APPEND) |
734 | #ifndef _WIN32 |
815 | |
|
|
816 | const_iv (O_ASYNC) |
|
|
817 | const_iv (O_DIRECT) |
|
|
818 | const_iv (O_NOATIME) |
|
|
819 | |
|
|
820 | const_iv (O_CLOEXEC) |
|
|
821 | const_iv (O_NOCTTY) |
|
|
822 | const_iv (O_NOFOLLOW) |
|
|
823 | const_iv (O_NONBLOCK) |
|
|
824 | const_iv (O_EXEC) |
|
|
825 | const_iv (O_SEARCH) |
|
|
826 | const_iv (O_DIRECTORY) |
|
|
827 | const_iv (O_DSYNC) |
|
|
828 | const_iv (O_RSYNC) |
|
|
829 | const_iv (O_SYNC) |
|
|
830 | const_iv (O_TTY_INIT) |
|
|
831 | |
735 | const_iv (S_IFIFO) |
832 | const_iv (S_IFIFO) |
736 | #endif |
833 | const_iv (S_IFCHR) |
|
|
834 | const_iv (S_IFBLK) |
|
|
835 | const_iv (S_IFLNK) |
|
|
836 | const_iv (S_IFREG) |
|
|
837 | const_iv (S_IFDIR) |
|
|
838 | const_iv (S_IFWHT) |
|
|
839 | const_iv (S_IFSOCK) |
|
|
840 | const_iv (S_IFMT) |
|
|
841 | |
737 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
842 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
738 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
843 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
739 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
844 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
740 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
845 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
741 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
846 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
… | |
… | |
788 | |
893 | |
789 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
894 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
790 | const_eio (SYNC_FILE_RANGE_WRITE) |
895 | const_eio (SYNC_FILE_RANGE_WRITE) |
791 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
896 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
792 | |
897 | |
|
|
898 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
899 | |
793 | const_eio (READDIR_DENTS) |
900 | const_eio (READDIR_DENTS) |
794 | const_eio (READDIR_DIRS_FIRST) |
901 | const_eio (READDIR_DIRS_FIRST) |
795 | const_eio (READDIR_STAT_ORDER) |
902 | const_eio (READDIR_STAT_ORDER) |
796 | const_eio (READDIR_FOUND_UNKNOWN) |
903 | const_eio (READDIR_FOUND_UNKNOWN) |
797 | |
904 | |
… | |
… | |
823 | /* atfork child called in fifo order, so before eio's handler */ |
930 | /* atfork child called in fifo order, so before eio's handler */ |
824 | X_THREAD_ATFORK (0, 0, atfork_child); |
931 | X_THREAD_ATFORK (0, 0, atfork_child); |
825 | } |
932 | } |
826 | |
933 | |
827 | void |
934 | void |
828 | max_poll_reqs (int nreqs) |
935 | max_poll_reqs (unsigned int nreqs) |
829 | PROTOTYPE: $ |
936 | PROTOTYPE: $ |
830 | CODE: |
937 | CODE: |
831 | eio_set_max_poll_reqs (nreqs); |
938 | eio_set_max_poll_reqs (nreqs); |
832 | |
939 | |
833 | void |
940 | void |
… | |
… | |
835 | PROTOTYPE: $ |
942 | PROTOTYPE: $ |
836 | CODE: |
943 | CODE: |
837 | eio_set_max_poll_time (nseconds); |
944 | eio_set_max_poll_time (nseconds); |
838 | |
945 | |
839 | void |
946 | void |
840 | min_parallel (int nthreads) |
947 | min_parallel (unsigned int nthreads) |
841 | PROTOTYPE: $ |
948 | PROTOTYPE: $ |
842 | CODE: |
949 | CODE: |
843 | eio_set_min_parallel (nthreads); |
950 | eio_set_min_parallel (nthreads); |
844 | |
951 | |
845 | void |
952 | void |
846 | max_parallel (int nthreads) |
953 | max_parallel (unsigned int nthreads) |
847 | PROTOTYPE: $ |
954 | PROTOTYPE: $ |
848 | CODE: |
955 | CODE: |
849 | eio_set_max_parallel (nthreads); |
956 | eio_set_max_parallel (nthreads); |
850 | |
957 | |
851 | void |
958 | void |
852 | max_idle (int nthreads) |
959 | max_idle (unsigned int nthreads) |
853 | PROTOTYPE: $ |
960 | PROTOTYPE: $ |
854 | CODE: |
961 | CODE: |
855 | eio_set_max_idle (nthreads); |
962 | eio_set_max_idle (nthreads); |
856 | |
963 | |
857 | void |
964 | void |
|
|
965 | idle_timeout (unsigned int seconds) |
|
|
966 | PROTOTYPE: $ |
|
|
967 | CODE: |
|
|
968 | eio_set_idle_timeout (seconds); |
|
|
969 | |
|
|
970 | void |
858 | max_outstanding (int maxreqs) |
971 | max_outstanding (unsigned int maxreqs) |
859 | PROTOTYPE: $ |
972 | PROTOTYPE: $ |
860 | CODE: |
973 | CODE: |
861 | max_outstanding = maxreqs; |
974 | max_outstanding = maxreqs; |
862 | |
975 | |
863 | void |
976 | void |
… | |
… | |
908 | |
1021 | |
909 | REQ_SEND (req); |
1022 | REQ_SEND (req); |
910 | } |
1023 | } |
911 | |
1024 | |
912 | void |
1025 | void |
|
|
1026 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
|
|
1027 | PPCODE: |
|
|
1028 | { |
|
|
1029 | int fd = s_fileno_croak (fh, 0); |
|
|
1030 | dREQ; |
|
|
1031 | |
|
|
1032 | req->type = EIO_FALLOCATE; |
|
|
1033 | req->sv1 = newSVsv (fh); |
|
|
1034 | req->int1 = fd; |
|
|
1035 | req->int2 = mode; |
|
|
1036 | req->offs = offset; |
|
|
1037 | req->size = len; |
|
|
1038 | |
|
|
1039 | REQ_SEND (req); |
|
|
1040 | } |
|
|
1041 | |
|
|
1042 | void |
913 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1043 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
914 | PPCODE: |
1044 | PPCODE: |
915 | { |
1045 | { |
916 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
1046 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
917 | int fd = s_fileno_croak (fh, 0); |
1047 | int fd = s_fileno_croak (fh, 0); |
918 | dREQ; |
1048 | dREQ; |
919 | |
1049 | |
920 | if (close_pipe < 0) |
1050 | if (expect_false (close_fd < 0)) |
921 | { |
1051 | { |
922 | int pipefd [2]; |
1052 | int pipefd [2]; |
923 | |
1053 | |
|
|
1054 | if ( |
|
|
1055 | #ifdef _WIN32 |
|
|
1056 | _pipe (pipefd, 1, _O_BINARY) < 0 |
|
|
1057 | #else |
924 | if (pipe (pipefd) < 0 |
1058 | pipe (pipefd) < 0 |
925 | || close (pipefd [1]) < 0 |
|
|
926 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) |
1059 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0 |
|
|
1060 | #endif |
|
|
1061 | || close (pipefd [1]) < 0 |
|
|
1062 | ) |
927 | abort (); /*D*/ |
1063 | abort (); /*D*/ |
928 | |
1064 | |
929 | close_pipe = pipefd [0]; |
1065 | close_fd = pipefd [0]; |
930 | } |
1066 | } |
931 | |
1067 | |
932 | req->type = EIO_DUP2; |
1068 | req->type = EIO_DUP2; |
933 | req->int1 = close_pipe; |
1069 | req->int1 = close_fd; |
934 | req->sv2 = newSVsv (fh); |
1070 | req->sv2 = newSVsv (fh); |
935 | req->int2 = fd; |
1071 | req->int2 = fd; |
936 | |
1072 | |
937 | REQ_SEND (req); |
1073 | REQ_SEND (req); |
938 | } |
1074 | } |
… | |
… | |
990 | } |
1126 | } |
991 | } |
1127 | } |
992 | |
1128 | |
993 | void |
1129 | void |
994 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
1130 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
|
|
1131 | ALIAS: |
|
|
1132 | aio_readlink = EIO_READLINK |
|
|
1133 | aio_realpath = EIO_REALPATH |
995 | PPCODE: |
1134 | PPCODE: |
996 | { |
1135 | { |
997 | SV *data; |
|
|
998 | dREQ; |
1136 | dREQ; |
999 | |
1137 | |
1000 | req->type = EIO_READLINK; |
1138 | req->type = ix; |
1001 | req->sv1 = newSVsv (path); |
1139 | req->sv1 = newSVsv (path); |
1002 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1140 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1003 | |
1141 | |
1004 | REQ_SEND; |
1142 | REQ_SEND; |
1005 | } |
1143 | } |
… | |
… | |
1062 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
1200 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
1063 | } |
1201 | } |
1064 | |
1202 | |
1065 | REQ_SEND; |
1203 | REQ_SEND; |
1066 | } |
1204 | } |
|
|
1205 | |
|
|
1206 | UV |
|
|
1207 | major (UV dev) |
|
|
1208 | ALIAS: |
|
|
1209 | minor = 1 |
|
|
1210 | CODE: |
|
|
1211 | RETVAL = ix ? major (dev) : minor (dev); |
|
|
1212 | OUTPUT: |
|
|
1213 | RETVAL |
|
|
1214 | |
|
|
1215 | UV |
|
|
1216 | makedev (UV maj, UV min) |
|
|
1217 | CODE: |
|
|
1218 | RETVAL = makedev (maj, min); |
|
|
1219 | OUTPUT: |
|
|
1220 | RETVAL |
1067 | |
1221 | |
1068 | void |
1222 | void |
1069 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1223 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1070 | PPCODE: |
1224 | PPCODE: |
1071 | { |
1225 | { |