… | |
… | |
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_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 |
|
|
26 | |
|
|
27 | /* perl stupidly overrides readdir and maybe others */ |
|
|
28 | /* with thread-unsafe versions, imagine that :( */ |
|
|
29 | #undef readdir |
|
|
30 | #undef opendir |
|
|
31 | #undef closedir |
27 | |
32 | |
28 | #ifdef _WIN32 |
33 | #ifdef _WIN32 |
29 | |
34 | |
30 | # define EIO_STRUCT_DIRENT Direntry_t |
35 | # define EIO_STRUCT_DIRENT Direntry_t |
31 | # undef malloc |
36 | # undef malloc |
… | |
… | |
35 | # undef open |
40 | # undef open |
36 | # undef read |
41 | # undef read |
37 | # undef write |
42 | # undef write |
38 | # undef send |
43 | # undef send |
39 | # undef recv |
44 | # undef recv |
40 | # undef stat |
45 | # undef lstat |
41 | # undef fstat |
|
|
42 | # define lstat stat |
|
|
43 | # undef truncate |
46 | # undef truncate |
44 | # undef ftruncate |
47 | # undef ftruncate |
45 | # undef open |
48 | # undef open |
|
|
49 | # undef link |
46 | # undef close |
50 | # undef close |
47 | # undef unlink |
51 | # undef unlink |
|
|
52 | # undef mkdir |
48 | # undef rmdir |
53 | # undef rmdir |
49 | # undef rename |
54 | # undef rename |
50 | # undef lseek |
55 | # undef lseek |
|
|
56 | # undef opendir |
|
|
57 | # undef readdir |
|
|
58 | # undef closedir |
|
|
59 | # undef chmod |
|
|
60 | # undef fchmod |
51 | |
61 | |
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 opendir(fd) EIO_ERRNO (ENOSYS, 0) |
62 | # define readdir(fd) (errno = ENOSYS, -1) |
63 | # define readdir(fd) EIO_ENOSYS () |
63 | # define closedir(fd) (errno = ENOSYS, -1) |
64 | # define closedir(fd) EIO_ENOSYS () |
64 | # define mkdir(a,b) mkdir (a) |
|
|
65 | |
65 | |
66 | #else |
66 | #else |
67 | |
67 | |
68 | # include <sys/time.h> |
68 | # include <sys/time.h> |
69 | # include <sys/select.h> |
69 | # include <sys/select.h> |
70 | # include <unistd.h> |
70 | # include <unistd.h> |
71 | # include <utime.h> |
71 | # include <utime.h> |
72 | # include <signal.h> |
72 | # include <signal.h> |
73 | # define EIO_STRUCT_DIRENT struct dirent |
|
|
74 | |
73 | |
75 | #endif |
74 | #endif |
76 | |
|
|
77 | /* perl stupidly overrides readdir and maybe others */ |
|
|
78 | /* with thread-unsafe versions, imagine that :( */ |
|
|
79 | #undef readdir |
|
|
80 | #undef opendir |
|
|
81 | #undef closedir |
|
|
82 | |
75 | |
83 | #define EIO_STRUCT_STAT Stat_t |
76 | #define EIO_STRUCT_STAT Stat_t |
84 | |
77 | |
85 | /* use NV for 32 bit perls as it allows larger offsets */ |
78 | /* use NV for 32 bit perls as it allows larger offsets */ |
86 | #if IVSIZE >= 8 |
79 | #if IVSIZE >= 8 |
… | |
… | |
118 | STRLEN stroffset; \ |
111 | STRLEN stroffset; \ |
119 | SV *self; |
112 | SV *self; |
120 | |
113 | |
121 | #define EIO_NO_WRAPPERS 1 |
114 | #define EIO_NO_WRAPPERS 1 |
122 | |
115 | |
|
|
116 | #include "libeio/config.h" |
123 | #include "libeio/eio.h" |
117 | #include "libeio/eio.h" |
|
|
118 | |
|
|
119 | /* Linux/others */ |
|
|
120 | #ifndef O_ASYNC |
|
|
121 | # define O_ASYNC 0 |
|
|
122 | #endif |
|
|
123 | #ifndef O_DIRECT |
|
|
124 | # define O_DIRECT 0 |
|
|
125 | #endif |
|
|
126 | #ifndef O_NOATIME |
|
|
127 | # define O_NOATIME 0 |
|
|
128 | #endif |
|
|
129 | |
|
|
130 | /* POSIX */ |
|
|
131 | #ifndef O_CLOEXEC |
|
|
132 | # define O_CLOEXEC 0 |
|
|
133 | #endif |
|
|
134 | #ifndef O_NOFOLLOW |
|
|
135 | # define O_NOFOLLOW 0 |
|
|
136 | #endif |
|
|
137 | #ifndef O_NOCTTY |
|
|
138 | # define O_NOCTTY 0 |
|
|
139 | #endif |
|
|
140 | #ifndef O_NONBLOCK |
|
|
141 | # define O_NONBLOCK 0 |
|
|
142 | #endif |
|
|
143 | #ifndef O_EXEC |
|
|
144 | # define O_EXEC 0 |
|
|
145 | #endif |
|
|
146 | #ifndef O_SEARCH |
|
|
147 | # define O_SEARCH 0 |
|
|
148 | #endif |
|
|
149 | #ifndef O_DIRECTORY |
|
|
150 | # define O_DIRECTORY 0 |
|
|
151 | #endif |
|
|
152 | #ifndef O_DSYNC |
|
|
153 | # define O_DSYNC 0 |
|
|
154 | #endif |
|
|
155 | #ifndef O_RSYNC |
|
|
156 | # define O_RSYNC 0 |
|
|
157 | #endif |
|
|
158 | #ifndef O_SYNC |
|
|
159 | # define O_SYNC 0 |
|
|
160 | #endif |
|
|
161 | #ifndef O_TTY_INIT |
|
|
162 | # define O_TTY_INIT 0 |
|
|
163 | #endif |
124 | |
164 | |
125 | #ifndef POSIX_FADV_NORMAL |
165 | #ifndef POSIX_FADV_NORMAL |
126 | # define POSIX_FADV_NORMAL 0 |
166 | # define POSIX_FADV_NORMAL 0 |
127 | #endif |
167 | #endif |
128 | #ifndef POSIX_FADV_SEQUENTIAL |
168 | #ifndef POSIX_FADV_SEQUENTIAL |
… | |
… | |
176 | #endif |
216 | #endif |
177 | #ifndef PROT_EXEC |
217 | #ifndef PROT_EXEC |
178 | # define PROT_EXEC 0 |
218 | # define PROT_EXEC 0 |
179 | #endif |
219 | #endif |
180 | |
220 | |
|
|
221 | #ifndef ST_RDONLY |
|
|
222 | # define ST_RDONLY 0 |
|
|
223 | #endif |
|
|
224 | #ifndef ST_NOSUID |
|
|
225 | # define ST_NOSUID 0 |
|
|
226 | #endif |
181 | #ifndef ST_NODEV |
227 | #ifndef ST_NODEV |
182 | # define ST_NODEV 0 |
228 | # define ST_NODEV 0 |
183 | #endif |
229 | #endif |
184 | #ifndef ST_NOEXEC |
230 | #ifndef ST_NOEXEC |
185 | # define ST_NOEXEC 0 |
231 | # define ST_NOEXEC 0 |
… | |
… | |
205 | #ifndef ST_NODIRATIME |
251 | #ifndef ST_NODIRATIME |
206 | # define ST_NODIRATIME 0 |
252 | # define ST_NODIRATIME 0 |
207 | #endif |
253 | #endif |
208 | #ifndef ST_RELATIME |
254 | #ifndef ST_RELATIME |
209 | # define ST_RELATIME 0 |
255 | # define ST_RELATIME 0 |
|
|
256 | #endif |
|
|
257 | |
|
|
258 | #ifndef S_IFIFO |
|
|
259 | # define S_IFIFO 0 |
|
|
260 | #endif |
|
|
261 | #ifndef S_IFCHR |
|
|
262 | # define S_IFCHR 0 |
|
|
263 | #endif |
|
|
264 | #ifndef S_IFBLK |
|
|
265 | # define S_IFBLK 0 |
|
|
266 | #endif |
|
|
267 | #ifndef S_IFLNK |
|
|
268 | # define S_IFLNK 0 |
|
|
269 | #endif |
|
|
270 | #ifndef S_IFREG |
|
|
271 | # define S_IFREG 0 |
|
|
272 | #endif |
|
|
273 | #ifndef S_IFDIR |
|
|
274 | # define S_IFDIR 0 |
|
|
275 | #endif |
|
|
276 | #ifndef S_IFWHT |
|
|
277 | # define S_IFWHT 0 |
|
|
278 | #endif |
|
|
279 | #ifndef S_IFSOCK |
|
|
280 | # define S_IFSOCK 0 |
210 | #endif |
281 | #endif |
211 | |
282 | |
212 | #ifndef MAP_ANONYMOUS |
283 | #ifndef MAP_ANONYMOUS |
213 | # ifdef MAP_ANON |
284 | # ifdef MAP_ANON |
214 | # define MAP_ANONYMOUS MAP_ANON |
285 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
228 | #ifndef MAP_POPULATE |
299 | #ifndef MAP_POPULATE |
229 | # define MAP_POPULATE 0 |
300 | # define MAP_POPULATE 0 |
230 | #endif |
301 | #endif |
231 | #ifndef MAP_NONBLOCK |
302 | #ifndef MAP_NONBLOCK |
232 | # define MAP_NONBLOCK 0 |
303 | # define MAP_NONBLOCK 0 |
|
|
304 | #endif |
|
|
305 | |
|
|
306 | #ifndef makedev |
|
|
307 | # define makedev(maj,min) (((maj) << 8) | (min)) |
|
|
308 | #endif |
|
|
309 | #ifndef major |
|
|
310 | # define major(dev) ((dev) >> 8) |
|
|
311 | #endif |
|
|
312 | #ifndef minor |
|
|
313 | # define minor(dev) ((dev) & 0xff) |
233 | #endif |
314 | #endif |
234 | |
315 | |
235 | #ifndef PAGESIZE |
316 | #ifndef PAGESIZE |
236 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
317 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
237 | #endif |
318 | #endif |
… | |
… | |
352 | /* do not recreate the result IV from scratch each time */ |
433 | /* do not recreate the result IV from scratch each time */ |
353 | if (expect_true (sv_result_cache)) |
434 | if (expect_true (sv_result_cache)) |
354 | { |
435 | { |
355 | sv_result = sv_result_cache; sv_result_cache = 0; |
436 | sv_result = sv_result_cache; sv_result_cache = 0; |
356 | SvIV_set (sv_result, req->result); |
437 | SvIV_set (sv_result, req->result); |
|
|
438 | SvIOK_only (sv_result); |
357 | } |
439 | } |
358 | else |
440 | else |
359 | { |
441 | { |
360 | sv_result = newSViv (req->result); |
442 | sv_result = newSViv (req->result); |
361 | SvREADONLY_on (sv_result); |
443 | SvREADONLY_on (sv_result); |
… | |
… | |
458 | case EIO_STATVFS: |
540 | case EIO_STATVFS: |
459 | case EIO_FSTATVFS: |
541 | case EIO_FSTATVFS: |
460 | { |
542 | { |
461 | SV *rv = &PL_sv_undef; |
543 | SV *rv = &PL_sv_undef; |
462 | |
544 | |
|
|
545 | #ifndef _WIN32 |
463 | if (req->result >= 0) |
546 | if (req->result >= 0) |
464 | { |
547 | { |
465 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
548 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
466 | HV *hv = newHV (); |
549 | HV *hv = newHV (); |
467 | |
550 | |
… | |
… | |
477 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
560 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
478 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
561 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
479 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
562 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
480 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
563 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
481 | } |
564 | } |
|
|
565 | #endif |
482 | |
566 | |
483 | PUSHs (rv); |
567 | PUSHs (rv); |
484 | } |
568 | } |
485 | |
569 | |
486 | break; |
570 | break; |
… | |
… | |
502 | case EIO_NOP: |
586 | case EIO_NOP: |
503 | case EIO_BUSY: |
587 | case EIO_BUSY: |
504 | break; |
588 | break; |
505 | |
589 | |
506 | case EIO_READLINK: |
590 | case EIO_READLINK: |
|
|
591 | case EIO_REALPATH: |
507 | if (req->result > 0) |
592 | if (req->result > 0) |
508 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
593 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
509 | break; |
594 | break; |
510 | |
595 | |
511 | case EIO_STAT: |
596 | case EIO_STAT: |
… | |
… | |
525 | SvSETMAGIC (req->sv2); |
610 | SvSETMAGIC (req->sv2); |
526 | PUSHs (sv_result); |
611 | PUSHs (sv_result); |
527 | } |
612 | } |
528 | break; |
613 | break; |
529 | |
614 | |
530 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ |
615 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ |
531 | if (req->result > 0) |
616 | if (req->result > 0) |
532 | SvIV_set (sv_result, 0); |
617 | SvIV_set (sv_result, 0); |
533 | /* FALLTHROUGH */ |
618 | /* FALLTHROUGH */ |
534 | |
619 | |
535 | default: |
620 | default: |
… | |
… | |
583 | grp->sv2 = 0; |
668 | grp->sv2 = 0; |
584 | |
669 | |
585 | eio_grp_cancel (grp); |
670 | eio_grp_cancel (grp); |
586 | } |
671 | } |
587 | |
672 | |
588 | static void |
|
|
589 | create_respipe (void) |
673 | static void create_respipe (void) |
590 | { |
674 | { |
591 | if (s_epipe_renew (&respipe)) |
675 | if (s_epipe_renew (&respipe)) |
592 | croak ("IO::AIO: unable to initialize result pipe"); |
676 | croak ("IO::AIO: unable to initialize result pipe"); |
593 | } |
677 | } |
594 | |
678 | |
… | |
… | |
635 | /*****************************************************************************/ |
719 | /*****************************************************************************/ |
636 | |
720 | |
637 | #if !_POSIX_MAPPED_FILES |
721 | #if !_POSIX_MAPPED_FILES |
638 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
722 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
639 | # define munmap(addr,length) (errno = ENOSYS, -1) |
723 | # define munmap(addr,length) (errno = ENOSYS, -1) |
|
|
724 | #endif |
|
|
725 | |
|
|
726 | #if !_POSIX_MEMORY_PROTECTION |
640 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
727 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
641 | # define PROT_NONE 0 |
728 | # define PROT_NONE 0 |
642 | # define PROT_WRITE 0 |
729 | # define PROT_WRITE 0 |
643 | # define MAP_PRIVATE 0 |
730 | # define MAP_PRIVATE 0 |
644 | # define MAP_SHARED 0 |
731 | # define MAP_SHARED 0 |
645 | # define MAP_FIXED 0 |
732 | # define MAP_FIXED 0 |
646 | #endif |
733 | #endif |
647 | |
734 | |
648 | #define MMAP_MAGIC PERL_MAGIC_ext |
735 | #define MMAP_MAGIC PERL_MAGIC_ext |
649 | |
736 | |
650 | static int |
|
|
651 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
737 | static int mmap_free (pTHX_ SV *sv, MAGIC *mg) |
652 | { |
738 | { |
653 | int old_errno = errno; |
739 | int old_errno = errno; |
654 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
740 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
655 | errno = old_errno; |
741 | errno = old_errno; |
656 | |
742 | |
… | |
… | |
672 | 0, 0, 0, 0, mmap_free |
758 | 0, 0, 0, 0, mmap_free |
673 | }; |
759 | }; |
674 | |
760 | |
675 | /*****************************************************************************/ |
761 | /*****************************************************************************/ |
676 | |
762 | |
677 | static SV * |
|
|
678 | get_cb (SV *cb_sv) |
763 | static SV * get_cb (SV *cb_sv) |
679 | { |
764 | { |
680 | SvGETMAGIC (cb_sv); |
765 | SvGETMAGIC (cb_sv); |
681 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
766 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
682 | } |
767 | } |
683 | |
768 | |
… | |
… | |
724 | const_iv (O_RDWR) |
809 | const_iv (O_RDWR) |
725 | const_iv (O_CREAT) |
810 | const_iv (O_CREAT) |
726 | const_iv (O_TRUNC) |
811 | const_iv (O_TRUNC) |
727 | const_iv (O_EXCL) |
812 | const_iv (O_EXCL) |
728 | const_iv (O_APPEND) |
813 | const_iv (O_APPEND) |
729 | #ifndef _WIN32 |
814 | |
|
|
815 | const_iv (O_ASYNC) |
|
|
816 | const_iv (O_DIRECT) |
|
|
817 | const_iv (O_NOATIME) |
|
|
818 | |
|
|
819 | const_iv (O_CLOEXEC) |
|
|
820 | const_iv (O_NOCTTY) |
|
|
821 | const_iv (O_NOFOLLOW) |
|
|
822 | const_iv (O_NONBLOCK) |
|
|
823 | const_iv (O_EXEC) |
|
|
824 | const_iv (O_SEARCH) |
|
|
825 | const_iv (O_DIRECTORY) |
|
|
826 | const_iv (O_DSYNC) |
|
|
827 | const_iv (O_RSYNC) |
|
|
828 | const_iv (O_SYNC) |
|
|
829 | const_iv (O_TTY_INIT) |
|
|
830 | |
730 | const_iv (S_IFIFO) |
831 | const_iv (S_IFIFO) |
731 | #endif |
832 | const_iv (S_IFCHR) |
|
|
833 | const_iv (S_IFBLK) |
|
|
834 | const_iv (S_IFLNK) |
|
|
835 | const_iv (S_IFREG) |
|
|
836 | const_iv (S_IFDIR) |
|
|
837 | const_iv (S_IFWHT) |
|
|
838 | const_iv (S_IFSOCK) |
|
|
839 | const_iv (S_IFMT) |
|
|
840 | |
732 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
841 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
733 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
842 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
734 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
843 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
735 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
844 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
736 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
845 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
… | |
… | |
783 | |
892 | |
784 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
893 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
785 | const_eio (SYNC_FILE_RANGE_WRITE) |
894 | const_eio (SYNC_FILE_RANGE_WRITE) |
786 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
895 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
787 | |
896 | |
|
|
897 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
898 | |
788 | const_eio (READDIR_DENTS) |
899 | const_eio (READDIR_DENTS) |
789 | const_eio (READDIR_DIRS_FIRST) |
900 | const_eio (READDIR_DIRS_FIRST) |
790 | const_eio (READDIR_STAT_ORDER) |
901 | const_eio (READDIR_STAT_ORDER) |
791 | const_eio (READDIR_FOUND_UNKNOWN) |
902 | const_eio (READDIR_FOUND_UNKNOWN) |
792 | |
903 | |
… | |
… | |
818 | /* atfork child called in fifo order, so before eio's handler */ |
929 | /* atfork child called in fifo order, so before eio's handler */ |
819 | X_THREAD_ATFORK (0, 0, atfork_child); |
930 | X_THREAD_ATFORK (0, 0, atfork_child); |
820 | } |
931 | } |
821 | |
932 | |
822 | void |
933 | void |
823 | max_poll_reqs (int nreqs) |
934 | max_poll_reqs (unsigned int nreqs) |
824 | PROTOTYPE: $ |
935 | PROTOTYPE: $ |
825 | CODE: |
936 | CODE: |
826 | eio_set_max_poll_reqs (nreqs); |
937 | eio_set_max_poll_reqs (nreqs); |
827 | |
938 | |
828 | void |
939 | void |
… | |
… | |
830 | PROTOTYPE: $ |
941 | PROTOTYPE: $ |
831 | CODE: |
942 | CODE: |
832 | eio_set_max_poll_time (nseconds); |
943 | eio_set_max_poll_time (nseconds); |
833 | |
944 | |
834 | void |
945 | void |
835 | min_parallel (int nthreads) |
946 | min_parallel (unsigned int nthreads) |
836 | PROTOTYPE: $ |
947 | PROTOTYPE: $ |
837 | CODE: |
948 | CODE: |
838 | eio_set_min_parallel (nthreads); |
949 | eio_set_min_parallel (nthreads); |
839 | |
950 | |
840 | void |
951 | void |
841 | max_parallel (int nthreads) |
952 | max_parallel (unsigned int nthreads) |
842 | PROTOTYPE: $ |
953 | PROTOTYPE: $ |
843 | CODE: |
954 | CODE: |
844 | eio_set_max_parallel (nthreads); |
955 | eio_set_max_parallel (nthreads); |
845 | |
956 | |
846 | void |
957 | void |
847 | max_idle (int nthreads) |
958 | max_idle (unsigned int nthreads) |
848 | PROTOTYPE: $ |
959 | PROTOTYPE: $ |
849 | CODE: |
960 | CODE: |
850 | eio_set_max_idle (nthreads); |
961 | eio_set_max_idle (nthreads); |
851 | |
962 | |
852 | void |
963 | void |
|
|
964 | idle_timeout (unsigned int seconds) |
|
|
965 | PROTOTYPE: $ |
|
|
966 | CODE: |
|
|
967 | eio_set_idle_timeout (seconds); |
|
|
968 | |
|
|
969 | void |
853 | max_outstanding (int maxreqs) |
970 | max_outstanding (unsigned int maxreqs) |
854 | PROTOTYPE: $ |
971 | PROTOTYPE: $ |
855 | CODE: |
972 | CODE: |
856 | max_outstanding = maxreqs; |
973 | max_outstanding = maxreqs; |
857 | |
974 | |
858 | void |
975 | void |
… | |
… | |
903 | |
1020 | |
904 | REQ_SEND (req); |
1021 | REQ_SEND (req); |
905 | } |
1022 | } |
906 | |
1023 | |
907 | void |
1024 | void |
|
|
1025 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
|
|
1026 | PPCODE: |
|
|
1027 | { |
|
|
1028 | int fd = s_fileno_croak (fh, 0); |
|
|
1029 | dREQ; |
|
|
1030 | |
|
|
1031 | req->type = EIO_FALLOCATE; |
|
|
1032 | req->sv1 = newSVsv (fh); |
|
|
1033 | req->int1 = fd; |
|
|
1034 | req->int2 = mode; |
|
|
1035 | req->offs = offset; |
|
|
1036 | req->size = len; |
|
|
1037 | |
|
|
1038 | REQ_SEND (req); |
|
|
1039 | } |
|
|
1040 | |
|
|
1041 | void |
908 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1042 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
909 | PPCODE: |
1043 | PPCODE: |
910 | { |
1044 | { |
911 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
1045 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
912 | int fd = s_fileno_croak (fh, 0); |
1046 | int fd = s_fileno_croak (fh, 0); |
913 | dREQ; |
1047 | dREQ; |
914 | |
1048 | |
915 | if (close_pipe < 0) |
1049 | if (expect_false (close_fd < 0)) |
916 | { |
1050 | { |
|
|
1051 | #ifdef _WIN32 |
|
|
1052 | close_fd = _open_osfhandle (socket (AF_INET, SOCK_STREAM, 0), 0); |
|
|
1053 | #else |
917 | int pipefd [2]; |
1054 | int pipefd [2]; |
918 | |
1055 | |
919 | if (pipe (pipefd) < 0 |
1056 | if (pipe (pipefd) < 0 |
920 | || close (pipefd [1]) < 0 |
1057 | || close (pipefd [1]) < 0 |
921 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) |
1058 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) |
922 | abort (); /*D*/ |
1059 | abort (); /*D*/ |
923 | |
1060 | |
924 | close_pipe = pipefd [0]; |
1061 | close_fd = pipefd [0]; |
|
|
1062 | #endif |
925 | } |
1063 | } |
926 | |
1064 | |
927 | req->type = EIO_DUP2; |
1065 | req->type = EIO_DUP2; |
928 | req->int1 = close_pipe; |
1066 | req->int1 = close_fd; |
929 | req->sv2 = newSVsv (fh); |
1067 | req->sv2 = newSVsv (fh); |
930 | req->int2 = fd; |
1068 | req->int2 = fd; |
931 | |
1069 | |
932 | REQ_SEND (req); |
1070 | REQ_SEND (req); |
933 | } |
1071 | } |
… | |
… | |
985 | } |
1123 | } |
986 | } |
1124 | } |
987 | |
1125 | |
988 | void |
1126 | void |
989 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
1127 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
|
|
1128 | ALIAS: |
|
|
1129 | aio_readlink = EIO_READLINK |
|
|
1130 | aio_realpath = EIO_REALPATH |
990 | PPCODE: |
1131 | PPCODE: |
991 | { |
1132 | { |
992 | SV *data; |
1133 | SV *data; |
993 | dREQ; |
1134 | dREQ; |
994 | |
1135 | |
995 | req->type = EIO_READLINK; |
1136 | req->type = ix; |
996 | req->sv1 = newSVsv (path); |
1137 | req->sv1 = newSVsv (path); |
997 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1138 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
998 | |
1139 | |
999 | REQ_SEND; |
1140 | REQ_SEND; |
1000 | } |
1141 | } |
… | |
… | |
1057 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
1198 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
1058 | } |
1199 | } |
1059 | |
1200 | |
1060 | REQ_SEND; |
1201 | REQ_SEND; |
1061 | } |
1202 | } |
|
|
1203 | |
|
|
1204 | UV |
|
|
1205 | major (UV dev) |
|
|
1206 | ALIAS: |
|
|
1207 | minor = 1 |
|
|
1208 | CODE: |
|
|
1209 | RETVAL = ix ? major (dev) : minor (dev); |
|
|
1210 | OUTPUT: |
|
|
1211 | RETVAL |
|
|
1212 | |
|
|
1213 | UV |
|
|
1214 | makedev (UV maj, UV min) |
|
|
1215 | CODE: |
|
|
1216 | RETVAL = makedev (maj, min); |
|
|
1217 | OUTPUT: |
|
|
1218 | RETVAL |
1062 | |
1219 | |
1063 | void |
1220 | void |
1064 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1221 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1065 | PPCODE: |
1222 | PPCODE: |
1066 | { |
1223 | { |
… | |
… | |
1522 | if (!SvOK (length) || len + offset > svlen) |
1679 | if (!SvOK (length) || len + offset > svlen) |
1523 | len = svlen - offset; |
1680 | len = svlen - offset; |
1524 | |
1681 | |
1525 | addr = (void *)(((intptr_t)addr) + offset); |
1682 | addr = (void *)(((intptr_t)addr) + offset); |
1526 | eio_page_align (&addr, &len); |
1683 | eio_page_align (&addr, &len); |
1527 | #if _POSIX_MEMLOCK |
1684 | #if _POSIX_MEMLOCK_RANGE |
1528 | RETVAL = munlock (addr, len); |
1685 | RETVAL = munlock (addr, len); |
1529 | #else |
1686 | #else |
1530 | RETVAL = ((errno = ENOSYS), -1); |
1687 | RETVAL = ((errno = ENOSYS), -1); |
1531 | #endif |
1688 | #endif |
1532 | } |
1689 | } |