… | |
… | |
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" |
|
|
125 | |
|
|
126 | /* Linux/others */ |
|
|
127 | #ifndef O_ASYNC |
|
|
128 | # define O_ASYNC 0 |
|
|
129 | #endif |
|
|
130 | #ifndef O_DIRECT |
|
|
131 | # define O_DIRECT 0 |
|
|
132 | #endif |
|
|
133 | #ifndef O_NOATIME |
|
|
134 | # define O_NOATIME 0 |
|
|
135 | #endif |
|
|
136 | |
|
|
137 | /* POSIX */ |
|
|
138 | #ifndef O_CLOEXEC |
|
|
139 | # define O_CLOEXEC 0 |
|
|
140 | #endif |
|
|
141 | #ifndef O_NOFOLLOW |
|
|
142 | # define O_NOFOLLOW 0 |
|
|
143 | #endif |
|
|
144 | #ifndef O_NOCTTY |
|
|
145 | # define O_NOCTTY 0 |
|
|
146 | #endif |
|
|
147 | #ifndef O_NONBLOCK |
|
|
148 | # define O_NONBLOCK 0 |
|
|
149 | #endif |
|
|
150 | #ifndef O_EXEC |
|
|
151 | # define O_EXEC 0 |
|
|
152 | #endif |
|
|
153 | #ifndef O_SEARCH |
|
|
154 | # define O_SEARCH 0 |
|
|
155 | #endif |
|
|
156 | #ifndef O_DIRECTORY |
|
|
157 | # define O_DIRECTORY 0 |
|
|
158 | #endif |
|
|
159 | #ifndef O_DSYNC |
|
|
160 | # define O_DSYNC 0 |
|
|
161 | #endif |
|
|
162 | #ifndef O_RSYNC |
|
|
163 | # define O_RSYNC 0 |
|
|
164 | #endif |
|
|
165 | #ifndef O_SYNC |
|
|
166 | # define O_SYNC 0 |
|
|
167 | #endif |
|
|
168 | #ifndef O_TTY_INIT |
|
|
169 | # define O_TTY_INIT 0 |
|
|
170 | #endif |
124 | |
171 | |
125 | #ifndef POSIX_FADV_NORMAL |
172 | #ifndef POSIX_FADV_NORMAL |
126 | # define POSIX_FADV_NORMAL 0 |
173 | # define POSIX_FADV_NORMAL 0 |
127 | # define NO_FADVISE 1 |
|
|
128 | #endif |
174 | #endif |
129 | #ifndef POSIX_FADV_SEQUENTIAL |
175 | #ifndef POSIX_FADV_SEQUENTIAL |
130 | # define POSIX_FADV_SEQUENTIAL 0 |
176 | # define POSIX_FADV_SEQUENTIAL 0 |
131 | #endif |
177 | #endif |
132 | #ifndef POSIX_FADV_RANDOM |
178 | #ifndef POSIX_FADV_RANDOM |
… | |
… | |
140 | #endif |
186 | #endif |
141 | #ifndef POSIX_FADV_DONTNEED |
187 | #ifndef POSIX_FADV_DONTNEED |
142 | # define POSIX_FADV_DONTNEED 0 |
188 | # define POSIX_FADV_DONTNEED 0 |
143 | #endif |
189 | #endif |
144 | |
190 | |
145 | #if _XOPEN_SOURCE < 600 || NO_FADVISE |
191 | #if !HAVE_POSIX_FADVISE |
146 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
192 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
147 | #endif |
193 | #endif |
148 | |
194 | |
149 | #ifndef POSIX_MADV_NORMAL |
195 | #ifndef POSIX_MADV_NORMAL |
150 | # define POSIX_MADV_NORMAL 0 |
196 | # define POSIX_MADV_NORMAL 0 |
151 | # define NO_MADVISE 1 |
|
|
152 | #endif |
197 | #endif |
153 | #ifndef POSIX_MADV_SEQUENTIAL |
198 | #ifndef POSIX_MADV_SEQUENTIAL |
154 | # define POSIX_MADV_SEQUENTIAL 0 |
199 | # define POSIX_MADV_SEQUENTIAL 0 |
155 | #endif |
200 | #endif |
156 | #ifndef POSIX_MADV_RANDOM |
201 | #ifndef POSIX_MADV_RANDOM |
… | |
… | |
161 | #endif |
206 | #endif |
162 | #ifndef POSIX_MADV_DONTNEED |
207 | #ifndef POSIX_MADV_DONTNEED |
163 | # define POSIX_MADV_DONTNEED 0 |
208 | # define POSIX_MADV_DONTNEED 0 |
164 | #endif |
209 | #endif |
165 | |
210 | |
166 | #if _XOPEN_SOURCE < 600 || NO_MADVISE |
211 | #if !HAVE_POSIX_MADVISE |
167 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
212 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
168 | #endif |
213 | #endif |
169 | |
214 | |
170 | #ifndef PROT_NONE |
215 | #ifndef PROT_NONE |
171 | # define PROT_NONE 0 |
216 | # define PROT_NONE 0 |
… | |
… | |
207 | #ifndef ST_NODIRATIME |
252 | #ifndef ST_NODIRATIME |
208 | # define ST_NODIRATIME 0 |
253 | # define ST_NODIRATIME 0 |
209 | #endif |
254 | #endif |
210 | #ifndef ST_RELATIME |
255 | #ifndef ST_RELATIME |
211 | # define ST_RELATIME 0 |
256 | # define ST_RELATIME 0 |
|
|
257 | #endif |
|
|
258 | |
|
|
259 | #ifndef S_IFIFO |
|
|
260 | # define S_IFIFO 0 |
|
|
261 | #endif |
|
|
262 | #ifndef S_IFCHR |
|
|
263 | # define S_IFCHR 0 |
|
|
264 | #endif |
|
|
265 | #ifndef S_IFBLK |
|
|
266 | # define S_IFBLK 0 |
|
|
267 | #endif |
|
|
268 | #ifndef S_IFLNK |
|
|
269 | # define S_IFLNK 0 |
|
|
270 | #endif |
|
|
271 | #ifndef S_IFREG |
|
|
272 | # define S_IFREG 0 |
|
|
273 | #endif |
|
|
274 | #ifndef S_IFDIR |
|
|
275 | # define S_IFDIR 0 |
|
|
276 | #endif |
|
|
277 | #ifndef S_IFWHT |
|
|
278 | # define S_IFWHT 0 |
|
|
279 | #endif |
|
|
280 | #ifndef S_IFSOCK |
|
|
281 | # define S_IFSOCK 0 |
212 | #endif |
282 | #endif |
213 | |
283 | |
214 | #ifndef MAP_ANONYMOUS |
284 | #ifndef MAP_ANONYMOUS |
215 | # ifdef MAP_ANON |
285 | # ifdef MAP_ANON |
216 | # define MAP_ANONYMOUS MAP_ANON |
286 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
230 | #ifndef MAP_POPULATE |
300 | #ifndef MAP_POPULATE |
231 | # define MAP_POPULATE 0 |
301 | # define MAP_POPULATE 0 |
232 | #endif |
302 | #endif |
233 | #ifndef MAP_NONBLOCK |
303 | #ifndef MAP_NONBLOCK |
234 | # define MAP_NONBLOCK 0 |
304 | # define MAP_NONBLOCK 0 |
|
|
305 | #endif |
|
|
306 | |
|
|
307 | #ifndef makedev |
|
|
308 | # define makedev(maj,min) (((maj) << 8) | (min)) |
|
|
309 | #endif |
|
|
310 | #ifndef major |
|
|
311 | # define major(dev) ((dev) >> 8) |
|
|
312 | #endif |
|
|
313 | #ifndef minor |
|
|
314 | # define minor(dev) ((dev) & 0xff) |
235 | #endif |
315 | #endif |
236 | |
316 | |
237 | #ifndef PAGESIZE |
317 | #ifndef PAGESIZE |
238 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
318 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
239 | #endif |
319 | #endif |
… | |
… | |
354 | /* do not recreate the result IV from scratch each time */ |
434 | /* do not recreate the result IV from scratch each time */ |
355 | if (expect_true (sv_result_cache)) |
435 | if (expect_true (sv_result_cache)) |
356 | { |
436 | { |
357 | sv_result = sv_result_cache; sv_result_cache = 0; |
437 | sv_result = sv_result_cache; sv_result_cache = 0; |
358 | SvIV_set (sv_result, req->result); |
438 | SvIV_set (sv_result, req->result); |
|
|
439 | SvIOK_only (sv_result); |
359 | } |
440 | } |
360 | else |
441 | else |
361 | { |
442 | { |
362 | sv_result = newSViv (req->result); |
443 | sv_result = newSViv (req->result); |
363 | SvREADONLY_on (sv_result); |
444 | SvREADONLY_on (sv_result); |
… | |
… | |
504 | case EIO_NOP: |
585 | case EIO_NOP: |
505 | case EIO_BUSY: |
586 | case EIO_BUSY: |
506 | break; |
587 | break; |
507 | |
588 | |
508 | case EIO_READLINK: |
589 | case EIO_READLINK: |
|
|
590 | case EIO_REALPATH: |
509 | if (req->result > 0) |
591 | if (req->result > 0) |
510 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
592 | PUSHs (sv_2mortal (newSVpvn (req->ptr2, req->result))); |
511 | break; |
593 | break; |
512 | |
594 | |
513 | case EIO_STAT: |
595 | case EIO_STAT: |
… | |
… | |
527 | SvSETMAGIC (req->sv2); |
609 | SvSETMAGIC (req->sv2); |
528 | PUSHs (sv_result); |
610 | PUSHs (sv_result); |
529 | } |
611 | } |
530 | break; |
612 | break; |
531 | |
613 | |
532 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ |
614 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ |
533 | if (req->result > 0) |
615 | if (req->result > 0) |
534 | SvIV_set (sv_result, 0); |
616 | SvIV_set (sv_result, 0); |
535 | /* FALLTHROUGH */ |
617 | /* FALLTHROUGH */ |
536 | |
618 | |
537 | default: |
619 | default: |
… | |
… | |
585 | grp->sv2 = 0; |
667 | grp->sv2 = 0; |
586 | |
668 | |
587 | eio_grp_cancel (grp); |
669 | eio_grp_cancel (grp); |
588 | } |
670 | } |
589 | |
671 | |
590 | static void |
|
|
591 | create_respipe (void) |
672 | static void create_respipe (void) |
592 | { |
673 | { |
593 | if (s_epipe_renew (&respipe)) |
674 | if (s_epipe_renew (&respipe)) |
594 | croak ("IO::AIO: unable to initialize result pipe"); |
675 | croak ("IO::AIO: unable to initialize result pipe"); |
595 | } |
676 | } |
596 | |
677 | |
… | |
… | |
637 | /*****************************************************************************/ |
718 | /*****************************************************************************/ |
638 | |
719 | |
639 | #if !_POSIX_MAPPED_FILES |
720 | #if !_POSIX_MAPPED_FILES |
640 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
721 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
641 | # define munmap(addr,length) (errno = ENOSYS, -1) |
722 | # define munmap(addr,length) (errno = ENOSYS, -1) |
|
|
723 | #endif |
|
|
724 | |
|
|
725 | #if !_POSIX_MEMORY_PROTECTION |
642 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
726 | # define mprotect(addr,len,prot) (errno = ENOSYS, -1) |
|
|
727 | # define PROT_NONE 0 |
|
|
728 | # define PROT_WRITE 0 |
|
|
729 | # define MAP_PRIVATE 0 |
|
|
730 | # define MAP_SHARED 0 |
|
|
731 | # define MAP_FIXED 0 |
643 | #endif |
732 | #endif |
644 | |
733 | |
645 | #define MMAP_MAGIC PERL_MAGIC_ext |
734 | #define MMAP_MAGIC PERL_MAGIC_ext |
646 | |
735 | |
647 | static int |
|
|
648 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
736 | static int mmap_free (pTHX_ SV *sv, MAGIC *mg) |
649 | { |
737 | { |
650 | int old_errno = errno; |
738 | int old_errno = errno; |
651 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
739 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
652 | errno = old_errno; |
740 | errno = old_errno; |
653 | |
741 | |
… | |
… | |
669 | 0, 0, 0, 0, mmap_free |
757 | 0, 0, 0, 0, mmap_free |
670 | }; |
758 | }; |
671 | |
759 | |
672 | /*****************************************************************************/ |
760 | /*****************************************************************************/ |
673 | |
761 | |
674 | static SV * |
|
|
675 | get_cb (SV *cb_sv) |
762 | static SV * get_cb (SV *cb_sv) |
676 | { |
763 | { |
677 | SvGETMAGIC (cb_sv); |
764 | SvGETMAGIC (cb_sv); |
678 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
765 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
679 | } |
766 | } |
680 | |
767 | |
… | |
… | |
721 | const_iv (O_RDWR) |
808 | const_iv (O_RDWR) |
722 | const_iv (O_CREAT) |
809 | const_iv (O_CREAT) |
723 | const_iv (O_TRUNC) |
810 | const_iv (O_TRUNC) |
724 | const_iv (O_EXCL) |
811 | const_iv (O_EXCL) |
725 | const_iv (O_APPEND) |
812 | const_iv (O_APPEND) |
726 | #ifndef _WIN32 |
813 | |
|
|
814 | const_iv (O_ASYNC) |
|
|
815 | const_iv (O_DIRECT) |
|
|
816 | const_iv (O_NOATIME) |
|
|
817 | |
|
|
818 | const_iv (O_CLOEXEC) |
|
|
819 | const_iv (O_NOCTTY) |
|
|
820 | const_iv (O_NOFOLLOW) |
|
|
821 | const_iv (O_NONBLOCK) |
|
|
822 | const_iv (O_EXEC) |
|
|
823 | const_iv (O_SEARCH) |
|
|
824 | const_iv (O_DIRECTORY) |
|
|
825 | const_iv (O_DSYNC) |
|
|
826 | const_iv (O_RSYNC) |
|
|
827 | const_iv (O_SYNC) |
|
|
828 | const_iv (O_TTY_INIT) |
|
|
829 | |
727 | const_iv (S_IFIFO) |
830 | const_iv (S_IFIFO) |
728 | #endif |
831 | const_iv (S_IFCHR) |
|
|
832 | const_iv (S_IFBLK) |
|
|
833 | const_iv (S_IFLNK) |
|
|
834 | const_iv (S_IFREG) |
|
|
835 | const_iv (S_IFDIR) |
|
|
836 | const_iv (S_IFWHT) |
|
|
837 | const_iv (S_IFSOCK) |
|
|
838 | const_iv (S_IFMT) |
|
|
839 | |
729 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
840 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
730 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
841 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
731 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
842 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
732 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
843 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
733 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
844 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
… | |
… | |
780 | |
891 | |
781 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
892 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
782 | const_eio (SYNC_FILE_RANGE_WRITE) |
893 | const_eio (SYNC_FILE_RANGE_WRITE) |
783 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
894 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
784 | |
895 | |
|
|
896 | const_eio (FALLOC_FL_KEEP_SIZE) |
|
|
897 | |
785 | const_eio (READDIR_DENTS) |
898 | const_eio (READDIR_DENTS) |
786 | const_eio (READDIR_DIRS_FIRST) |
899 | const_eio (READDIR_DIRS_FIRST) |
787 | const_eio (READDIR_STAT_ORDER) |
900 | const_eio (READDIR_STAT_ORDER) |
788 | const_eio (READDIR_FOUND_UNKNOWN) |
901 | const_eio (READDIR_FOUND_UNKNOWN) |
789 | |
902 | |
… | |
… | |
815 | /* atfork child called in fifo order, so before eio's handler */ |
928 | /* atfork child called in fifo order, so before eio's handler */ |
816 | X_THREAD_ATFORK (0, 0, atfork_child); |
929 | X_THREAD_ATFORK (0, 0, atfork_child); |
817 | } |
930 | } |
818 | |
931 | |
819 | void |
932 | void |
820 | max_poll_reqs (int nreqs) |
933 | max_poll_reqs (unsigned int nreqs) |
821 | PROTOTYPE: $ |
934 | PROTOTYPE: $ |
822 | CODE: |
935 | CODE: |
823 | eio_set_max_poll_reqs (nreqs); |
936 | eio_set_max_poll_reqs (nreqs); |
824 | |
937 | |
825 | void |
938 | void |
… | |
… | |
827 | PROTOTYPE: $ |
940 | PROTOTYPE: $ |
828 | CODE: |
941 | CODE: |
829 | eio_set_max_poll_time (nseconds); |
942 | eio_set_max_poll_time (nseconds); |
830 | |
943 | |
831 | void |
944 | void |
832 | min_parallel (int nthreads) |
945 | min_parallel (unsigned int nthreads) |
833 | PROTOTYPE: $ |
946 | PROTOTYPE: $ |
834 | CODE: |
947 | CODE: |
835 | eio_set_min_parallel (nthreads); |
948 | eio_set_min_parallel (nthreads); |
836 | |
949 | |
837 | void |
950 | void |
838 | max_parallel (int nthreads) |
951 | max_parallel (unsigned int nthreads) |
839 | PROTOTYPE: $ |
952 | PROTOTYPE: $ |
840 | CODE: |
953 | CODE: |
841 | eio_set_max_parallel (nthreads); |
954 | eio_set_max_parallel (nthreads); |
842 | |
955 | |
843 | void |
956 | void |
844 | max_idle (int nthreads) |
957 | max_idle (unsigned int nthreads) |
845 | PROTOTYPE: $ |
958 | PROTOTYPE: $ |
846 | CODE: |
959 | CODE: |
847 | eio_set_max_idle (nthreads); |
960 | eio_set_max_idle (nthreads); |
848 | |
961 | |
849 | void |
962 | void |
|
|
963 | idle_timeout (unsigned int seconds) |
|
|
964 | PROTOTYPE: $ |
|
|
965 | CODE: |
|
|
966 | eio_set_idle_timeout (seconds); |
|
|
967 | |
|
|
968 | void |
850 | max_outstanding (int maxreqs) |
969 | max_outstanding (unsigned int maxreqs) |
851 | PROTOTYPE: $ |
970 | PROTOTYPE: $ |
852 | CODE: |
971 | CODE: |
853 | max_outstanding = maxreqs; |
972 | max_outstanding = maxreqs; |
854 | |
973 | |
855 | void |
974 | void |
… | |
… | |
895 | req->sv1 = newSVsv (fh); |
1014 | req->sv1 = newSVsv (fh); |
896 | req->int1 = fd; |
1015 | req->int1 = fd; |
897 | req->offs = offset; |
1016 | req->offs = offset; |
898 | req->size = nbytes; |
1017 | req->size = nbytes; |
899 | req->int2 = flags; |
1018 | req->int2 = flags; |
|
|
1019 | |
|
|
1020 | REQ_SEND (req); |
|
|
1021 | } |
|
|
1022 | |
|
|
1023 | void |
|
|
1024 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
|
|
1025 | PPCODE: |
|
|
1026 | { |
|
|
1027 | int fd = s_fileno_croak (fh, 0); |
|
|
1028 | dREQ; |
|
|
1029 | |
|
|
1030 | req->type = EIO_FALLOCATE; |
|
|
1031 | req->sv1 = newSVsv (fh); |
|
|
1032 | req->int1 = fd; |
|
|
1033 | req->int2 = mode; |
|
|
1034 | req->offs = offset; |
|
|
1035 | req->size = len; |
900 | |
1036 | |
901 | REQ_SEND (req); |
1037 | REQ_SEND (req); |
902 | } |
1038 | } |
903 | |
1039 | |
904 | void |
1040 | void |
… | |
… | |
982 | } |
1118 | } |
983 | } |
1119 | } |
984 | |
1120 | |
985 | void |
1121 | void |
986 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
1122 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
|
|
1123 | ALIAS: |
|
|
1124 | aio_readlink = EIO_READLINK |
|
|
1125 | aio_realpath = EIO_REALPATH |
987 | PPCODE: |
1126 | PPCODE: |
988 | { |
1127 | { |
989 | SV *data; |
1128 | SV *data; |
990 | dREQ; |
1129 | dREQ; |
991 | |
1130 | |
992 | req->type = EIO_READLINK; |
1131 | req->type = ix; |
993 | req->sv1 = newSVsv (path); |
1132 | req->sv1 = newSVsv (path); |
994 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1133 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
995 | |
1134 | |
996 | REQ_SEND; |
1135 | REQ_SEND; |
997 | } |
1136 | } |
… | |
… | |
1055 | } |
1194 | } |
1056 | |
1195 | |
1057 | REQ_SEND; |
1196 | REQ_SEND; |
1058 | } |
1197 | } |
1059 | |
1198 | |
|
|
1199 | UV |
|
|
1200 | major (UV dev) |
|
|
1201 | ALIAS: |
|
|
1202 | minor = 1 |
|
|
1203 | CODE: |
|
|
1204 | RETVAL = ix ? major (dev) : minor (dev); |
|
|
1205 | OUTPUT: |
|
|
1206 | RETVAL |
|
|
1207 | |
|
|
1208 | UV |
|
|
1209 | makedev (UV maj, UV min) |
|
|
1210 | CODE: |
|
|
1211 | RETVAL = makedev (maj, min); |
|
|
1212 | OUTPUT: |
|
|
1213 | RETVAL |
|
|
1214 | |
1060 | void |
1215 | void |
1061 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1216 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1062 | PPCODE: |
1217 | PPCODE: |
1063 | { |
1218 | { |
1064 | dREQ; |
1219 | dREQ; |
… | |
… | |
1257 | |
1412 | |
1258 | void |
1413 | void |
1259 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
1414 | aio_mlock (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, SV *callback=&PL_sv_undef) |
1260 | PPCODE: |
1415 | PPCODE: |
1261 | { |
1416 | { |
1262 | |
|
|
1263 | STRLEN svlen; |
1417 | STRLEN svlen; |
1264 | char *svptr = SvPVbyte (data, svlen); |
1418 | char *svptr = SvPVbyte (data, svlen); |
1265 | UV len = SvUV (length); |
1419 | UV len = SvUV (length); |
1266 | |
1420 | |
1267 | if (offset < 0) |
1421 | if (offset < 0) |
… | |
… | |
1520 | if (!SvOK (length) || len + offset > svlen) |
1674 | if (!SvOK (length) || len + offset > svlen) |
1521 | len = svlen - offset; |
1675 | len = svlen - offset; |
1522 | |
1676 | |
1523 | addr = (void *)(((intptr_t)addr) + offset); |
1677 | addr = (void *)(((intptr_t)addr) + offset); |
1524 | eio_page_align (&addr, &len); |
1678 | eio_page_align (&addr, &len); |
1525 | #if _POSIX_MEMLOCK |
1679 | #if _POSIX_MEMLOCK_RANGE |
1526 | RETVAL = munlock (addr, len); |
1680 | RETVAL = munlock (addr, len); |
1527 | #else |
1681 | #else |
1528 | RETVAL = ((errno = ENOSYS), -1); |
1682 | RETVAL = ((errno = ENOSYS), -1); |
1529 | #endif |
1683 | #endif |
1530 | } |
1684 | } |