… | |
… | |
121 | #define EIO_NO_WRAPPERS 1 |
121 | #define EIO_NO_WRAPPERS 1 |
122 | |
122 | |
123 | #include "libeio/config.h" |
123 | #include "libeio/config.h" |
124 | #include "libeio/eio.h" |
124 | #include "libeio/eio.h" |
125 | |
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 |
|
|
171 | |
126 | #ifndef POSIX_FADV_NORMAL |
172 | #ifndef POSIX_FADV_NORMAL |
127 | # define POSIX_FADV_NORMAL 0 |
173 | # define POSIX_FADV_NORMAL 0 |
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 |
… | |
… | |
206 | #ifndef ST_NODIRATIME |
252 | #ifndef ST_NODIRATIME |
207 | # define ST_NODIRATIME 0 |
253 | # define ST_NODIRATIME 0 |
208 | #endif |
254 | #endif |
209 | #ifndef ST_RELATIME |
255 | #ifndef ST_RELATIME |
210 | # 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 |
211 | #endif |
282 | #endif |
212 | |
283 | |
213 | #ifndef MAP_ANONYMOUS |
284 | #ifndef MAP_ANONYMOUS |
214 | # ifdef MAP_ANON |
285 | # ifdef MAP_ANON |
215 | # define MAP_ANONYMOUS MAP_ANON |
286 | # define MAP_ANONYMOUS MAP_ANON |
… | |
… | |
229 | #ifndef MAP_POPULATE |
300 | #ifndef MAP_POPULATE |
230 | # define MAP_POPULATE 0 |
301 | # define MAP_POPULATE 0 |
231 | #endif |
302 | #endif |
232 | #ifndef MAP_NONBLOCK |
303 | #ifndef MAP_NONBLOCK |
233 | # 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) |
234 | #endif |
315 | #endif |
235 | |
316 | |
236 | #ifndef PAGESIZE |
317 | #ifndef PAGESIZE |
237 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
318 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
238 | #endif |
319 | #endif |
… | |
… | |
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: |
… | |
… | |
729 | const_iv (O_RDWR) |
811 | const_iv (O_RDWR) |
730 | const_iv (O_CREAT) |
812 | const_iv (O_CREAT) |
731 | const_iv (O_TRUNC) |
813 | const_iv (O_TRUNC) |
732 | const_iv (O_EXCL) |
814 | const_iv (O_EXCL) |
733 | const_iv (O_APPEND) |
815 | const_iv (O_APPEND) |
734 | #ifndef _WIN32 |
816 | |
|
|
817 | const_iv (O_ASYNC) |
|
|
818 | const_iv (O_DIRECT) |
|
|
819 | const_iv (O_NOATIME) |
|
|
820 | |
|
|
821 | const_iv (O_CLOEXEC) |
|
|
822 | const_iv (O_NOCTTY) |
|
|
823 | const_iv (O_NOFOLLOW) |
|
|
824 | const_iv (O_NONBLOCK) |
|
|
825 | const_iv (O_EXEC) |
|
|
826 | const_iv (O_SEARCH) |
|
|
827 | const_iv (O_DIRECTORY) |
|
|
828 | const_iv (O_DSYNC) |
|
|
829 | const_iv (O_RSYNC) |
|
|
830 | const_iv (O_SYNC) |
|
|
831 | const_iv (O_TTY_INIT) |
|
|
832 | |
735 | const_iv (S_IFIFO) |
833 | const_iv (S_IFIFO) |
736 | #endif |
834 | const_iv (S_IFCHR) |
|
|
835 | const_iv (S_IFBLK) |
|
|
836 | const_iv (S_IFLNK) |
|
|
837 | const_iv (S_IFREG) |
|
|
838 | const_iv (S_IFDIR) |
|
|
839 | const_iv (S_IFWHT) |
|
|
840 | const_iv (S_IFSOCK) |
|
|
841 | const_iv (S_IFMT) |
|
|
842 | |
737 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
843 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
738 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
844 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
739 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
845 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
740 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
846 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
741 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
847 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
… | |
… | |
823 | /* atfork child called in fifo order, so before eio's handler */ |
929 | /* atfork child called in fifo order, so before eio's handler */ |
824 | X_THREAD_ATFORK (0, 0, atfork_child); |
930 | X_THREAD_ATFORK (0, 0, atfork_child); |
825 | } |
931 | } |
826 | |
932 | |
827 | void |
933 | void |
828 | max_poll_reqs (int nreqs) |
934 | max_poll_reqs (unsigned int nreqs) |
829 | PROTOTYPE: $ |
935 | PROTOTYPE: $ |
830 | CODE: |
936 | CODE: |
831 | eio_set_max_poll_reqs (nreqs); |
937 | eio_set_max_poll_reqs (nreqs); |
832 | |
938 | |
833 | void |
939 | void |
… | |
… | |
835 | PROTOTYPE: $ |
941 | PROTOTYPE: $ |
836 | CODE: |
942 | CODE: |
837 | eio_set_max_poll_time (nseconds); |
943 | eio_set_max_poll_time (nseconds); |
838 | |
944 | |
839 | void |
945 | void |
840 | min_parallel (int nthreads) |
946 | min_parallel (unsigned int nthreads) |
841 | PROTOTYPE: $ |
947 | PROTOTYPE: $ |
842 | CODE: |
948 | CODE: |
843 | eio_set_min_parallel (nthreads); |
949 | eio_set_min_parallel (nthreads); |
844 | |
950 | |
845 | void |
951 | void |
846 | max_parallel (int nthreads) |
952 | max_parallel (unsigned int nthreads) |
847 | PROTOTYPE: $ |
953 | PROTOTYPE: $ |
848 | CODE: |
954 | CODE: |
849 | eio_set_max_parallel (nthreads); |
955 | eio_set_max_parallel (nthreads); |
850 | |
956 | |
851 | void |
957 | void |
852 | max_idle (int nthreads) |
958 | max_idle (unsigned int nthreads) |
853 | PROTOTYPE: $ |
959 | PROTOTYPE: $ |
854 | CODE: |
960 | CODE: |
855 | eio_set_max_idle (nthreads); |
961 | eio_set_max_idle (nthreads); |
856 | |
962 | |
857 | void |
963 | void |
|
|
964 | idle_timeout (unsigned int seconds) |
|
|
965 | PROTOTYPE: $ |
|
|
966 | CODE: |
|
|
967 | eio_set_idle_timeout (seconds); |
|
|
968 | |
|
|
969 | void |
858 | max_outstanding (int maxreqs) |
970 | max_outstanding (unsigned int maxreqs) |
859 | PROTOTYPE: $ |
971 | PROTOTYPE: $ |
860 | CODE: |
972 | CODE: |
861 | max_outstanding = maxreqs; |
973 | max_outstanding = maxreqs; |
862 | |
974 | |
863 | void |
975 | void |
… | |
… | |
990 | } |
1102 | } |
991 | } |
1103 | } |
992 | |
1104 | |
993 | void |
1105 | void |
994 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
1106 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
|
|
1107 | ALIAS: |
|
|
1108 | aio_readlink = EIO_READLINK |
|
|
1109 | aio_realpath = EIO_REALPATH |
995 | PPCODE: |
1110 | PPCODE: |
996 | { |
1111 | { |
997 | SV *data; |
1112 | SV *data; |
998 | dREQ; |
1113 | dREQ; |
999 | |
1114 | |
1000 | req->type = EIO_READLINK; |
1115 | req->type = ix; |
1001 | req->sv1 = newSVsv (path); |
1116 | req->sv1 = newSVsv (path); |
1002 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1117 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1003 | |
1118 | |
1004 | REQ_SEND; |
1119 | REQ_SEND; |
1005 | } |
1120 | } |
… | |
… | |
1063 | } |
1178 | } |
1064 | |
1179 | |
1065 | REQ_SEND; |
1180 | REQ_SEND; |
1066 | } |
1181 | } |
1067 | |
1182 | |
|
|
1183 | UV |
|
|
1184 | major (UV dev) |
|
|
1185 | ALIAS: |
|
|
1186 | minor = 1 |
|
|
1187 | CODE: |
|
|
1188 | RETVAL = ix ? major (dev) : minor (dev); |
|
|
1189 | OUTPUT: |
|
|
1190 | RETVAL |
|
|
1191 | |
|
|
1192 | UV |
|
|
1193 | makedev (UV maj, UV min) |
|
|
1194 | CODE: |
|
|
1195 | RETVAL = makedev (maj, min); |
|
|
1196 | OUTPUT: |
|
|
1197 | RETVAL |
|
|
1198 | |
1068 | void |
1199 | void |
1069 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1200 | aio_utime (SV8 *fh_or_path, SV *atime, SV *mtime, SV *callback=&PL_sv_undef) |
1070 | PPCODE: |
1201 | PPCODE: |
1071 | { |
1202 | { |
1072 | dREQ; |
1203 | dREQ; |