… | |
… | |
19 | |
19 | |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
20 | #if _POSIX_MEMLOCK || _POSIX_MEMLOCK_RANGE || _POSIX_MAPPED_FILES |
21 | # include <sys/mman.h> |
21 | # include <sys/mman.h> |
22 | #endif |
22 | #endif |
23 | |
23 | |
|
|
24 | #if __linux__ |
|
|
25 | # include <linux/fs.h> |
|
|
26 | # ifdef FS_IOC_FIEMAP |
|
|
27 | # include <linux/fiemap.h> |
|
|
28 | # define HAVE_FIEMAP 1 |
|
|
29 | # endif |
|
|
30 | #endif |
|
|
31 | |
24 | /* perl namespace pollution */ |
32 | /* perl namespace pollution */ |
25 | #undef VERSION |
33 | #undef VERSION |
26 | |
|
|
27 | #ifdef _WIN32 |
|
|
28 | |
|
|
29 | # define EIO_STRUCT_DIRENT Direntry_t |
|
|
30 | # undef malloc |
|
|
31 | # undef free |
|
|
32 | |
|
|
33 | // perl overrides all those nice win32 functions |
|
|
34 | # undef open |
|
|
35 | # undef read |
|
|
36 | # undef write |
|
|
37 | # undef send |
|
|
38 | # undef recv |
|
|
39 | # undef stat |
|
|
40 | # undef fstat |
|
|
41 | # define lstat stat |
|
|
42 | # undef truncate |
|
|
43 | # undef ftruncate |
|
|
44 | # undef open |
|
|
45 | # undef close |
|
|
46 | # undef unlink |
|
|
47 | # undef rmdir |
|
|
48 | # undef rename |
|
|
49 | # undef lseek |
|
|
50 | |
|
|
51 | # define opendir(fd) (errno = ENOSYS, 0) |
|
|
52 | # define readdir(fd) (errno = ENOSYS, -1) |
|
|
53 | # define closedir(fd) (errno = ENOSYS, -1) |
|
|
54 | |
|
|
55 | #else |
|
|
56 | |
|
|
57 | # include <sys/time.h> |
|
|
58 | # include <sys/select.h> |
|
|
59 | # include <unistd.h> |
|
|
60 | # include <utime.h> |
|
|
61 | # include <signal.h> |
|
|
62 | # define EIO_STRUCT_DIRENT struct dirent |
|
|
63 | |
|
|
64 | #endif |
|
|
65 | |
34 | |
66 | /* perl stupidly overrides readdir and maybe others */ |
35 | /* perl stupidly overrides readdir and maybe others */ |
67 | /* with thread-unsafe versions, imagine that :( */ |
36 | /* with thread-unsafe versions, imagine that :( */ |
68 | #undef readdir |
37 | #undef readdir |
69 | #undef opendir |
38 | #undef opendir |
70 | #undef closedir |
39 | #undef closedir |
71 | |
40 | |
|
|
41 | #ifdef _WIN32 |
|
|
42 | |
|
|
43 | // perl overrides all those nice libc functions |
|
|
44 | |
|
|
45 | #undef malloc |
|
|
46 | #undef free |
|
|
47 | #undef open |
|
|
48 | #undef read |
|
|
49 | #undef write |
|
|
50 | #undef send |
|
|
51 | #undef recv |
|
|
52 | #undef stat |
|
|
53 | #undef lstat |
|
|
54 | #undef fstat |
|
|
55 | #undef truncate |
|
|
56 | #undef ftruncate |
|
|
57 | #undef open |
|
|
58 | #undef link |
|
|
59 | #undef close |
|
|
60 | #undef unlink |
|
|
61 | #undef mkdir |
|
|
62 | #undef rmdir |
|
|
63 | #undef rename |
|
|
64 | #undef lseek |
|
|
65 | #undef opendir |
|
|
66 | #undef readdir |
|
|
67 | #undef closedir |
|
|
68 | #undef chmod |
|
|
69 | #undef fchmod |
|
|
70 | #undef dup |
|
|
71 | #undef dup2 |
|
|
72 | #undef abort |
|
|
73 | #undef pipe |
|
|
74 | |
|
|
75 | #define EIO_STRUCT_STAT struct _stati64 |
72 | #define EIO_STRUCT_STAT Stat_t |
76 | #define EIO_STRUCT_STATI64 |
73 | |
77 | |
74 | /* use NV for 32 bit perls as it allows larger offsets */ |
|
|
75 | #if IVSIZE >= 8 |
|
|
76 | # define VAL64 IV |
|
|
77 | # define SvVAL64 SvIV |
|
|
78 | # define newSVval64 newSViv |
|
|
79 | #else |
78 | #else |
80 | # define VAL64 NV |
79 | |
81 | # define SvVAL64 SvNV |
80 | #include <sys/time.h> |
82 | # define newSVval64 newSVnv |
81 | #include <sys/select.h> |
|
|
82 | #include <unistd.h> |
|
|
83 | #include <utime.h> |
|
|
84 | #include <signal.h> |
|
|
85 | |
|
|
86 | #define EIO_STRUCT_STAT Stat_t |
|
|
87 | |
83 | #endif |
88 | #endif |
84 | |
89 | |
85 | /*****************************************************************************/ |
90 | /*****************************************************************************/ |
86 | |
91 | |
87 | #if __GNUC__ >= 3 |
92 | #if __GNUC__ >= 3 |
… | |
… | |
97 | |
102 | |
98 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
103 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
99 | typedef int aio_rfd; /* read file desriptor */ |
104 | typedef int aio_rfd; /* read file desriptor */ |
100 | typedef int aio_wfd; /* write file descriptor */ |
105 | typedef int aio_wfd; /* write file descriptor */ |
101 | |
106 | |
102 | static HV *aio_stash, *aio_req_stash, *aio_grp_stash; |
107 | static HV *aio_stash, *aio_req_stash, *aio_grp_stash, *aio_wd_stash; |
103 | |
108 | |
104 | #define EIO_REQ_MEMBERS \ |
109 | #define EIO_REQ_MEMBERS \ |
105 | SV *callback; \ |
110 | SV *callback; \ |
106 | SV *sv1, *sv2; \ |
111 | SV *sv1, *sv2; \ |
|
|
112 | SV *sv3, *sv4; \ |
107 | STRLEN stroffset; \ |
113 | STRLEN stroffset; \ |
108 | SV *self; |
114 | SV *self; |
109 | |
115 | |
110 | #define EIO_NO_WRAPPERS 1 |
116 | #define EIO_NO_WRAPPERS 1 |
111 | |
117 | |
112 | #include "libeio/config.h" |
118 | #include "libeio/config.h" |
113 | #include "libeio/eio.h" |
119 | #include "libeio/eio.h" |
114 | |
120 | |
115 | /* Linux/others */ |
121 | static int req_invoke (eio_req *req); |
116 | #ifndef O_ASYNC |
122 | #define EIO_FINISH(req) req_invoke (req) |
117 | # define O_ASYNC 0 |
123 | static void req_destroy (eio_req *grp); |
118 | #endif |
124 | #define EIO_DESTROY(req) req_destroy (req) |
119 | #ifndef O_DIRECT |
|
|
120 | # define O_DIRECT 0 |
|
|
121 | #endif |
|
|
122 | #ifndef O_NOATIME |
|
|
123 | # define O_NOATIME 0 |
|
|
124 | #endif |
|
|
125 | |
125 | |
126 | /* POSIX */ |
126 | #include "libeio/eio.c" |
127 | #ifndef O_CLOEXEC |
|
|
128 | # define O_CLOEXEC 0 |
|
|
129 | #endif |
|
|
130 | #ifndef O_NOFOLLOW |
|
|
131 | # define O_NOFOLLOW 0 |
|
|
132 | #endif |
|
|
133 | #ifndef O_NOCTTY |
|
|
134 | # define O_NOCTTY 0 |
|
|
135 | #endif |
|
|
136 | #ifndef O_NONBLOCK |
|
|
137 | # define O_NONBLOCK 0 |
|
|
138 | #endif |
|
|
139 | #ifndef O_EXEC |
|
|
140 | # define O_EXEC 0 |
|
|
141 | #endif |
|
|
142 | #ifndef O_SEARCH |
|
|
143 | # define O_SEARCH 0 |
|
|
144 | #endif |
|
|
145 | #ifndef O_DIRECTORY |
|
|
146 | # define O_DIRECTORY 0 |
|
|
147 | #endif |
|
|
148 | #ifndef O_DSYNC |
|
|
149 | # define O_DSYNC 0 |
|
|
150 | #endif |
|
|
151 | #ifndef O_RSYNC |
|
|
152 | # define O_RSYNC 0 |
|
|
153 | #endif |
|
|
154 | #ifndef O_SYNC |
|
|
155 | # define O_SYNC 0 |
|
|
156 | #endif |
|
|
157 | #ifndef O_TTY_INIT |
|
|
158 | # define O_TTY_INIT 0 |
|
|
159 | #endif |
|
|
160 | |
|
|
161 | #ifndef POSIX_FADV_NORMAL |
|
|
162 | # define POSIX_FADV_NORMAL 0 |
|
|
163 | #endif |
|
|
164 | #ifndef POSIX_FADV_SEQUENTIAL |
|
|
165 | # define POSIX_FADV_SEQUENTIAL 0 |
|
|
166 | #endif |
|
|
167 | #ifndef POSIX_FADV_RANDOM |
|
|
168 | # define POSIX_FADV_RANDOM 0 |
|
|
169 | #endif |
|
|
170 | #ifndef POSIX_FADV_NOREUSE |
|
|
171 | # define POSIX_FADV_NOREUSE 0 |
|
|
172 | #endif |
|
|
173 | #ifndef POSIX_FADV_WILLNEED |
|
|
174 | # define POSIX_FADV_WILLNEED 0 |
|
|
175 | #endif |
|
|
176 | #ifndef POSIX_FADV_DONTNEED |
|
|
177 | # define POSIX_FADV_DONTNEED 0 |
|
|
178 | #endif |
|
|
179 | |
127 | |
180 | #if !HAVE_POSIX_FADVISE |
128 | #if !HAVE_POSIX_FADVISE |
181 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
129 | # define posix_fadvise(a,b,c,d) errno = ENOSYS /* also return ENOSYS */ |
182 | #endif |
130 | #endif |
183 | |
131 | |
184 | #ifndef POSIX_MADV_NORMAL |
|
|
185 | # define POSIX_MADV_NORMAL 0 |
|
|
186 | #endif |
|
|
187 | #ifndef POSIX_MADV_SEQUENTIAL |
|
|
188 | # define POSIX_MADV_SEQUENTIAL 0 |
|
|
189 | #endif |
|
|
190 | #ifndef POSIX_MADV_RANDOM |
|
|
191 | # define POSIX_MADV_RANDOM 0 |
|
|
192 | #endif |
|
|
193 | #ifndef POSIX_MADV_WILLNEED |
|
|
194 | # define POSIX_MADV_WILLNEED 0 |
|
|
195 | #endif |
|
|
196 | #ifndef POSIX_MADV_DONTNEED |
|
|
197 | # define POSIX_MADV_DONTNEED 0 |
|
|
198 | #endif |
|
|
199 | |
|
|
200 | #if !HAVE_POSIX_MADVISE |
132 | #if !HAVE_POSIX_MADVISE |
201 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
133 | # define posix_madvise(a,b,c) errno = ENOSYS /* also return ENOSYS */ |
202 | #endif |
|
|
203 | |
|
|
204 | #ifndef PROT_NONE |
|
|
205 | # define PROT_NONE 0 |
|
|
206 | #endif |
|
|
207 | #ifndef PROT_READ |
|
|
208 | # define PROT_READ 0 |
|
|
209 | #endif |
|
|
210 | #ifndef PROT_WRITE |
|
|
211 | # define PROT_READ 0 |
|
|
212 | #endif |
|
|
213 | #ifndef PROT_EXEC |
|
|
214 | # define PROT_EXEC 0 |
|
|
215 | #endif |
|
|
216 | |
|
|
217 | #ifndef ST_NODEV |
|
|
218 | # define ST_NODEV 0 |
|
|
219 | #endif |
|
|
220 | #ifndef ST_NOEXEC |
|
|
221 | # define ST_NOEXEC 0 |
|
|
222 | #endif |
|
|
223 | #ifndef ST_SYNCHRONOUS |
|
|
224 | # define ST_SYNCHRONOUS 0 |
|
|
225 | #endif |
|
|
226 | #ifndef ST_MANDLOCK |
|
|
227 | # define ST_MANDLOCK 0 |
|
|
228 | #endif |
|
|
229 | #ifndef ST_WRITE |
|
|
230 | # define ST_WRITE 0 |
|
|
231 | #endif |
|
|
232 | #ifndef ST_APPEND |
|
|
233 | # define ST_APPEND 0 |
|
|
234 | #endif |
|
|
235 | #ifndef ST_IMMUTABLE |
|
|
236 | # define ST_IMMUTABLE 0 |
|
|
237 | #endif |
|
|
238 | #ifndef ST_NOATIME |
|
|
239 | # define ST_NOATIME 0 |
|
|
240 | #endif |
|
|
241 | #ifndef ST_NODIRATIME |
|
|
242 | # define ST_NODIRATIME 0 |
|
|
243 | #endif |
|
|
244 | #ifndef ST_RELATIME |
|
|
245 | # define ST_RELATIME 0 |
|
|
246 | #endif |
|
|
247 | |
|
|
248 | #ifndef S_IFIFO |
|
|
249 | # define S_IFIFO 0 |
|
|
250 | #endif |
|
|
251 | #ifndef S_IFCHR |
|
|
252 | # define S_IFCHR 0 |
|
|
253 | #endif |
|
|
254 | #ifndef S_IFBLK |
|
|
255 | # define S_IFBLK 0 |
|
|
256 | #endif |
|
|
257 | #ifndef S_IFLNK |
|
|
258 | # define S_IFLNK 0 |
|
|
259 | #endif |
|
|
260 | #ifndef S_IFREG |
|
|
261 | # define S_IFREG 0 |
|
|
262 | #endif |
|
|
263 | #ifndef S_IFDIR |
|
|
264 | # define S_IFDIR 0 |
|
|
265 | #endif |
|
|
266 | #ifndef S_IFWHT |
|
|
267 | # define S_IFWHT 0 |
|
|
268 | #endif |
|
|
269 | #ifndef S_IFSOCK |
|
|
270 | # define S_IFSOCK 0 |
|
|
271 | #endif |
134 | #endif |
272 | |
135 | |
273 | #ifndef MAP_ANONYMOUS |
136 | #ifndef MAP_ANONYMOUS |
274 | # ifdef MAP_ANON |
137 | # ifdef MAP_ANON |
275 | # define MAP_ANONYMOUS MAP_ANON |
138 | # define MAP_ANONYMOUS MAP_ANON |
276 | # else |
139 | # else |
277 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
140 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
278 | # endif |
141 | # endif |
279 | #endif |
142 | #endif |
280 | #ifndef MAP_HUGETLB |
143 | |
281 | # define MAP_HUGETLB 0 |
144 | /* defines all sorts of constants to 0 unless they are already defined */ |
282 | #endif |
145 | #include "def0.h" |
283 | #ifndef MAP_LOCKED |
|
|
284 | # define MAP_LOCKED 0 |
|
|
285 | #endif |
|
|
286 | #ifndef MAP_NORESERVE |
|
|
287 | # define MAP_NORESERVE 0 |
|
|
288 | #endif |
|
|
289 | #ifndef MAP_POPULATE |
|
|
290 | # define MAP_POPULATE 0 |
|
|
291 | #endif |
|
|
292 | #ifndef MAP_NONBLOCK |
|
|
293 | # define MAP_NONBLOCK 0 |
|
|
294 | #endif |
|
|
295 | |
146 | |
296 | #ifndef makedev |
147 | #ifndef makedev |
297 | # define makedev(maj,min) (((maj) << 8) | (min)) |
148 | # define makedev(maj,min) (((maj) << 8) | (min)) |
298 | #endif |
149 | #endif |
299 | #ifndef major |
150 | #ifndef major |
… | |
… | |
305 | |
156 | |
306 | #ifndef PAGESIZE |
157 | #ifndef PAGESIZE |
307 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
158 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
308 | #endif |
159 | #endif |
309 | |
160 | |
310 | static int req_invoke (eio_req *req); |
161 | /*****************************************************************************/ |
311 | #define EIO_FINISH(req) req_invoke (req) |
162 | |
312 | static void req_destroy (eio_req *grp); |
163 | static void |
313 | #define EIO_DESTROY(req) req_destroy (req) |
164 | fiemap (eio_req *req) |
|
|
165 | { |
|
|
166 | req->result = -1; |
|
|
167 | |
|
|
168 | #if HAVE_FIEMAP |
|
|
169 | int count = req->int3; |
|
|
170 | |
|
|
171 | /* heuristic: first try with 64 extents if we don't know how many, */ |
|
|
172 | /* as most files have (hopefully) fewer than this many extents */ |
|
|
173 | /* in fact, most should have <= 2, so maybe the 72 below is probably overkill */ |
|
|
174 | if (count < 0) |
|
|
175 | count = 72; /* for what it's worth, 72 extents fit nicely into 4kb */ |
|
|
176 | |
|
|
177 | for (;;) |
|
|
178 | { |
|
|
179 | struct fiemap *fiemap = malloc (sizeof (*fiemap) + sizeof (struct fiemap_extent) * count); |
|
|
180 | errno = ENOMEM; |
|
|
181 | if (!fiemap) |
|
|
182 | return; |
|
|
183 | |
|
|
184 | req->ptr1 = fiemap; |
|
|
185 | req->flags |= EIO_FLAG_PTR1_FREE; |
|
|
186 | |
|
|
187 | fiemap->fm_start = req->offs; |
|
|
188 | fiemap->fm_length = req->size; |
|
|
189 | fiemap->fm_flags = req->int2; |
|
|
190 | fiemap->fm_extent_count = count; |
|
|
191 | |
|
|
192 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
|
|
193 | return; |
|
|
194 | |
|
|
195 | if (req->int3 >= 0) |
|
|
196 | break; /* when not autosizing we are done */ |
|
|
197 | |
|
|
198 | if (fiemap->fm_extents [fiemap->fm_mapped_extents - 1].fe_flags & FIEMAP_EXTENT_LAST) |
|
|
199 | break; /* autosizing successful, we are done */ |
|
|
200 | |
|
|
201 | fiemap->fm_flags = req->int2; |
|
|
202 | fiemap->fm_extent_count = 0; |
|
|
203 | |
|
|
204 | if (ioctl (req->int1, FS_IOC_FIEMAP, fiemap)) |
|
|
205 | return; |
|
|
206 | |
|
|
207 | count = fiemap->fm_mapped_extents; |
|
|
208 | |
|
|
209 | free (fiemap); |
|
|
210 | } |
|
|
211 | |
|
|
212 | req->result = 0; |
|
|
213 | |
|
|
214 | #else |
|
|
215 | errno = ENOSYS; |
|
|
216 | #endif |
|
|
217 | } |
|
|
218 | |
|
|
219 | /*****************************************************************************/ |
314 | |
220 | |
315 | enum { |
221 | enum { |
316 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
222 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
317 | }; |
223 | }; |
318 | |
224 | |
319 | #include "libeio/eio.c" |
|
|
320 | |
|
|
321 | typedef eio_req *aio_req; |
225 | typedef eio_req *aio_req; |
322 | typedef eio_req *aio_req_ornot; |
226 | typedef eio_req *aio_req_ornot; |
|
|
227 | typedef eio_wd aio_wd; |
323 | |
228 | |
324 | static SV *on_next_submit; |
229 | static SV *on_next_submit; |
325 | static int next_pri = EIO_PRI_DEFAULT; |
230 | static int next_pri = EIO_PRI_DEFAULT; |
326 | static int max_outstanding; |
231 | static int max_outstanding; |
327 | |
232 | |
328 | static s_epipe respipe; |
233 | static s_epipe respipe; |
329 | |
234 | |
330 | static void req_destroy (aio_req req); |
235 | static void req_destroy (aio_req req); |
331 | static void req_cancel (aio_req req); |
236 | static void req_cancel (aio_req req); |
332 | |
237 | |
333 | static void want_poll (void) |
238 | static void |
|
|
239 | want_poll (void) |
334 | { |
240 | { |
335 | /* write a dummy byte to the pipe so fh becomes ready */ |
241 | /* write a dummy byte to the pipe so fh becomes ready */ |
336 | s_epipe_signal (&respipe); |
242 | s_epipe_signal (&respipe); |
337 | } |
243 | } |
338 | |
244 | |
339 | static void done_poll (void) |
245 | static void |
|
|
246 | done_poll (void) |
340 | { |
247 | { |
341 | /* read any signals sent by the worker threads */ |
248 | /* read any signals sent by the worker threads */ |
342 | s_epipe_drain (&respipe); |
249 | s_epipe_drain (&respipe); |
343 | } |
250 | } |
344 | |
251 | |
345 | /* must be called at most once */ |
252 | /* must be called at most once */ |
|
|
253 | static SV * |
346 | static SV *req_sv (aio_req req, HV *stash) |
254 | req_sv (aio_req req, HV *stash) |
347 | { |
255 | { |
348 | if (!req->self) |
256 | if (!req->self) |
349 | { |
257 | { |
350 | req->self = (SV *)newHV (); |
258 | req->self = (SV *)newHV (); |
351 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
259 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
352 | } |
260 | } |
353 | |
261 | |
354 | return sv_2mortal (sv_bless (newRV_inc (req->self), stash)); |
262 | return sv_2mortal (sv_bless (newRV_inc (req->self), stash)); |
355 | } |
263 | } |
356 | |
264 | |
357 | static aio_req SvAIO_REQ (SV *sv) |
265 | static SV * |
|
|
266 | newSVaio_wd (aio_wd wd) |
|
|
267 | { |
|
|
268 | return sv_bless (newRV_noinc (newSViv ((IV)wd)), aio_wd_stash); |
|
|
269 | } |
|
|
270 | |
|
|
271 | static aio_req |
|
|
272 | SvAIO_REQ (SV *sv) |
358 | { |
273 | { |
359 | MAGIC *mg; |
274 | MAGIC *mg; |
360 | |
275 | |
361 | if (!SvROK (sv) |
276 | if (!SvROK (sv) |
|
|
277 | /* for speed reasons, we do not verify that SvROK actually has a stash ptr */ |
362 | || (SvSTASH (SvRV (sv)) != aio_grp_stash |
278 | || (SvSTASH (SvRV (sv)) != aio_grp_stash |
363 | && SvSTASH (SvRV (sv)) != aio_req_stash |
279 | && SvSTASH (SvRV (sv)) != aio_req_stash |
364 | && !sv_derived_from (sv, "IO::AIO::REQ"))) |
280 | && !sv_derived_from (sv, "IO::AIO::REQ"))) |
365 | croak ("object of class IO::AIO::REQ expected"); |
281 | croak ("object of class IO::AIO::REQ expected"); |
366 | |
282 | |
367 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
283 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
368 | |
284 | |
369 | return mg ? (aio_req)mg->mg_ptr : 0; |
285 | return mg ? (aio_req)mg->mg_ptr : 0; |
370 | } |
286 | } |
371 | |
287 | |
|
|
288 | static aio_wd |
|
|
289 | SvAIO_WD (SV *sv) |
|
|
290 | { |
|
|
291 | if (!SvROK (sv) |
|
|
292 | || SvTYPE (SvRV (sv)) != SVt_PVMG |
|
|
293 | || SvSTASH (SvRV (sv)) != aio_wd_stash) |
|
|
294 | croak ("IO::AIO: expected a working directory object as returned by aio_wd"); |
|
|
295 | |
|
|
296 | return (aio_wd)(long)SvIVX (SvRV (sv)); |
|
|
297 | } |
|
|
298 | |
|
|
299 | static void |
372 | static void aio_grp_feed (aio_req grp) |
300 | aio_grp_feed (aio_req grp) |
373 | { |
301 | { |
374 | if (grp->sv2 && SvOK (grp->sv2)) |
302 | if (grp->sv2 && SvOK (grp->sv2)) |
375 | { |
303 | { |
376 | dSP; |
304 | dSP; |
377 | |
305 | |
… | |
… | |
385 | FREETMPS; |
313 | FREETMPS; |
386 | LEAVE; |
314 | LEAVE; |
387 | } |
315 | } |
388 | } |
316 | } |
389 | |
317 | |
|
|
318 | static void |
390 | static void req_submit (eio_req *req) |
319 | req_submit (eio_req *req) |
391 | { |
320 | { |
392 | eio_submit (req); |
321 | eio_submit (req); |
393 | |
322 | |
394 | if (expect_false (on_next_submit)) |
323 | if (expect_false (on_next_submit)) |
395 | { |
324 | { |
… | |
… | |
402 | PUTBACK; |
331 | PUTBACK; |
403 | call_sv (cb, G_DISCARD | G_EVAL); |
332 | call_sv (cb, G_DISCARD | G_EVAL); |
404 | } |
333 | } |
405 | } |
334 | } |
406 | |
335 | |
|
|
336 | static int |
407 | static int req_invoke (eio_req *req) |
337 | req_invoke (eio_req *req) |
408 | { |
338 | { |
409 | if (req->flags & FLAG_SV2_RO_OFF) |
339 | if (req->flags & FLAG_SV2_RO_OFF) |
410 | SvREADONLY_off (req->sv2); |
340 | SvREADONLY_off (req->sv2); |
411 | |
341 | |
412 | if (!EIO_CANCELLED (req) && req->callback) |
342 | if (!EIO_CANCELLED (req) && req->callback) |
… | |
… | |
433 | SvREADONLY_on (sv_result); |
363 | SvREADONLY_on (sv_result); |
434 | } |
364 | } |
435 | |
365 | |
436 | switch (req->type) |
366 | switch (req->type) |
437 | { |
367 | { |
|
|
368 | case EIO_WD_OPEN: |
|
|
369 | PUSHs (req->result ? &PL_sv_undef : sv_2mortal (newSVaio_wd (req->wd))); |
|
|
370 | break; |
|
|
371 | |
438 | case EIO_READDIR: |
372 | case EIO_READDIR: |
439 | { |
373 | { |
440 | SV *rv = &PL_sv_undef; |
374 | SV *rv = &PL_sv_undef; |
441 | |
375 | |
442 | if (req->result >= 0) |
376 | if (req->result >= 0) |
… | |
… | |
530 | case EIO_STATVFS: |
464 | case EIO_STATVFS: |
531 | case EIO_FSTATVFS: |
465 | case EIO_FSTATVFS: |
532 | { |
466 | { |
533 | SV *rv = &PL_sv_undef; |
467 | SV *rv = &PL_sv_undef; |
534 | |
468 | |
|
|
469 | #ifndef _WIN32 |
535 | if (req->result >= 0) |
470 | if (req->result >= 0) |
536 | { |
471 | { |
537 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
472 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
538 | HV *hv = newHV (); |
473 | HV *hv = newHV (); |
539 | |
474 | |
… | |
… | |
549 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
484 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
550 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
485 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
551 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
486 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
552 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
487 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
553 | } |
488 | } |
|
|
489 | #endif |
554 | |
490 | |
555 | PUSHs (rv); |
491 | PUSHs (rv); |
556 | } |
492 | } |
557 | |
493 | |
558 | break; |
494 | break; |
… | |
… | |
582 | break; |
518 | break; |
583 | |
519 | |
584 | case EIO_STAT: |
520 | case EIO_STAT: |
585 | case EIO_LSTAT: |
521 | case EIO_LSTAT: |
586 | case EIO_FSTAT: |
522 | case EIO_FSTAT: |
587 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
523 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
|
|
524 | |
588 | PL_laststatval = req->result; |
525 | if (!(PL_laststatval = req->result)) |
|
|
526 | /* if compilation fails here then perl's Stat_t is not struct _stati64 */ |
589 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
527 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
|
|
528 | |
590 | PUSHs (sv_result); |
529 | PUSHs (sv_result); |
|
|
530 | break; |
|
|
531 | |
|
|
532 | case EIO_SEEK: |
|
|
533 | PUSHs (req->result ? sv_result : sv_2mortal (newSVval64 (req->offs))); |
591 | break; |
534 | break; |
592 | |
535 | |
593 | case EIO_READ: |
536 | case EIO_READ: |
594 | { |
537 | { |
595 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
538 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
… | |
… | |
598 | SvSETMAGIC (req->sv2); |
541 | SvSETMAGIC (req->sv2); |
599 | PUSHs (sv_result); |
542 | PUSHs (sv_result); |
600 | } |
543 | } |
601 | break; |
544 | break; |
602 | |
545 | |
|
|
546 | case EIO_CUSTOM: |
|
|
547 | if (req->feed == fiemap) |
|
|
548 | { |
|
|
549 | #if HAVE_FIEMAP |
|
|
550 | if (!req->result) |
|
|
551 | { |
|
|
552 | struct fiemap *fiemap = (struct fiemap *)req->ptr1; |
|
|
553 | |
|
|
554 | if (fiemap->fm_extent_count) |
|
|
555 | { |
|
|
556 | AV *av = newAV (); |
|
|
557 | int i; |
|
|
558 | |
|
|
559 | while (fiemap->fm_mapped_extents) |
|
|
560 | { |
|
|
561 | struct fiemap_extent *extent = &fiemap->fm_extents [--fiemap->fm_mapped_extents]; |
|
|
562 | AV *ext_av = newAV (); |
|
|
563 | |
|
|
564 | av_store (ext_av, 3, newSVuv (extent->fe_flags)); |
|
|
565 | av_store (ext_av, 2, newSVval64 (extent->fe_length)); |
|
|
566 | av_store (ext_av, 1, newSVval64 (extent->fe_physical)); |
|
|
567 | av_store (ext_av, 0, newSVval64 (extent->fe_logical)); |
|
|
568 | |
|
|
569 | av_store (av, fiemap->fm_mapped_extents, newRV_noinc ((SV *)ext_av)); |
|
|
570 | } |
|
|
571 | |
|
|
572 | PUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
573 | } |
|
|
574 | else |
|
|
575 | { |
|
|
576 | SvIV_set (sv_result, fiemap->fm_mapped_extents); |
|
|
577 | PUSHs (sv_result); |
|
|
578 | } |
|
|
579 | } |
|
|
580 | #endif |
|
|
581 | } |
|
|
582 | else |
|
|
583 | PUSHs (sv_result); |
|
|
584 | break; |
|
|
585 | |
603 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ |
586 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), so fudge result value */ |
604 | if (req->result > 0) |
587 | if (req->result > 0) |
605 | SvIV_set (sv_result, 0); |
588 | SvIV_set (sv_result, 0); |
606 | /* FALLTHROUGH */ |
589 | /* FALLTHROUGH */ |
607 | |
590 | |
… | |
… | |
628 | } |
611 | } |
629 | |
612 | |
630 | return !!SvTRUE (ERRSV); |
613 | return !!SvTRUE (ERRSV); |
631 | } |
614 | } |
632 | |
615 | |
|
|
616 | static void |
633 | static void req_destroy (aio_req req) |
617 | req_destroy (aio_req req) |
634 | { |
618 | { |
635 | if (req->self) |
619 | if (req->self) |
636 | { |
620 | { |
637 | sv_unmagic (req->self, PERL_MAGIC_ext); |
621 | sv_unmagic (req->self, PERL_MAGIC_ext); |
638 | SvREFCNT_dec (req->self); |
622 | SvREFCNT_dec (req->self); |
639 | } |
623 | } |
640 | |
624 | |
641 | SvREFCNT_dec (req->sv1); |
625 | SvREFCNT_dec (req->sv1); |
642 | SvREFCNT_dec (req->sv2); |
626 | SvREFCNT_dec (req->sv2); |
|
|
627 | SvREFCNT_dec (req->sv3); |
|
|
628 | SvREFCNT_dec (req->sv4); |
643 | SvREFCNT_dec (req->callback); |
629 | SvREFCNT_dec (req->callback); |
644 | |
630 | |
645 | Safefree (req); |
631 | free (req); |
646 | } |
632 | } |
647 | |
633 | |
|
|
634 | static void |
648 | static void req_cancel_subs (aio_req grp) |
635 | req_cancel_subs (aio_req grp) |
649 | { |
636 | { |
650 | aio_req sub; |
|
|
651 | |
|
|
652 | if (grp->type != EIO_GROUP) |
637 | if (grp->type != EIO_GROUP) |
653 | return; |
638 | return; |
654 | |
639 | |
655 | SvREFCNT_dec (grp->sv2); |
640 | SvREFCNT_dec (grp->sv2); |
656 | grp->sv2 = 0; |
641 | grp->sv2 = 0; |
657 | |
642 | |
658 | eio_grp_cancel (grp); |
643 | eio_grp_cancel (grp); |
659 | } |
644 | } |
660 | |
645 | |
|
|
646 | static void ecb_cold |
661 | static void create_respipe (void) |
647 | create_respipe (void) |
662 | { |
648 | { |
663 | if (s_epipe_renew (&respipe)) |
649 | if (s_epipe_renew (&respipe)) |
664 | croak ("IO::AIO: unable to initialize result pipe"); |
650 | croak ("IO::AIO: unable to initialize result pipe"); |
665 | } |
651 | } |
666 | |
652 | |
667 | static void poll_wait (void) |
653 | static void |
|
|
654 | poll_wait (void) |
668 | { |
655 | { |
669 | while (eio_nreqs ()) |
656 | while (eio_nreqs ()) |
670 | { |
657 | { |
671 | int size; |
658 | int size; |
672 | |
659 | |
… | |
… | |
681 | |
668 | |
682 | s_epipe_wait (&respipe); |
669 | s_epipe_wait (&respipe); |
683 | } |
670 | } |
684 | } |
671 | } |
685 | |
672 | |
686 | static int poll_cb (void) |
673 | static int |
|
|
674 | poll_cb (void) |
687 | { |
675 | { |
688 | for (;;) |
676 | for (;;) |
689 | { |
677 | { |
690 | int res = eio_poll (); |
678 | int res = eio_poll (); |
691 | |
679 | |
… | |
… | |
697 | |
685 | |
698 | poll_wait (); |
686 | poll_wait (); |
699 | } |
687 | } |
700 | } |
688 | } |
701 | |
689 | |
702 | static void atfork_child (void) |
690 | static void ecb_cold |
|
|
691 | reinit (void) |
703 | { |
692 | { |
704 | create_respipe (); |
693 | create_respipe (); |
|
|
694 | |
|
|
695 | if (eio_init (want_poll, done_poll) < 0) |
|
|
696 | croak ("IO::AIO: unable to initialise eio library"); |
705 | } |
697 | } |
706 | |
698 | |
707 | /*****************************************************************************/ |
699 | /*****************************************************************************/ |
708 | |
700 | |
709 | #if !_POSIX_MAPPED_FILES |
701 | #if !_POSIX_MAPPED_FILES |
… | |
… | |
720 | # define MAP_FIXED 0 |
712 | # define MAP_FIXED 0 |
721 | #endif |
713 | #endif |
722 | |
714 | |
723 | #define MMAP_MAGIC PERL_MAGIC_ext |
715 | #define MMAP_MAGIC PERL_MAGIC_ext |
724 | |
716 | |
|
|
717 | static int ecb_cold |
725 | static int mmap_free (pTHX_ SV *sv, MAGIC *mg) |
718 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
726 | { |
719 | { |
727 | int old_errno = errno; |
720 | int old_errno = errno; |
728 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
721 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
729 | errno = old_errno; |
722 | errno = old_errno; |
730 | |
723 | |
… | |
… | |
746 | 0, 0, 0, 0, mmap_free |
739 | 0, 0, 0, 0, mmap_free |
747 | }; |
740 | }; |
748 | |
741 | |
749 | /*****************************************************************************/ |
742 | /*****************************************************************************/ |
750 | |
743 | |
|
|
744 | static SV * |
751 | static SV * get_cb (SV *cb_sv) |
745 | get_cb (SV *cb_sv) |
752 | { |
746 | { |
753 | SvGETMAGIC (cb_sv); |
747 | SvGETMAGIC (cb_sv); |
754 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
748 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
755 | } |
749 | } |
756 | |
750 | |
|
|
751 | static aio_req ecb_noinline |
|
|
752 | dreq (SV *callback) |
|
|
753 | { |
|
|
754 | SV *cb_cv; |
|
|
755 | aio_req req; |
|
|
756 | int req_pri = next_pri; |
|
|
757 | next_pri = EIO_PRI_DEFAULT; |
|
|
758 | |
|
|
759 | cb_cv = get_cb (callback); |
|
|
760 | |
|
|
761 | req = calloc (sizeof (*req), 1); |
|
|
762 | if (!req) |
|
|
763 | croak ("out of memory during eio_req allocation"); |
|
|
764 | |
|
|
765 | req->callback = SvREFCNT_inc (cb_cv); |
|
|
766 | req->pri = req_pri; |
|
|
767 | |
|
|
768 | return req; |
|
|
769 | } |
|
|
770 | |
757 | #define dREQ \ |
771 | #define dREQ \ |
758 | SV *cb_cv; \ |
772 | aio_req req = dreq (callback); \ |
759 | aio_req req; \ |
|
|
760 | int req_pri = next_pri; \ |
|
|
761 | next_pri = EIO_PRI_DEFAULT; \ |
|
|
762 | \ |
|
|
763 | cb_cv = get_cb (callback); \ |
|
|
764 | \ |
|
|
765 | Newz (0, req, 1, eio_req); \ |
|
|
766 | if (!req) \ |
|
|
767 | croak ("out of memory during eio_req allocation"); \ |
|
|
768 | \ |
|
|
769 | req->callback = SvREFCNT_inc (cb_cv); \ |
|
|
770 | req->pri = req_pri |
|
|
771 | |
773 | |
772 | #define REQ_SEND \ |
774 | #define REQ_SEND \ |
773 | PUTBACK; \ |
775 | PUTBACK; \ |
774 | req_submit (req); \ |
776 | req_submit (req); \ |
775 | SPAGAIN; \ |
777 | SPAGAIN; \ |
776 | \ |
778 | \ |
777 | if (GIMME_V != G_VOID) \ |
779 | if (GIMME_V != G_VOID) \ |
778 | XPUSHs (req_sv (req, aio_req_stash)); |
780 | XPUSHs (req_sv (req, aio_req_stash)); |
779 | |
781 | |
|
|
782 | ecb_inline void |
|
|
783 | req_set_path (aio_req req, SV *path, SV **wdsv, SV **pathsv, eio_wd *wd, void **ptr) |
|
|
784 | { |
|
|
785 | if (expect_false (SvROK (path))) |
|
|
786 | { |
|
|
787 | SV *rv = SvRV (path); |
|
|
788 | SV *wdob; |
|
|
789 | |
|
|
790 | if (SvTYPE (rv) == SVt_PVAV && AvFILLp (rv) == 1) |
|
|
791 | { |
|
|
792 | path = AvARRAY (rv)[1]; |
|
|
793 | wdob = AvARRAY (rv)[0]; |
|
|
794 | |
|
|
795 | if (SvOK (wdob)) |
|
|
796 | { |
|
|
797 | *wd = SvAIO_WD (wdob); |
|
|
798 | *wdsv = SvREFCNT_inc_NN (SvRV (wdob)); |
|
|
799 | } |
|
|
800 | else |
|
|
801 | *wd = EIO_INVALID_WD; |
|
|
802 | } |
|
|
803 | else if (SvTYPE (rv) == SVt_PVMG && SvSTASH (rv) == aio_wd_stash) |
|
|
804 | { |
|
|
805 | *wd = (aio_wd)(long)SvIVX (rv); |
|
|
806 | *wdsv = SvREFCNT_inc_NN (rv); |
|
|
807 | *ptr = "."; |
|
|
808 | return; /* path set to "." */ |
|
|
809 | } |
|
|
810 | else |
|
|
811 | croak ("IO::AIO: pathname arguments must be specified as a string, an IO::AIO::WD object or a [IO::AIO::WD, path] pair"); |
|
|
812 | } |
|
|
813 | |
|
|
814 | *pathsv = newSVsv (path); |
|
|
815 | *ptr = SvPVbyte_nolen (*pathsv); |
|
|
816 | } |
|
|
817 | |
|
|
818 | static void ecb_noinline |
|
|
819 | req_set_path1 (aio_req req, SV *path) |
|
|
820 | { |
|
|
821 | req_set_path (req, path, &req->sv1, &req->sv3, &req->wd, &req->ptr1); |
|
|
822 | } |
|
|
823 | |
|
|
824 | static void ecb_noinline |
|
|
825 | req_set_fh_or_path (aio_req req, int type_path, int type_fh, SV *fh_or_path) |
|
|
826 | { |
|
|
827 | SV *rv = SvROK (fh_or_path) ? SvRV (fh_or_path) : fh_or_path; |
|
|
828 | |
|
|
829 | switch (SvTYPE (rv)) |
|
|
830 | { |
|
|
831 | case SVt_PVIO: |
|
|
832 | case SVt_PVLV: |
|
|
833 | case SVt_PVGV: |
|
|
834 | req->type = type_fh; |
|
|
835 | req->sv1 = newSVsv (fh_or_path); |
|
|
836 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
|
|
837 | break; |
|
|
838 | |
|
|
839 | default: |
|
|
840 | req->type = type_path; |
|
|
841 | req_set_path1 (req, fh_or_path); |
|
|
842 | break; |
|
|
843 | } |
|
|
844 | } |
|
|
845 | |
|
|
846 | XS(boot_IO__AIO) ecb_cold; |
|
|
847 | |
780 | MODULE = IO::AIO PACKAGE = IO::AIO |
848 | MODULE = IO::AIO PACKAGE = IO::AIO |
781 | |
849 | |
782 | PROTOTYPES: ENABLE |
850 | PROTOTYPES: ENABLE |
783 | |
851 | |
784 | BOOT: |
852 | BOOT: |
… | |
… | |
788 | IV iv; |
856 | IV iv; |
789 | } *civ, const_iv[] = { |
857 | } *civ, const_iv[] = { |
790 | # define const_niv(name, value) { # name, (IV) value }, |
858 | # define const_niv(name, value) { # name, (IV) value }, |
791 | # define const_iv(name) { # name, (IV) name }, |
859 | # define const_iv(name) { # name, (IV) name }, |
792 | # define const_eio(name) { # name, (IV) EIO_ ## name }, |
860 | # define const_eio(name) { # name, (IV) EIO_ ## name }, |
|
|
861 | |
|
|
862 | /* you have to re-run ./gendef0 after adding/Removing any constants here */ |
|
|
863 | |
|
|
864 | const_iv (ENOSYS) |
793 | const_iv (EXDEV) |
865 | const_iv (EXDEV) |
794 | const_iv (ENOSYS) |
866 | const_iv (EBADR) |
|
|
867 | |
795 | const_iv (O_RDONLY) |
868 | const_iv (O_RDONLY) |
796 | const_iv (O_WRONLY) |
869 | const_iv (O_WRONLY) |
797 | const_iv (O_RDWR) |
870 | const_iv (O_RDWR) |
798 | const_iv (O_CREAT) |
871 | const_iv (O_CREAT) |
799 | const_iv (O_TRUNC) |
872 | const_iv (O_TRUNC) |
… | |
… | |
867 | const_iv (MAP_LOCKED) |
940 | const_iv (MAP_LOCKED) |
868 | const_iv (MAP_NORESERVE) |
941 | const_iv (MAP_NORESERVE) |
869 | const_iv (MAP_POPULATE) |
942 | const_iv (MAP_POPULATE) |
870 | const_iv (MAP_NONBLOCK) |
943 | const_iv (MAP_NONBLOCK) |
871 | |
944 | |
|
|
945 | const_iv (FIEMAP_FLAG_SYNC) |
|
|
946 | const_iv (FIEMAP_FLAG_XATTR) |
|
|
947 | const_iv (FIEMAP_FLAGS_COMPAT) |
|
|
948 | const_iv (FIEMAP_EXTENT_LAST) |
|
|
949 | const_iv (FIEMAP_EXTENT_UNKNOWN) |
|
|
950 | const_iv (FIEMAP_EXTENT_DELALLOC) |
|
|
951 | const_iv (FIEMAP_EXTENT_ENCODED) |
|
|
952 | const_iv (FIEMAP_EXTENT_DATA_ENCRYPTED) |
|
|
953 | const_iv (FIEMAP_EXTENT_NOT_ALIGNED) |
|
|
954 | const_iv (FIEMAP_EXTENT_DATA_INLINE) |
|
|
955 | const_iv (FIEMAP_EXTENT_DATA_TAIL) |
|
|
956 | const_iv (FIEMAP_EXTENT_UNWRITTEN) |
|
|
957 | const_iv (FIEMAP_EXTENT_MERGED) |
|
|
958 | const_iv (FIEMAP_EXTENT_SHARED) |
|
|
959 | |
|
|
960 | const_eio (SEEK_SET) |
|
|
961 | const_eio (SEEK_CUR) |
|
|
962 | const_eio (SEEK_END) |
|
|
963 | |
872 | const_eio (MCL_FUTURE) |
964 | const_eio (MCL_FUTURE) |
873 | const_eio (MCL_CURRENT) |
965 | const_eio (MCL_CURRENT) |
874 | |
966 | |
875 | const_eio (MS_ASYNC) |
967 | const_eio (MS_ASYNC) |
876 | const_eio (MS_INVALIDATE) |
968 | const_eio (MS_INVALIDATE) |
… | |
… | |
901 | }; |
993 | }; |
902 | |
994 | |
903 | aio_stash = gv_stashpv ("IO::AIO" , 1); |
995 | aio_stash = gv_stashpv ("IO::AIO" , 1); |
904 | aio_req_stash = gv_stashpv ("IO::AIO::REQ", 1); |
996 | aio_req_stash = gv_stashpv ("IO::AIO::REQ", 1); |
905 | aio_grp_stash = gv_stashpv ("IO::AIO::GRP", 1); |
997 | aio_grp_stash = gv_stashpv ("IO::AIO::GRP", 1); |
|
|
998 | aio_wd_stash = gv_stashpv ("IO::AIO::WD" , 1); |
906 | |
999 | |
907 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1000 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
908 | newCONSTSUB (aio_stash, (char *)civ->name, newSViv (civ->iv)); |
1001 | newCONSTSUB (aio_stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
909 | |
1002 | |
910 | newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); |
1003 | newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); |
911 | |
1004 | |
912 | create_respipe (); |
1005 | reinit (); |
913 | |
|
|
914 | if (eio_init (want_poll, done_poll) < 0) |
|
|
915 | croak ("IO::AIO: unable to initialise eio library"); |
|
|
916 | |
|
|
917 | /* atfork child called in fifo order, so before eio's handler */ |
|
|
918 | X_THREAD_ATFORK (0, 0, atfork_child); |
|
|
919 | } |
1006 | } |
|
|
1007 | |
|
|
1008 | void |
|
|
1009 | reinit () |
|
|
1010 | PROTOTYPE: |
920 | |
1011 | |
921 | void |
1012 | void |
922 | max_poll_reqs (unsigned int nreqs) |
1013 | max_poll_reqs (unsigned int nreqs) |
923 | PROTOTYPE: $ |
1014 | PROTOTYPE: $ |
924 | CODE: |
1015 | CODE: |
… | |
… | |
959 | PROTOTYPE: $ |
1050 | PROTOTYPE: $ |
960 | CODE: |
1051 | CODE: |
961 | max_outstanding = maxreqs; |
1052 | max_outstanding = maxreqs; |
962 | |
1053 | |
963 | void |
1054 | void |
|
|
1055 | aio_wd (SV8 *pathname, SV *callback=&PL_sv_undef) |
|
|
1056 | PPCODE: |
|
|
1057 | { |
|
|
1058 | dREQ; |
|
|
1059 | |
|
|
1060 | req->type = EIO_WD_OPEN; |
|
|
1061 | req_set_path1 (req, pathname); |
|
|
1062 | |
|
|
1063 | REQ_SEND; |
|
|
1064 | } |
|
|
1065 | |
|
|
1066 | void |
964 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
1067 | aio_open (SV8 *pathname, int flags, int mode, SV *callback=&PL_sv_undef) |
965 | PPCODE: |
1068 | PPCODE: |
966 | { |
1069 | { |
967 | dREQ; |
1070 | dREQ; |
968 | |
1071 | |
969 | req->type = EIO_OPEN; |
1072 | req->type = EIO_OPEN; |
970 | req->sv1 = newSVsv (pathname); |
1073 | req_set_path1 (req, pathname); |
971 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
972 | req->int1 = flags; |
1074 | req->int1 = flags; |
973 | req->int2 = mode; |
1075 | req->int2 = mode; |
974 | |
1076 | |
975 | REQ_SEND; |
1077 | REQ_SEND; |
976 | } |
1078 | } |
… | |
… | |
978 | void |
1080 | void |
979 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
1081 | aio_fsync (SV *fh, SV *callback=&PL_sv_undef) |
980 | ALIAS: |
1082 | ALIAS: |
981 | aio_fsync = EIO_FSYNC |
1083 | aio_fsync = EIO_FSYNC |
982 | aio_fdatasync = EIO_FDATASYNC |
1084 | aio_fdatasync = EIO_FDATASYNC |
|
|
1085 | aio_syncfs = EIO_SYNCFS |
983 | PPCODE: |
1086 | PPCODE: |
984 | { |
1087 | { |
985 | int fd = s_fileno_croak (fh, 0); |
1088 | int fd = s_fileno_croak (fh, 0); |
986 | dREQ; |
1089 | dREQ; |
987 | |
1090 | |
988 | req->type = ix; |
1091 | req->type = ix; |
989 | req->sv1 = newSVsv (fh); |
1092 | req->sv1 = newSVsv (fh); |
990 | req->int1 = fd; |
1093 | req->int1 = fd; |
991 | |
1094 | |
992 | REQ_SEND (req); |
1095 | REQ_SEND; |
993 | } |
1096 | } |
994 | |
1097 | |
995 | void |
1098 | void |
996 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
1099 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
997 | PPCODE: |
1100 | PPCODE: |
… | |
… | |
1004 | req->int1 = fd; |
1107 | req->int1 = fd; |
1005 | req->offs = offset; |
1108 | req->offs = offset; |
1006 | req->size = nbytes; |
1109 | req->size = nbytes; |
1007 | req->int2 = flags; |
1110 | req->int2 = flags; |
1008 | |
1111 | |
1009 | REQ_SEND (req); |
1112 | REQ_SEND; |
1010 | } |
1113 | } |
1011 | |
1114 | |
1012 | void |
1115 | void |
1013 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1116 | aio_fallocate (SV *fh, int mode, off_t offset, size_t len, SV *callback=&PL_sv_undef) |
1014 | PPCODE: |
1117 | PPCODE: |
… | |
… | |
1021 | req->int1 = fd; |
1124 | req->int1 = fd; |
1022 | req->int2 = mode; |
1125 | req->int2 = mode; |
1023 | req->offs = offset; |
1126 | req->offs = offset; |
1024 | req->size = len; |
1127 | req->size = len; |
1025 | |
1128 | |
1026 | REQ_SEND (req); |
1129 | REQ_SEND; |
1027 | } |
1130 | } |
1028 | |
1131 | |
1029 | void |
1132 | void |
1030 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1133 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
1031 | PPCODE: |
1134 | PPCODE: |
1032 | { |
1135 | { |
1033 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
1136 | static int close_fd = -1; /* dummy fd to close fds via dup2 */ |
1034 | int fd = s_fileno_croak (fh, 0); |
1137 | int fd = s_fileno_croak (fh, 0); |
1035 | dREQ; |
1138 | dREQ; |
1036 | |
1139 | |
1037 | if (close_pipe < 0) |
1140 | if (expect_false (close_fd < 0)) |
1038 | { |
1141 | { |
1039 | int pipefd [2]; |
1142 | int pipefd [2]; |
1040 | |
1143 | |
|
|
1144 | if ( |
|
|
1145 | #ifdef _WIN32 |
|
|
1146 | _pipe (pipefd, 1, _O_BINARY) < 0 |
|
|
1147 | #else |
1041 | if (pipe (pipefd) < 0 |
1148 | pipe (pipefd) < 0 |
1042 | || close (pipefd [1]) < 0 |
|
|
1043 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0) |
1149 | || fcntl (pipefd [0], F_SETFD, FD_CLOEXEC) < 0 |
|
|
1150 | #endif |
|
|
1151 | || close (pipefd [1]) < 0 |
|
|
1152 | ) |
1044 | abort (); /*D*/ |
1153 | abort (); /*D*/ |
1045 | |
1154 | |
1046 | close_pipe = pipefd [0]; |
1155 | close_fd = pipefd [0]; |
1047 | } |
1156 | } |
1048 | |
1157 | |
1049 | req->type = EIO_DUP2; |
1158 | req->type = EIO_DUP2; |
1050 | req->int1 = close_pipe; |
1159 | req->int1 = close_fd; |
1051 | req->sv2 = newSVsv (fh); |
1160 | req->sv2 = newSVsv (fh); |
1052 | req->int2 = fd; |
1161 | req->int2 = fd; |
1053 | |
1162 | |
1054 | REQ_SEND (req); |
1163 | REQ_SEND; |
|
|
1164 | } |
|
|
1165 | |
|
|
1166 | void |
|
|
1167 | aio_seek (SV *fh, SV *offset, int whence, SV *callback=&PL_sv_undef) |
|
|
1168 | PPCODE: |
|
|
1169 | { |
|
|
1170 | int fd = s_fileno_croak (fh, 0); |
|
|
1171 | dREQ; |
|
|
1172 | |
|
|
1173 | req->type = EIO_SEEK; |
|
|
1174 | req->sv1 = newSVsv (fh); |
|
|
1175 | req->int1 = fd; |
|
|
1176 | req->offs = SvVAL64 (offset); |
|
|
1177 | req->int2 = whence; |
|
|
1178 | |
|
|
1179 | REQ_SEND; |
1055 | } |
1180 | } |
1056 | |
1181 | |
1057 | void |
1182 | void |
1058 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
1183 | aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback=&PL_sv_undef) |
1059 | ALIAS: |
1184 | ALIAS: |
… | |
… | |
1106 | REQ_SEND; |
1231 | REQ_SEND; |
1107 | } |
1232 | } |
1108 | } |
1233 | } |
1109 | |
1234 | |
1110 | void |
1235 | void |
1111 | aio_readlink (SV8 *path, SV *callback=&PL_sv_undef) |
1236 | aio_readlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1112 | ALIAS: |
1237 | ALIAS: |
1113 | aio_readlink = EIO_READLINK |
1238 | aio_readlink = EIO_READLINK |
1114 | aio_realpath = EIO_REALPATH |
1239 | aio_realpath = EIO_REALPATH |
1115 | PPCODE: |
1240 | PPCODE: |
1116 | { |
1241 | { |
1117 | SV *data; |
|
|
1118 | dREQ; |
1242 | dREQ; |
1119 | |
1243 | |
1120 | req->type = ix; |
1244 | req->type = ix; |
1121 | req->sv1 = newSVsv (path); |
1245 | req_set_path1 (req, pathname); |
1122 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1123 | |
1246 | |
1124 | REQ_SEND; |
1247 | REQ_SEND; |
1125 | } |
1248 | } |
1126 | |
1249 | |
1127 | void |
1250 | void |
… | |
… | |
1167 | aio_statvfs = EIO_STATVFS |
1290 | aio_statvfs = EIO_STATVFS |
1168 | PPCODE: |
1291 | PPCODE: |
1169 | { |
1292 | { |
1170 | dREQ; |
1293 | dREQ; |
1171 | |
1294 | |
1172 | req->sv1 = newSVsv (fh_or_path); |
1295 | req_set_fh_or_path (req, ix, ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT, fh_or_path); |
1173 | |
|
|
1174 | if (SvPOK (req->sv1)) |
|
|
1175 | { |
|
|
1176 | req->type = ix; |
|
|
1177 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1178 | } |
|
|
1179 | else |
|
|
1180 | { |
|
|
1181 | req->type = ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT; |
|
|
1182 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
|
|
1183 | } |
|
|
1184 | |
1296 | |
1185 | REQ_SEND; |
1297 | REQ_SEND; |
1186 | } |
1298 | } |
1187 | |
1299 | |
1188 | UV |
1300 | UV |
… | |
… | |
1207 | { |
1319 | { |
1208 | dREQ; |
1320 | dREQ; |
1209 | |
1321 | |
1210 | req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; |
1322 | req->nv1 = SvOK (atime) ? SvNV (atime) : -1.; |
1211 | req->nv2 = SvOK (mtime) ? SvNV (mtime) : -1.; |
1323 | req->nv2 = SvOK (mtime) ? SvNV (mtime) : -1.; |
1212 | req->sv1 = newSVsv (fh_or_path); |
1324 | req_set_fh_or_path (req, EIO_UTIME, EIO_FUTIME, fh_or_path); |
1213 | |
|
|
1214 | if (SvPOK (req->sv1)) |
|
|
1215 | { |
|
|
1216 | req->type = EIO_UTIME; |
|
|
1217 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1218 | } |
|
|
1219 | else |
|
|
1220 | { |
|
|
1221 | req->type = EIO_FUTIME; |
|
|
1222 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
|
|
1223 | } |
|
|
1224 | |
1325 | |
1225 | REQ_SEND; |
1326 | REQ_SEND; |
1226 | } |
1327 | } |
1227 | |
1328 | |
1228 | void |
1329 | void |
1229 | aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) |
1330 | aio_truncate (SV8 *fh_or_path, SV *offset, SV *callback=&PL_sv_undef) |
1230 | PPCODE: |
1331 | PPCODE: |
1231 | { |
1332 | { |
1232 | dREQ; |
1333 | dREQ; |
1233 | |
1334 | |
1234 | req->sv1 = newSVsv (fh_or_path); |
|
|
1235 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
1335 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
1236 | |
1336 | req_set_fh_or_path (req, EIO_TRUNCATE, EIO_FTRUNCATE, fh_or_path); |
1237 | if (SvPOK (req->sv1)) |
|
|
1238 | { |
|
|
1239 | req->type = EIO_TRUNCATE; |
|
|
1240 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1241 | } |
|
|
1242 | else |
|
|
1243 | { |
|
|
1244 | req->type = EIO_FTRUNCATE; |
|
|
1245 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
|
|
1246 | } |
|
|
1247 | |
1337 | |
1248 | REQ_SEND; |
1338 | REQ_SEND; |
1249 | } |
1339 | } |
1250 | |
1340 | |
1251 | void |
1341 | void |
1252 | aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) |
1342 | aio_chmod (SV8 *fh_or_path, int mode, SV *callback=&PL_sv_undef) |
1253 | ALIAS: |
|
|
1254 | aio_chmod = EIO_CHMOD |
|
|
1255 | aio_mkdir = EIO_MKDIR |
|
|
1256 | PPCODE: |
1343 | PPCODE: |
1257 | { |
1344 | { |
1258 | dREQ; |
1345 | dREQ; |
1259 | |
1346 | |
1260 | req->int2 = mode; |
1347 | req->int2 = mode; |
1261 | req->sv1 = newSVsv (fh_or_path); |
1348 | req_set_fh_or_path (req, EIO_CHMOD, EIO_FCHMOD, fh_or_path); |
1262 | |
|
|
1263 | if (SvPOK (req->sv1)) |
|
|
1264 | { |
|
|
1265 | req->type = ix; |
|
|
1266 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1267 | } |
|
|
1268 | else |
|
|
1269 | { |
|
|
1270 | req->type = EIO_FCHMOD; |
|
|
1271 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
|
|
1272 | } |
|
|
1273 | |
1349 | |
1274 | REQ_SEND; |
1350 | REQ_SEND; |
1275 | } |
1351 | } |
1276 | |
1352 | |
1277 | void |
1353 | void |
… | |
… | |
1280 | { |
1356 | { |
1281 | dREQ; |
1357 | dREQ; |
1282 | |
1358 | |
1283 | req->int2 = SvOK (uid) ? SvIV (uid) : -1; |
1359 | req->int2 = SvOK (uid) ? SvIV (uid) : -1; |
1284 | req->int3 = SvOK (gid) ? SvIV (gid) : -1; |
1360 | req->int3 = SvOK (gid) ? SvIV (gid) : -1; |
1285 | req->sv1 = newSVsv (fh_or_path); |
1361 | req_set_fh_or_path (req, EIO_CHOWN, EIO_FCHOWN, fh_or_path); |
1286 | |
|
|
1287 | if (SvPOK (req->sv1)) |
|
|
1288 | { |
|
|
1289 | req->type = EIO_CHOWN; |
|
|
1290 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1291 | } |
|
|
1292 | else |
|
|
1293 | { |
|
|
1294 | req->type = EIO_FCHOWN; |
|
|
1295 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
|
|
1296 | } |
|
|
1297 | |
1362 | |
1298 | REQ_SEND; |
1363 | REQ_SEND; |
1299 | } |
1364 | } |
1300 | |
1365 | |
1301 | void |
1366 | void |
… | |
… | |
1303 | PPCODE: |
1368 | PPCODE: |
1304 | { |
1369 | { |
1305 | dREQ; |
1370 | dREQ; |
1306 | |
1371 | |
1307 | req->type = EIO_READDIR; |
1372 | req->type = EIO_READDIR; |
1308 | req->sv1 = newSVsv (pathname); |
|
|
1309 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1310 | req->int1 = flags | EIO_READDIR_DENTS | EIO_READDIR_CUSTOM1; |
1373 | req->int1 = flags | EIO_READDIR_DENTS | EIO_READDIR_CUSTOM1; |
1311 | |
1374 | |
1312 | if (flags & EIO_READDIR_DENTS) |
1375 | if (flags & EIO_READDIR_DENTS) |
1313 | req->int1 |= EIO_READDIR_CUSTOM2; |
1376 | req->int1 |= EIO_READDIR_CUSTOM2; |
1314 | |
1377 | |
|
|
1378 | req_set_path1 (req, pathname); |
|
|
1379 | |
1315 | REQ_SEND; |
1380 | REQ_SEND; |
|
|
1381 | } |
|
|
1382 | |
|
|
1383 | void |
|
|
1384 | aio_mkdir (SV8 *pathname, int mode, SV *callback=&PL_sv_undef) |
|
|
1385 | PPCODE: |
|
|
1386 | { |
|
|
1387 | dREQ; |
|
|
1388 | |
|
|
1389 | req->type = EIO_MKDIR; |
|
|
1390 | req->int2 = mode; |
|
|
1391 | req_set_path1 (req, pathname); |
|
|
1392 | |
|
|
1393 | REQ_SEND; |
1316 | } |
1394 | } |
1317 | |
1395 | |
1318 | void |
1396 | void |
1319 | aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1397 | aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1320 | ALIAS: |
1398 | ALIAS: |
… | |
… | |
1324 | PPCODE: |
1402 | PPCODE: |
1325 | { |
1403 | { |
1326 | dREQ; |
1404 | dREQ; |
1327 | |
1405 | |
1328 | req->type = ix; |
1406 | req->type = ix; |
1329 | req->sv1 = newSVsv (pathname); |
1407 | req_set_path1 (req, pathname); |
1330 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1331 | |
1408 | |
1332 | REQ_SEND; |
1409 | REQ_SEND; |
1333 | } |
1410 | } |
1334 | |
1411 | |
1335 | void |
1412 | void |
… | |
… | |
1338 | aio_link = EIO_LINK |
1415 | aio_link = EIO_LINK |
1339 | aio_symlink = EIO_SYMLINK |
1416 | aio_symlink = EIO_SYMLINK |
1340 | aio_rename = EIO_RENAME |
1417 | aio_rename = EIO_RENAME |
1341 | PPCODE: |
1418 | PPCODE: |
1342 | { |
1419 | { |
|
|
1420 | eio_wd wd2 = 0; |
1343 | dREQ; |
1421 | dREQ; |
1344 | |
1422 | |
1345 | req->type = ix; |
1423 | req->type = ix; |
1346 | req->sv1 = newSVsv (oldpath); |
1424 | req_set_path1 (req, oldpath); |
1347 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1425 | req_set_path (req, newpath, &req->sv2, &req->sv4, &wd2, &req->ptr2); |
1348 | req->sv2 = newSVsv (newpath); |
1426 | req->int3 = (long)wd2; |
1349 | req->ptr2 = SvPVbyte_nolen (req->sv2); |
|
|
1350 | |
1427 | |
1351 | REQ_SEND; |
1428 | REQ_SEND; |
1352 | } |
1429 | } |
1353 | |
1430 | |
1354 | void |
1431 | void |
… | |
… | |
1356 | PPCODE: |
1433 | PPCODE: |
1357 | { |
1434 | { |
1358 | dREQ; |
1435 | dREQ; |
1359 | |
1436 | |
1360 | req->type = EIO_MKNOD; |
1437 | req->type = EIO_MKNOD; |
1361 | req->sv1 = newSVsv (pathname); |
|
|
1362 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1363 | req->int2 = (mode_t)mode; |
1438 | req->int2 = (mode_t)mode; |
1364 | req->offs = dev; |
1439 | req->offs = dev; |
|
|
1440 | req_set_path1 (req, pathname); |
1365 | |
1441 | |
1366 | REQ_SEND; |
1442 | REQ_SEND; |
1367 | } |
1443 | } |
1368 | |
1444 | |
1369 | void |
1445 | void |
… | |
… | |
1436 | |
1512 | |
1437 | req->type = EIO_MLOCKALL; |
1513 | req->type = EIO_MLOCKALL; |
1438 | req->int1 = flags; |
1514 | req->int1 = flags; |
1439 | |
1515 | |
1440 | REQ_SEND; |
1516 | REQ_SEND; |
|
|
1517 | } |
|
|
1518 | |
|
|
1519 | void |
|
|
1520 | aio_fiemap (SV *fh, off_t start, SV *length, U32 flags, SV *count, SV *callback=&PL_sv_undef) |
|
|
1521 | PPCODE: |
|
|
1522 | { |
|
|
1523 | int fd = s_fileno_croak (fh, 0); |
|
|
1524 | dREQ; |
|
|
1525 | |
|
|
1526 | req->type = EIO_CUSTOM; |
|
|
1527 | req->sv1 = newSVsv (fh); |
|
|
1528 | req->int1 = fd; |
|
|
1529 | |
|
|
1530 | req->feed = fiemap; |
|
|
1531 | #if HAVE_FIEMAP |
|
|
1532 | /* keep our fingers crossed that the next two types are 64 bit */ |
|
|
1533 | req->offs = start; |
|
|
1534 | req->size = SvOK (length) ? SvVAL64 (length) : ~0ULL; |
|
|
1535 | req->int2 = flags; |
|
|
1536 | req->int3 = SvOK (count) ? SvIV (count) : -1; |
|
|
1537 | #endif |
|
|
1538 | |
|
|
1539 | REQ_SEND; |
1441 | } |
1540 | } |
1442 | |
1541 | |
1443 | void |
1542 | void |
1444 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1543 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1445 | PPCODE: |
1544 | PPCODE: |
… | |
… | |
1569 | CODE: |
1668 | CODE: |
1570 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1669 | RETVAL = posix_fadvise (fh, offset, length, advice); |
1571 | OUTPUT: |
1670 | OUTPUT: |
1572 | RETVAL |
1671 | RETVAL |
1573 | |
1672 | |
1574 | ssize_t |
1673 | IV |
1575 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1674 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
1576 | CODE: |
1675 | CODE: |
1577 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1676 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
1578 | OUTPUT: |
1677 | OUTPUT: |
1579 | RETVAL |
1678 | RETVAL |
… | |
… | |
1691 | SvREFCNT_dec (on_next_submit); |
1790 | SvREFCNT_dec (on_next_submit); |
1692 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1791 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1693 | |
1792 | |
1694 | PROTOTYPES: DISABLE |
1793 | PROTOTYPES: DISABLE |
1695 | |
1794 | |
|
|
1795 | MODULE = IO::AIO PACKAGE = IO::AIO::WD |
|
|
1796 | |
|
|
1797 | BOOT: |
|
|
1798 | { |
|
|
1799 | newCONSTSUB (aio_stash, "CWD" , newSVaio_wd (EIO_CWD )); |
|
|
1800 | newCONSTSUB (aio_stash, "INVALID_WD", newSVaio_wd (EIO_INVALID_WD)); |
|
|
1801 | } |
|
|
1802 | |
|
|
1803 | void |
|
|
1804 | DESTROY (SV *self) |
|
|
1805 | CODE: |
|
|
1806 | { |
|
|
1807 | aio_wd wd = SvAIO_WD (self); |
|
|
1808 | #if HAVE_AT |
|
|
1809 | { |
|
|
1810 | SV *callback = &PL_sv_undef; |
|
|
1811 | dREQ; /* clobbers next_pri :/ */ |
|
|
1812 | next_pri = req->pri; /* restore next_pri */ |
|
|
1813 | req->pri = EIO_PRI_MAX; /* better use max. priority to conserve fds */ |
|
|
1814 | req->type = EIO_WD_CLOSE; |
|
|
1815 | req->wd = wd; |
|
|
1816 | REQ_SEND; |
|
|
1817 | } |
|
|
1818 | #else |
|
|
1819 | eio_wd_close_sync (wd); |
|
|
1820 | #endif |
|
|
1821 | } |
|
|
1822 | |
1696 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1823 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1697 | |
1824 | |
1698 | void |
1825 | void |
1699 | cancel (aio_req_ornot req) |
1826 | cancel (aio_req_ornot req) |
1700 | CODE: |
1827 | CODE: |