… | |
… | |
77 | # ifndef EV_USE_REALTIME |
77 | # ifndef EV_USE_REALTIME |
78 | # define EV_USE_REALTIME 0 |
78 | # define EV_USE_REALTIME 0 |
79 | # endif |
79 | # endif |
80 | # endif |
80 | # endif |
81 | |
81 | |
|
|
82 | # if HAVE_NANOSLEEP |
82 | # ifndef EV_USE_NANOSLEEP |
83 | # ifndef EV_USE_NANOSLEEP |
83 | # if HAVE_NANOSLEEP |
|
|
84 | # define EV_USE_NANOSLEEP 1 |
84 | # define EV_USE_NANOSLEEP EV_FEATURE_OS |
|
|
85 | # endif |
85 | # else |
86 | # else |
|
|
87 | # undef EV_USE_NANOSLEEP |
86 | # define EV_USE_NANOSLEEP 0 |
88 | # define EV_USE_NANOSLEEP 0 |
|
|
89 | # endif |
|
|
90 | |
|
|
91 | # if HAVE_SELECT && HAVE_SYS_SELECT_H |
|
|
92 | # ifndef EV_USE_SELECT |
|
|
93 | # define EV_USE_SELECT EV_FEATURE_BACKENDS |
87 | # endif |
94 | # endif |
88 | # endif |
|
|
89 | |
|
|
90 | # ifndef EV_USE_SELECT |
|
|
91 | # if HAVE_SELECT && HAVE_SYS_SELECT_H |
|
|
92 | # define EV_USE_SELECT 1 |
|
|
93 | # else |
95 | # else |
|
|
96 | # undef EV_USE_SELECT |
94 | # define EV_USE_SELECT 0 |
97 | # define EV_USE_SELECT 0 |
|
|
98 | # endif |
|
|
99 | |
|
|
100 | # if HAVE_POLL && HAVE_POLL_H |
|
|
101 | # ifndef EV_USE_POLL |
|
|
102 | # define EV_USE_POLL EV_FEATURE_BACKENDS |
95 | # endif |
103 | # endif |
96 | # endif |
|
|
97 | |
|
|
98 | # ifndef EV_USE_POLL |
|
|
99 | # if HAVE_POLL && HAVE_POLL_H |
|
|
100 | # define EV_USE_POLL 1 |
|
|
101 | # else |
104 | # else |
|
|
105 | # undef EV_USE_POLL |
102 | # define EV_USE_POLL 0 |
106 | # define EV_USE_POLL 0 |
|
|
107 | # endif |
|
|
108 | |
|
|
109 | # if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H |
|
|
110 | # ifndef EV_USE_EPOLL |
|
|
111 | # define EV_USE_EPOLL EV_FEATURE_BACKENDS |
103 | # endif |
112 | # endif |
|
|
113 | # else |
|
|
114 | # undef EV_USE_EPOLL |
|
|
115 | # define EV_USE_EPOLL 0 |
104 | # endif |
116 | # endif |
105 | |
117 | |
|
|
118 | # if HAVE_KQUEUE && HAVE_SYS_EVENT_H |
106 | # ifndef EV_USE_EPOLL |
119 | # ifndef EV_USE_KQUEUE |
107 | # if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H |
120 | # define EV_USE_KQUEUE EV_FEATURE_BACKENDS |
108 | # define EV_USE_EPOLL 1 |
|
|
109 | # else |
|
|
110 | # define EV_USE_EPOLL 0 |
|
|
111 | # endif |
121 | # endif |
|
|
122 | # else |
|
|
123 | # undef EV_USE_KQUEUE |
|
|
124 | # define EV_USE_KQUEUE 0 |
112 | # endif |
125 | # endif |
113 | |
126 | |
114 | # ifndef EV_USE_KQUEUE |
127 | # if HAVE_PORT_H && HAVE_PORT_CREATE |
115 | # if HAVE_KQUEUE && HAVE_SYS_EVENT_H |
128 | # ifndef EV_USE_PORT |
116 | # define EV_USE_KQUEUE 1 |
129 | # define EV_USE_PORT EV_FEATURE_BACKENDS |
117 | # else |
|
|
118 | # define EV_USE_KQUEUE 0 |
|
|
119 | # endif |
130 | # endif |
120 | # endif |
|
|
121 | |
|
|
122 | # ifndef EV_USE_PORT |
|
|
123 | # if HAVE_PORT_H && HAVE_PORT_CREATE |
|
|
124 | # define EV_USE_PORT 1 |
|
|
125 | # else |
131 | # else |
|
|
132 | # undef EV_USE_PORT |
126 | # define EV_USE_PORT 0 |
133 | # define EV_USE_PORT 0 |
|
|
134 | # endif |
|
|
135 | |
|
|
136 | # if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H |
|
|
137 | # ifndef EV_USE_INOTIFY |
|
|
138 | # define EV_USE_INOTIFY EV_FEATURE_OS |
127 | # endif |
139 | # endif |
128 | # endif |
|
|
129 | |
|
|
130 | # ifndef EV_USE_INOTIFY |
|
|
131 | # if HAVE_INOTIFY_INIT && HAVE_SYS_INOTIFY_H |
|
|
132 | # define EV_USE_INOTIFY 1 |
|
|
133 | # else |
140 | # else |
|
|
141 | # undef EV_USE_INOTIFY |
134 | # define EV_USE_INOTIFY 0 |
142 | # define EV_USE_INOTIFY 0 |
|
|
143 | # endif |
|
|
144 | |
|
|
145 | # if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H |
|
|
146 | # ifndef EV_USE_SIGNALFD |
|
|
147 | # define EV_USE_SIGNALFD EV_FEATURE_OS |
135 | # endif |
148 | # endif |
136 | # endif |
|
|
137 | |
|
|
138 | # ifndef EV_USE_SIGNALFD |
|
|
139 | # if HAVE_SIGNALFD && HAVE_SYS_SIGNALFD_H |
|
|
140 | # define EV_USE_SIGNALFD 1 |
|
|
141 | # else |
149 | # else |
|
|
150 | # undef EV_USE_SIGNALFD |
142 | # define EV_USE_SIGNALFD 0 |
151 | # define EV_USE_SIGNALFD 0 |
|
|
152 | # endif |
|
|
153 | |
|
|
154 | # if HAVE_EVENTFD |
|
|
155 | # ifndef EV_USE_EVENTFD |
|
|
156 | # define EV_USE_EVENTFD EV_FEATURE_OS |
143 | # endif |
157 | # endif |
144 | # endif |
|
|
145 | |
|
|
146 | # ifndef EV_USE_EVENTFD |
|
|
147 | # if HAVE_EVENTFD |
|
|
148 | # define EV_USE_EVENTFD 1 |
|
|
149 | # else |
158 | # else |
|
|
159 | # undef EV_USE_EVENTFD |
150 | # define EV_USE_EVENTFD 0 |
160 | # define EV_USE_EVENTFD 0 |
151 | # endif |
|
|
152 | # endif |
161 | # endif |
153 | |
162 | |
154 | #endif |
163 | #endif |
155 | |
164 | |
156 | #include <math.h> |
165 | #include <math.h> |
… | |
… | |
184 | # define WIN32_LEAN_AND_MEAN |
193 | # define WIN32_LEAN_AND_MEAN |
185 | # include <windows.h> |
194 | # include <windows.h> |
186 | # ifndef EV_SELECT_IS_WINSOCKET |
195 | # ifndef EV_SELECT_IS_WINSOCKET |
187 | # define EV_SELECT_IS_WINSOCKET 1 |
196 | # define EV_SELECT_IS_WINSOCKET 1 |
188 | # endif |
197 | # endif |
|
|
198 | # undef EV_AVOID_STDIO |
189 | #endif |
199 | #endif |
190 | |
200 | |
191 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
201 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
192 | |
202 | |
193 | /* try to deduce the maximum number of signals on this platform */ |
203 | /* try to deduce the maximum number of signals on this platform */ |
… | |
… | |
206 | #elif defined (MAXSIG) |
216 | #elif defined (MAXSIG) |
207 | # define EV_NSIG (MAXSIG+1) |
217 | # define EV_NSIG (MAXSIG+1) |
208 | #elif defined (MAX_SIG) |
218 | #elif defined (MAX_SIG) |
209 | # define EV_NSIG (MAX_SIG+1) |
219 | # define EV_NSIG (MAX_SIG+1) |
210 | #elif defined (SIGARRAYSIZE) |
220 | #elif defined (SIGARRAYSIZE) |
211 | # define EV_NSIG SIGARRAYSIZE /* Assume ary[SIGARRAYSIZE] */ |
221 | # define EV_NSIG (SIGARRAYSIZE) /* Assume ary[SIGARRAYSIZE] */ |
212 | #elif defined (_sys_nsig) |
222 | #elif defined (_sys_nsig) |
213 | # define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ |
223 | # define EV_NSIG (_sys_nsig) /* Solaris 2.5 */ |
214 | #else |
224 | #else |
215 | # error "unable to find value for NSIG, please report" |
225 | # error "unable to find value for NSIG, please report" |
216 | /* to make it compile regardless, just remove the above line */ |
226 | /* to make it compile regardless, just remove the above line, */ |
|
|
227 | /* but consider reporting it, too! :) */ |
217 | # define EV_NSIG 65 |
228 | # define EV_NSIG 65 |
218 | #endif |
229 | #endif |
219 | |
230 | |
220 | #ifndef EV_USE_CLOCK_SYSCALL |
231 | #ifndef EV_USE_CLOCK_SYSCALL |
221 | # if __linux && __GLIBC__ >= 2 |
232 | # if __linux && __GLIBC__ >= 2 |
222 | # define EV_USE_CLOCK_SYSCALL 1 |
233 | # define EV_USE_CLOCK_SYSCALL EV_FEATURE_OS |
223 | # else |
234 | # else |
224 | # define EV_USE_CLOCK_SYSCALL 0 |
235 | # define EV_USE_CLOCK_SYSCALL 0 |
225 | # endif |
236 | # endif |
226 | #endif |
237 | #endif |
227 | |
238 | |
228 | #ifndef EV_USE_MONOTONIC |
239 | #ifndef EV_USE_MONOTONIC |
229 | # if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 |
240 | # if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 |
230 | # define EV_USE_MONOTONIC 1 |
241 | # define EV_USE_MONOTONIC EV_FEATURE_OS |
231 | # else |
242 | # else |
232 | # define EV_USE_MONOTONIC 0 |
243 | # define EV_USE_MONOTONIC 0 |
233 | # endif |
244 | # endif |
234 | #endif |
245 | #endif |
235 | |
246 | |
… | |
… | |
237 | # define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL |
248 | # define EV_USE_REALTIME !EV_USE_CLOCK_SYSCALL |
238 | #endif |
249 | #endif |
239 | |
250 | |
240 | #ifndef EV_USE_NANOSLEEP |
251 | #ifndef EV_USE_NANOSLEEP |
241 | # if _POSIX_C_SOURCE >= 199309L |
252 | # if _POSIX_C_SOURCE >= 199309L |
242 | # define EV_USE_NANOSLEEP 1 |
253 | # define EV_USE_NANOSLEEP EV_FEATURE_OS |
243 | # else |
254 | # else |
244 | # define EV_USE_NANOSLEEP 0 |
255 | # define EV_USE_NANOSLEEP 0 |
245 | # endif |
256 | # endif |
246 | #endif |
257 | #endif |
247 | |
258 | |
248 | #ifndef EV_USE_SELECT |
259 | #ifndef EV_USE_SELECT |
249 | # define EV_USE_SELECT 1 |
260 | # define EV_USE_SELECT EV_FEATURE_BACKENDS |
250 | #endif |
261 | #endif |
251 | |
262 | |
252 | #ifndef EV_USE_POLL |
263 | #ifndef EV_USE_POLL |
253 | # ifdef _WIN32 |
264 | # ifdef _WIN32 |
254 | # define EV_USE_POLL 0 |
265 | # define EV_USE_POLL 0 |
255 | # else |
266 | # else |
256 | # define EV_USE_POLL 1 |
267 | # define EV_USE_POLL EV_FEATURE_BACKENDS |
257 | # endif |
268 | # endif |
258 | #endif |
269 | #endif |
259 | |
270 | |
260 | #ifndef EV_USE_EPOLL |
271 | #ifndef EV_USE_EPOLL |
261 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
272 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
262 | # define EV_USE_EPOLL 1 |
273 | # define EV_USE_EPOLL EV_FEATURE_BACKENDS |
263 | # else |
274 | # else |
264 | # define EV_USE_EPOLL 0 |
275 | # define EV_USE_EPOLL 0 |
265 | # endif |
276 | # endif |
266 | #endif |
277 | #endif |
267 | |
278 | |
… | |
… | |
273 | # define EV_USE_PORT 0 |
284 | # define EV_USE_PORT 0 |
274 | #endif |
285 | #endif |
275 | |
286 | |
276 | #ifndef EV_USE_INOTIFY |
287 | #ifndef EV_USE_INOTIFY |
277 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
288 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) |
278 | # define EV_USE_INOTIFY 1 |
289 | # define EV_USE_INOTIFY EV_FEATURE_OS |
279 | # else |
290 | # else |
280 | # define EV_USE_INOTIFY 0 |
291 | # define EV_USE_INOTIFY 0 |
281 | # endif |
292 | # endif |
282 | #endif |
293 | #endif |
283 | |
294 | |
284 | #ifndef EV_PID_HASHSIZE |
295 | #ifndef EV_PID_HASHSIZE |
285 | # if EV_MINIMAL |
296 | # define EV_PID_HASHSIZE EV_FEATURE_DATA ? 16 : 1 |
286 | # define EV_PID_HASHSIZE 1 |
|
|
287 | # else |
|
|
288 | # define EV_PID_HASHSIZE 16 |
|
|
289 | # endif |
|
|
290 | #endif |
297 | #endif |
291 | |
298 | |
292 | #ifndef EV_INOTIFY_HASHSIZE |
299 | #ifndef EV_INOTIFY_HASHSIZE |
293 | # if EV_MINIMAL |
300 | # define EV_INOTIFY_HASHSIZE EV_FEATURE_DATA ? 16 : 1 |
294 | # define EV_INOTIFY_HASHSIZE 1 |
|
|
295 | # else |
|
|
296 | # define EV_INOTIFY_HASHSIZE 16 |
|
|
297 | # endif |
|
|
298 | #endif |
301 | #endif |
299 | |
302 | |
300 | #ifndef EV_USE_EVENTFD |
303 | #ifndef EV_USE_EVENTFD |
301 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
304 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
302 | # define EV_USE_EVENTFD 1 |
305 | # define EV_USE_EVENTFD EV_FEATURE_OS |
303 | # else |
306 | # else |
304 | # define EV_USE_EVENTFD 0 |
307 | # define EV_USE_EVENTFD 0 |
305 | # endif |
308 | # endif |
306 | #endif |
309 | #endif |
307 | |
310 | |
308 | #ifndef EV_USE_SIGNALFD |
311 | #ifndef EV_USE_SIGNALFD |
309 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
312 | # if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)) |
310 | # define EV_USE_SIGNALFD 1 |
313 | # define EV_USE_SIGNALFD EV_FEATURE_OS |
311 | # else |
314 | # else |
312 | # define EV_USE_SIGNALFD 0 |
315 | # define EV_USE_SIGNALFD 0 |
313 | # endif |
316 | # endif |
314 | #endif |
317 | #endif |
315 | |
318 | |
… | |
… | |
318 | # define EV_USE_4HEAP 1 |
321 | # define EV_USE_4HEAP 1 |
319 | # define EV_HEAP_CACHE_AT 1 |
322 | # define EV_HEAP_CACHE_AT 1 |
320 | #endif |
323 | #endif |
321 | |
324 | |
322 | #ifndef EV_VERIFY |
325 | #ifndef EV_VERIFY |
323 | # define EV_VERIFY !EV_MINIMAL |
326 | # define EV_VERIFY (EV_FEATURE_API ? 1 : 0) |
324 | #endif |
327 | #endif |
325 | |
328 | |
326 | #ifndef EV_USE_4HEAP |
329 | #ifndef EV_USE_4HEAP |
327 | # define EV_USE_4HEAP !EV_MINIMAL |
330 | # define EV_USE_4HEAP EV_FEATURE_DATA |
328 | #endif |
331 | #endif |
329 | |
332 | |
330 | #ifndef EV_HEAP_CACHE_AT |
333 | #ifndef EV_HEAP_CACHE_AT |
331 | # define EV_HEAP_CACHE_AT !EV_MINIMAL |
334 | # define EV_HEAP_CACHE_AT EV_FEATURE_DATA |
332 | #endif |
335 | #endif |
333 | |
336 | |
334 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
337 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
335 | /* which makes programs even slower. might work on other unices, too. */ |
338 | /* which makes programs even slower. might work on other unices, too. */ |
336 | #if EV_USE_CLOCK_SYSCALL |
339 | #if EV_USE_CLOCK_SYSCALL |
… | |
… | |
403 | # endif |
406 | # endif |
404 | # endif |
407 | # endif |
405 | # ifdef __cplusplus |
408 | # ifdef __cplusplus |
406 | extern "C" { |
409 | extern "C" { |
407 | # endif |
410 | # endif |
408 | int eventfd (unsigned int initval, int flags); |
411 | int (eventfd) (unsigned int initval, int flags); |
409 | # ifdef __cplusplus |
412 | # ifdef __cplusplus |
410 | } |
413 | } |
411 | # endif |
414 | # endif |
412 | #endif |
415 | #endif |
413 | |
416 | |
… | |
… | |
441 | |
444 | |
442 | |
445 | |
443 | /**/ |
446 | /**/ |
444 | |
447 | |
445 | #if EV_VERIFY >= 3 |
448 | #if EV_VERIFY >= 3 |
446 | # define EV_FREQUENT_CHECK ev_loop_verify (EV_A) |
449 | # define EV_FREQUENT_CHECK ev_verify (EV_A) |
447 | #else |
450 | #else |
448 | # define EV_FREQUENT_CHECK do { } while (0) |
451 | # define EV_FREQUENT_CHECK do { } while (0) |
449 | #endif |
452 | #endif |
450 | |
453 | |
451 | /* |
454 | /* |
… | |
… | |
474 | |
477 | |
475 | #define expect_false(expr) expect ((expr) != 0, 0) |
478 | #define expect_false(expr) expect ((expr) != 0, 0) |
476 | #define expect_true(expr) expect ((expr) != 0, 1) |
479 | #define expect_true(expr) expect ((expr) != 0, 1) |
477 | #define inline_size static inline |
480 | #define inline_size static inline |
478 | |
481 | |
479 | #if EV_MINIMAL |
482 | #if EV_FEATURE_CODE |
|
|
483 | # define inline_speed static inline |
|
|
484 | #else |
480 | # define inline_speed static noinline |
485 | # define inline_speed static noinline |
481 | #else |
|
|
482 | # define inline_speed static inline |
|
|
483 | #endif |
486 | #endif |
484 | |
487 | |
485 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
488 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
486 | |
489 | |
487 | #if EV_MINPRI == EV_MAXPRI |
490 | #if EV_MINPRI == EV_MAXPRI |
… | |
… | |
524 | # include "ev_win32.c" |
527 | # include "ev_win32.c" |
525 | #endif |
528 | #endif |
526 | |
529 | |
527 | /*****************************************************************************/ |
530 | /*****************************************************************************/ |
528 | |
531 | |
|
|
532 | #if EV_AVOID_STDIO |
|
|
533 | static void noinline |
|
|
534 | ev_printerr (const char *msg) |
|
|
535 | { |
|
|
536 | write (STDERR_FILENO, msg, strlen (msg)); |
|
|
537 | } |
|
|
538 | #endif |
|
|
539 | |
529 | static void (*syserr_cb)(const char *msg); |
540 | static void (*syserr_cb)(const char *msg); |
530 | |
541 | |
531 | void |
542 | void |
532 | ev_set_syserr_cb (void (*cb)(const char *msg)) |
543 | ev_set_syserr_cb (void (*cb)(const char *msg)) |
533 | { |
544 | { |
… | |
… | |
542 | |
553 | |
543 | if (syserr_cb) |
554 | if (syserr_cb) |
544 | syserr_cb (msg); |
555 | syserr_cb (msg); |
545 | else |
556 | else |
546 | { |
557 | { |
|
|
558 | #if EV_AVOID_STDIO |
|
|
559 | const char *err = strerror (errno); |
|
|
560 | |
|
|
561 | ev_printerr (msg); |
|
|
562 | ev_printerr (": "); |
|
|
563 | ev_printerr (err); |
|
|
564 | ev_printerr ("\n"); |
|
|
565 | #else |
547 | perror (msg); |
566 | perror (msg); |
|
|
567 | #endif |
548 | abort (); |
568 | abort (); |
549 | } |
569 | } |
550 | } |
570 | } |
551 | |
571 | |
552 | static void * |
572 | static void * |
553 | ev_realloc_emul (void *ptr, long size) |
573 | ev_realloc_emul (void *ptr, long size) |
554 | { |
574 | { |
|
|
575 | #if __GLIBC__ |
|
|
576 | return realloc (ptr, size); |
|
|
577 | #else |
555 | /* some systems, notably openbsd and darwin, fail to properly |
578 | /* some systems, notably openbsd and darwin, fail to properly |
556 | * implement realloc (x, 0) (as required by both ansi c-98 and |
579 | * implement realloc (x, 0) (as required by both ansi c-89 and |
557 | * the single unix specification, so work around them here. |
580 | * the single unix specification, so work around them here. |
558 | */ |
581 | */ |
559 | |
582 | |
560 | if (size) |
583 | if (size) |
561 | return realloc (ptr, size); |
584 | return realloc (ptr, size); |
562 | |
585 | |
563 | free (ptr); |
586 | free (ptr); |
564 | return 0; |
587 | return 0; |
|
|
588 | #endif |
565 | } |
589 | } |
566 | |
590 | |
567 | static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; |
591 | static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; |
568 | |
592 | |
569 | void |
593 | void |
… | |
… | |
577 | { |
601 | { |
578 | ptr = alloc (ptr, size); |
602 | ptr = alloc (ptr, size); |
579 | |
603 | |
580 | if (!ptr && size) |
604 | if (!ptr && size) |
581 | { |
605 | { |
|
|
606 | #if EV_AVOID_STDIO |
|
|
607 | ev_printerr ("libev: memory allocation failed, aborting.\n"); |
|
|
608 | #else |
582 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
609 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
|
|
610 | #endif |
583 | abort (); |
611 | abort (); |
584 | } |
612 | } |
585 | |
613 | |
586 | return ptr; |
614 | return ptr; |
587 | } |
615 | } |
… | |
… | |
669 | |
697 | |
670 | static int ev_default_loop_ptr; |
698 | static int ev_default_loop_ptr; |
671 | |
699 | |
672 | #endif |
700 | #endif |
673 | |
701 | |
674 | #if EV_MINIMAL < 2 |
702 | #if EV_FEATURE_API |
675 | # define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A) |
703 | # define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A) |
676 | # define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A) |
704 | # define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A) |
677 | # define EV_INVOKE_PENDING invoke_cb (EV_A) |
705 | # define EV_INVOKE_PENDING invoke_cb (EV_A) |
678 | #else |
706 | #else |
679 | # define EV_RELEASE_CB (void)0 |
707 | # define EV_RELEASE_CB (void)0 |
… | |
… | |
864 | } |
892 | } |
865 | |
893 | |
866 | /*****************************************************************************/ |
894 | /*****************************************************************************/ |
867 | |
895 | |
868 | inline_speed void |
896 | inline_speed void |
869 | fd_event_nc (EV_P_ int fd, int revents) |
897 | fd_event_nocheck (EV_P_ int fd, int revents) |
870 | { |
898 | { |
871 | ANFD *anfd = anfds + fd; |
899 | ANFD *anfd = anfds + fd; |
872 | ev_io *w; |
900 | ev_io *w; |
873 | |
901 | |
874 | for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) |
902 | for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) |
… | |
… | |
886 | fd_event (EV_P_ int fd, int revents) |
914 | fd_event (EV_P_ int fd, int revents) |
887 | { |
915 | { |
888 | ANFD *anfd = anfds + fd; |
916 | ANFD *anfd = anfds + fd; |
889 | |
917 | |
890 | if (expect_true (!anfd->reify)) |
918 | if (expect_true (!anfd->reify)) |
891 | fd_event_nc (EV_A_ fd, revents); |
919 | fd_event_nocheck (EV_A_ fd, revents); |
892 | } |
920 | } |
893 | |
921 | |
894 | void |
922 | void |
895 | ev_feed_fd_event (EV_P_ int fd, int revents) |
923 | ev_feed_fd_event (EV_P_ int fd, int revents) |
896 | { |
924 | { |
897 | if (fd >= 0 && fd < anfdmax) |
925 | if (fd >= 0 && fd < anfdmax) |
898 | fd_event_nc (EV_A_ fd, revents); |
926 | fd_event_nocheck (EV_A_ fd, revents); |
899 | } |
927 | } |
900 | |
928 | |
901 | /* make sure the external fd watch events are in-sync */ |
929 | /* make sure the external fd watch events are in-sync */ |
902 | /* with the kernel/libev internal state */ |
930 | /* with the kernel/libev internal state */ |
903 | inline_size void |
931 | inline_size void |
… | |
… | |
966 | ev_io_stop (EV_A_ w); |
994 | ev_io_stop (EV_A_ w); |
967 | ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); |
995 | ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); |
968 | } |
996 | } |
969 | } |
997 | } |
970 | |
998 | |
971 | /* check whether the given fd is atcually valid, for error recovery */ |
999 | /* check whether the given fd is actually valid, for error recovery */ |
972 | inline_size int |
1000 | inline_size int |
973 | fd_valid (int fd) |
1001 | fd_valid (int fd) |
974 | { |
1002 | { |
975 | #ifdef _WIN32 |
1003 | #ifdef _WIN32 |
976 | return EV_FD_TO_WIN32_HANDLE (fd) != -1; |
1004 | return EV_FD_TO_WIN32_HANDLE (fd) != -1; |
… | |
… | |
1016 | { |
1044 | { |
1017 | anfds [fd].events = 0; |
1045 | anfds [fd].events = 0; |
1018 | anfds [fd].emask = 0; |
1046 | anfds [fd].emask = 0; |
1019 | fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); |
1047 | fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY); |
1020 | } |
1048 | } |
|
|
1049 | } |
|
|
1050 | |
|
|
1051 | /* used to prepare libev internal fd's */ |
|
|
1052 | /* this is not fork-safe */ |
|
|
1053 | inline_speed void |
|
|
1054 | fd_intern (int fd) |
|
|
1055 | { |
|
|
1056 | #ifdef _WIN32 |
|
|
1057 | unsigned long arg = 1; |
|
|
1058 | ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg); |
|
|
1059 | #else |
|
|
1060 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
1061 | fcntl (fd, F_SETFL, O_NONBLOCK); |
|
|
1062 | #endif |
1021 | } |
1063 | } |
1022 | |
1064 | |
1023 | /*****************************************************************************/ |
1065 | /*****************************************************************************/ |
1024 | |
1066 | |
1025 | /* |
1067 | /* |
… | |
… | |
1179 | |
1221 | |
1180 | static ANSIG signals [EV_NSIG - 1]; |
1222 | static ANSIG signals [EV_NSIG - 1]; |
1181 | |
1223 | |
1182 | /*****************************************************************************/ |
1224 | /*****************************************************************************/ |
1183 | |
1225 | |
1184 | /* used to prepare libev internal fd's */ |
1226 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
1185 | /* this is not fork-safe */ |
|
|
1186 | inline_speed void |
|
|
1187 | fd_intern (int fd) |
|
|
1188 | { |
|
|
1189 | #ifdef _WIN32 |
|
|
1190 | unsigned long arg = 1; |
|
|
1191 | ioctlsocket (EV_FD_TO_WIN32_HANDLE (fd), FIONBIO, &arg); |
|
|
1192 | #else |
|
|
1193 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
1194 | fcntl (fd, F_SETFL, O_NONBLOCK); |
|
|
1195 | #endif |
|
|
1196 | } |
|
|
1197 | |
1227 | |
1198 | static void noinline |
1228 | static void noinline |
1199 | evpipe_init (EV_P) |
1229 | evpipe_init (EV_P) |
1200 | { |
1230 | { |
1201 | if (!ev_is_active (&pipe_w)) |
1231 | if (!ev_is_active (&pipe_w)) |
1202 | { |
1232 | { |
1203 | #if EV_USE_EVENTFD |
1233 | # if EV_USE_EVENTFD |
1204 | evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); |
1234 | evfd = eventfd (0, EFD_NONBLOCK | EFD_CLOEXEC); |
1205 | if (evfd < 0 && errno == EINVAL) |
1235 | if (evfd < 0 && errno == EINVAL) |
1206 | evfd = eventfd (0, 0); |
1236 | evfd = eventfd (0, 0); |
1207 | |
1237 | |
1208 | if (evfd >= 0) |
1238 | if (evfd >= 0) |
… | |
… | |
1210 | evpipe [0] = -1; |
1240 | evpipe [0] = -1; |
1211 | fd_intern (evfd); /* doing it twice doesn't hurt */ |
1241 | fd_intern (evfd); /* doing it twice doesn't hurt */ |
1212 | ev_io_set (&pipe_w, evfd, EV_READ); |
1242 | ev_io_set (&pipe_w, evfd, EV_READ); |
1213 | } |
1243 | } |
1214 | else |
1244 | else |
1215 | #endif |
1245 | # endif |
1216 | { |
1246 | { |
1217 | while (pipe (evpipe)) |
1247 | while (pipe (evpipe)) |
1218 | ev_syserr ("(libev) error creating signal/async pipe"); |
1248 | ev_syserr ("(libev) error creating signal/async pipe"); |
1219 | |
1249 | |
1220 | fd_intern (evpipe [0]); |
1250 | fd_intern (evpipe [0]); |
… | |
… | |
1231 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
1261 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
1232 | { |
1262 | { |
1233 | if (!*flag) |
1263 | if (!*flag) |
1234 | { |
1264 | { |
1235 | int old_errno = errno; /* save errno because write might clobber it */ |
1265 | int old_errno = errno; /* save errno because write might clobber it */ |
|
|
1266 | char dummy; |
1236 | |
1267 | |
1237 | *flag = 1; |
1268 | *flag = 1; |
1238 | |
1269 | |
1239 | #if EV_USE_EVENTFD |
1270 | #if EV_USE_EVENTFD |
1240 | if (evfd >= 0) |
1271 | if (evfd >= 0) |
… | |
… | |
1242 | uint64_t counter = 1; |
1273 | uint64_t counter = 1; |
1243 | write (evfd, &counter, sizeof (uint64_t)); |
1274 | write (evfd, &counter, sizeof (uint64_t)); |
1244 | } |
1275 | } |
1245 | else |
1276 | else |
1246 | #endif |
1277 | #endif |
1247 | write (evpipe [1], &old_errno, 1); |
1278 | write (evpipe [1], &dummy, 1); |
1248 | |
1279 | |
1249 | errno = old_errno; |
1280 | errno = old_errno; |
1250 | } |
1281 | } |
1251 | } |
1282 | } |
1252 | |
1283 | |
… | |
… | |
1353 | break; |
1384 | break; |
1354 | } |
1385 | } |
1355 | } |
1386 | } |
1356 | #endif |
1387 | #endif |
1357 | |
1388 | |
|
|
1389 | #endif |
|
|
1390 | |
1358 | /*****************************************************************************/ |
1391 | /*****************************************************************************/ |
1359 | |
1392 | |
|
|
1393 | #if EV_CHILD_ENABLE |
1360 | static WL childs [EV_PID_HASHSIZE]; |
1394 | static WL childs [EV_PID_HASHSIZE]; |
1361 | |
|
|
1362 | #ifndef _WIN32 |
|
|
1363 | |
1395 | |
1364 | static ev_signal childev; |
1396 | static ev_signal childev; |
1365 | |
1397 | |
1366 | #ifndef WIFCONTINUED |
1398 | #ifndef WIFCONTINUED |
1367 | # define WIFCONTINUED(status) 0 |
1399 | # define WIFCONTINUED(status) 0 |
… | |
… | |
1372 | child_reap (EV_P_ int chain, int pid, int status) |
1404 | child_reap (EV_P_ int chain, int pid, int status) |
1373 | { |
1405 | { |
1374 | ev_child *w; |
1406 | ev_child *w; |
1375 | int traced = WIFSTOPPED (status) || WIFCONTINUED (status); |
1407 | int traced = WIFSTOPPED (status) || WIFCONTINUED (status); |
1376 | |
1408 | |
1377 | for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) |
1409 | for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) |
1378 | { |
1410 | { |
1379 | if ((w->pid == pid || !w->pid) |
1411 | if ((w->pid == pid || !w->pid) |
1380 | && (!traced || (w->flags & 1))) |
1412 | && (!traced || (w->flags & 1))) |
1381 | { |
1413 | { |
1382 | ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */ |
1414 | ev_set_priority (w, EV_MAXPRI); /* need to do it *now*, this *must* be the same prio as the signal watcher itself */ |
… | |
… | |
1407 | /* make sure we are called again until all children have been reaped */ |
1439 | /* make sure we are called again until all children have been reaped */ |
1408 | /* we need to do it this way so that the callback gets called before we continue */ |
1440 | /* we need to do it this way so that the callback gets called before we continue */ |
1409 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
1441 | ev_feed_event (EV_A_ (W)sw, EV_SIGNAL); |
1410 | |
1442 | |
1411 | child_reap (EV_A_ pid, pid, status); |
1443 | child_reap (EV_A_ pid, pid, status); |
1412 | if (EV_PID_HASHSIZE > 1) |
1444 | if ((EV_PID_HASHSIZE) > 1) |
1413 | child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ |
1445 | child_reap (EV_A_ 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */ |
1414 | } |
1446 | } |
1415 | |
1447 | |
1416 | #endif |
1448 | #endif |
1417 | |
1449 | |
… | |
… | |
1484 | #ifdef __APPLE__ |
1516 | #ifdef __APPLE__ |
1485 | /* only select works correctly on that "unix-certified" platform */ |
1517 | /* only select works correctly on that "unix-certified" platform */ |
1486 | flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ |
1518 | flags &= ~EVBACKEND_KQUEUE; /* horribly broken, even for sockets */ |
1487 | flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ |
1519 | flags &= ~EVBACKEND_POLL; /* poll is based on kqueue from 10.5 onwards */ |
1488 | #endif |
1520 | #endif |
|
|
1521 | #ifdef __FreeBSD__ |
|
|
1522 | flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ |
|
|
1523 | #endif |
1489 | |
1524 | |
1490 | return flags; |
1525 | return flags; |
1491 | } |
1526 | } |
1492 | |
1527 | |
1493 | unsigned int |
1528 | unsigned int |
… | |
… | |
1506 | ev_backend (EV_P) |
1541 | ev_backend (EV_P) |
1507 | { |
1542 | { |
1508 | return backend; |
1543 | return backend; |
1509 | } |
1544 | } |
1510 | |
1545 | |
1511 | #if EV_MINIMAL < 2 |
1546 | #if EV_FEATURE_API |
1512 | unsigned int |
1547 | unsigned int |
1513 | ev_loop_count (EV_P) |
1548 | ev_iteration (EV_P) |
1514 | { |
1549 | { |
1515 | return loop_count; |
1550 | return loop_count; |
1516 | } |
1551 | } |
1517 | |
1552 | |
1518 | unsigned int |
1553 | unsigned int |
1519 | ev_loop_depth (EV_P) |
1554 | ev_depth (EV_P) |
1520 | { |
1555 | { |
1521 | return loop_depth; |
1556 | return loop_depth; |
1522 | } |
1557 | } |
1523 | |
1558 | |
1524 | void |
1559 | void |
… | |
… | |
1596 | |
1631 | |
1597 | ev_rt_now = ev_time (); |
1632 | ev_rt_now = ev_time (); |
1598 | mn_now = get_clock (); |
1633 | mn_now = get_clock (); |
1599 | now_floor = mn_now; |
1634 | now_floor = mn_now; |
1600 | rtmn_diff = ev_rt_now - mn_now; |
1635 | rtmn_diff = ev_rt_now - mn_now; |
1601 | #if EV_MINIMAL < 2 |
1636 | #if EV_FEATURE_API |
1602 | invoke_cb = ev_invoke_pending; |
1637 | invoke_cb = ev_invoke_pending; |
1603 | #endif |
1638 | #endif |
1604 | |
1639 | |
1605 | io_blocktime = 0.; |
1640 | io_blocktime = 0.; |
1606 | timeout_blocktime = 0.; |
1641 | timeout_blocktime = 0.; |
… | |
… | |
1636 | if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); |
1671 | if (!backend && (flags & EVBACKEND_SELECT)) backend = select_init (EV_A_ flags); |
1637 | #endif |
1672 | #endif |
1638 | |
1673 | |
1639 | ev_prepare_init (&pending_w, pendingcb); |
1674 | ev_prepare_init (&pending_w, pendingcb); |
1640 | |
1675 | |
|
|
1676 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
1641 | ev_init (&pipe_w, pipecb); |
1677 | ev_init (&pipe_w, pipecb); |
1642 | ev_set_priority (&pipe_w, EV_MAXPRI); |
1678 | ev_set_priority (&pipe_w, EV_MAXPRI); |
|
|
1679 | #endif |
1643 | } |
1680 | } |
1644 | } |
1681 | } |
1645 | |
1682 | |
1646 | /* free up a loop structure */ |
1683 | /* free up a loop structure */ |
1647 | static void noinline |
1684 | static void noinline |
… | |
… | |
1765 | { |
1802 | { |
1766 | EV_WIN32_CLOSE_FD (evpipe [0]); |
1803 | EV_WIN32_CLOSE_FD (evpipe [0]); |
1767 | EV_WIN32_CLOSE_FD (evpipe [1]); |
1804 | EV_WIN32_CLOSE_FD (evpipe [1]); |
1768 | } |
1805 | } |
1769 | |
1806 | |
|
|
1807 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
1770 | evpipe_init (EV_A); |
1808 | evpipe_init (EV_A); |
1771 | /* now iterate over everything, in case we missed something */ |
1809 | /* now iterate over everything, in case we missed something */ |
1772 | pipecb (EV_A_ &pipe_w, EV_READ); |
1810 | pipecb (EV_A_ &pipe_w, EV_READ); |
|
|
1811 | #endif |
1773 | } |
1812 | } |
1774 | |
1813 | |
1775 | postfork = 0; |
1814 | postfork = 0; |
1776 | } |
1815 | } |
1777 | |
1816 | |
… | |
… | |
1839 | verify_watcher (EV_A_ ws [cnt]); |
1878 | verify_watcher (EV_A_ ws [cnt]); |
1840 | } |
1879 | } |
1841 | } |
1880 | } |
1842 | #endif |
1881 | #endif |
1843 | |
1882 | |
1844 | #if EV_MINIMAL < 2 |
1883 | #if EV_FEATURE_API |
1845 | void |
1884 | void |
1846 | ev_loop_verify (EV_P) |
1885 | ev_verify (EV_P) |
1847 | { |
1886 | { |
1848 | #if EV_VERIFY |
1887 | #if EV_VERIFY |
1849 | int i; |
1888 | int i; |
1850 | WL w; |
1889 | WL w; |
1851 | |
1890 | |
… | |
… | |
1890 | #if EV_ASYNC_ENABLE |
1929 | #if EV_ASYNC_ENABLE |
1891 | assert (asyncmax >= asynccnt); |
1930 | assert (asyncmax >= asynccnt); |
1892 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
1931 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
1893 | #endif |
1932 | #endif |
1894 | |
1933 | |
|
|
1934 | #if EV_PREPARE_ENABLE |
1895 | assert (preparemax >= preparecnt); |
1935 | assert (preparemax >= preparecnt); |
1896 | array_verify (EV_A_ (W *)prepares, preparecnt); |
1936 | array_verify (EV_A_ (W *)prepares, preparecnt); |
|
|
1937 | #endif |
1897 | |
1938 | |
|
|
1939 | #if EV_CHECK_ENABLE |
1898 | assert (checkmax >= checkcnt); |
1940 | assert (checkmax >= checkcnt); |
1899 | array_verify (EV_A_ (W *)checks, checkcnt); |
1941 | array_verify (EV_A_ (W *)checks, checkcnt); |
|
|
1942 | #endif |
1900 | |
1943 | |
1901 | # if 0 |
1944 | # if 0 |
|
|
1945 | #if EV_CHILD_ENABLE |
1902 | for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) |
1946 | for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) |
1903 | for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) |
1947 | for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) |
|
|
1948 | #endif |
1904 | # endif |
1949 | # endif |
1905 | #endif |
1950 | #endif |
1906 | } |
1951 | } |
1907 | #endif |
1952 | #endif |
1908 | |
1953 | |
… | |
… | |
1924 | |
1969 | |
1925 | loop_init (EV_A_ flags); |
1970 | loop_init (EV_A_ flags); |
1926 | |
1971 | |
1927 | if (ev_backend (EV_A)) |
1972 | if (ev_backend (EV_A)) |
1928 | { |
1973 | { |
1929 | #ifndef _WIN32 |
1974 | #if EV_CHILD_ENABLE |
1930 | ev_signal_init (&childev, childcb, SIGCHLD); |
1975 | ev_signal_init (&childev, childcb, SIGCHLD); |
1931 | ev_set_priority (&childev, EV_MAXPRI); |
1976 | ev_set_priority (&childev, EV_MAXPRI); |
1932 | ev_signal_start (EV_A_ &childev); |
1977 | ev_signal_start (EV_A_ &childev); |
1933 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
1978 | ev_unref (EV_A); /* child watcher should not keep loop alive */ |
1934 | #endif |
1979 | #endif |
… | |
… | |
1947 | EV_P = ev_default_loop_ptr; |
1992 | EV_P = ev_default_loop_ptr; |
1948 | #endif |
1993 | #endif |
1949 | |
1994 | |
1950 | ev_default_loop_ptr = 0; |
1995 | ev_default_loop_ptr = 0; |
1951 | |
1996 | |
1952 | #ifndef _WIN32 |
1997 | #if EV_CHILD_ENABLE |
1953 | ev_ref (EV_A); /* child watcher */ |
1998 | ev_ref (EV_A); /* child watcher */ |
1954 | ev_signal_stop (EV_A_ &childev); |
1999 | ev_signal_stop (EV_A_ &childev); |
1955 | #endif |
2000 | #endif |
1956 | |
2001 | |
1957 | loop_destroy (EV_A); |
2002 | loop_destroy (EV_A); |
… | |
… | |
2063 | EV_FREQUENT_CHECK; |
2108 | EV_FREQUENT_CHECK; |
2064 | feed_reverse (EV_A_ (W)w); |
2109 | feed_reverse (EV_A_ (W)w); |
2065 | } |
2110 | } |
2066 | while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); |
2111 | while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); |
2067 | |
2112 | |
2068 | feed_reverse_done (EV_A_ EV_TIMEOUT); |
2113 | feed_reverse_done (EV_A_ EV_TIMER); |
2069 | } |
2114 | } |
2070 | } |
2115 | } |
2071 | |
2116 | |
2072 | #if EV_PERIODIC_ENABLE |
2117 | #if EV_PERIODIC_ENABLE |
2073 | /* make periodics pending */ |
2118 | /* make periodics pending */ |
… | |
… | |
2234 | } |
2279 | } |
2235 | |
2280 | |
2236 | void |
2281 | void |
2237 | ev_loop (EV_P_ int flags) |
2282 | ev_loop (EV_P_ int flags) |
2238 | { |
2283 | { |
2239 | #if EV_MINIMAL < 2 |
2284 | #if EV_FEATURE_API |
2240 | ++loop_depth; |
2285 | ++loop_depth; |
2241 | #endif |
2286 | #endif |
2242 | |
2287 | |
2243 | assert (("libev: ev_loop recursion during release detected", loop_done != EVUNLOOP_RECURSE)); |
2288 | assert (("libev: ev_loop recursion during release detected", loop_done != EVUNLOOP_RECURSE)); |
2244 | |
2289 | |
… | |
… | |
2247 | EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ |
2292 | EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */ |
2248 | |
2293 | |
2249 | do |
2294 | do |
2250 | { |
2295 | { |
2251 | #if EV_VERIFY >= 2 |
2296 | #if EV_VERIFY >= 2 |
2252 | ev_loop_verify (EV_A); |
2297 | ev_verify (EV_A); |
2253 | #endif |
2298 | #endif |
2254 | |
2299 | |
2255 | #ifndef _WIN32 |
2300 | #ifndef _WIN32 |
2256 | if (expect_false (curpid)) /* penalise the forking check even more */ |
2301 | if (expect_false (curpid)) /* penalise the forking check even more */ |
2257 | if (expect_false (getpid () != curpid)) |
2302 | if (expect_false (getpid () != curpid)) |
… | |
… | |
2269 | queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); |
2314 | queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); |
2270 | EV_INVOKE_PENDING; |
2315 | EV_INVOKE_PENDING; |
2271 | } |
2316 | } |
2272 | #endif |
2317 | #endif |
2273 | |
2318 | |
|
|
2319 | #if EV_PREPARE_ENABLE |
2274 | /* queue prepare watchers (and execute them) */ |
2320 | /* queue prepare watchers (and execute them) */ |
2275 | if (expect_false (preparecnt)) |
2321 | if (expect_false (preparecnt)) |
2276 | { |
2322 | { |
2277 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
2323 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
2278 | EV_INVOKE_PENDING; |
2324 | EV_INVOKE_PENDING; |
2279 | } |
2325 | } |
|
|
2326 | #endif |
2280 | |
2327 | |
2281 | if (expect_false (loop_done)) |
2328 | if (expect_false (loop_done)) |
2282 | break; |
2329 | break; |
2283 | |
2330 | |
2284 | /* we might have forked, so reify kernel state if necessary */ |
2331 | /* we might have forked, so reify kernel state if necessary */ |
… | |
… | |
2335 | waittime -= sleeptime; |
2382 | waittime -= sleeptime; |
2336 | } |
2383 | } |
2337 | } |
2384 | } |
2338 | } |
2385 | } |
2339 | |
2386 | |
2340 | #if EV_MINIMAL < 2 |
2387 | #if EV_FEATURE_API |
2341 | ++loop_count; |
2388 | ++loop_count; |
2342 | #endif |
2389 | #endif |
2343 | assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */ |
2390 | assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */ |
2344 | backend_poll (EV_A_ waittime); |
2391 | backend_poll (EV_A_ waittime); |
2345 | assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */ |
2392 | assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */ |
… | |
… | |
2357 | #if EV_IDLE_ENABLE |
2404 | #if EV_IDLE_ENABLE |
2358 | /* queue idle watchers unless other events are pending */ |
2405 | /* queue idle watchers unless other events are pending */ |
2359 | idle_reify (EV_A); |
2406 | idle_reify (EV_A); |
2360 | #endif |
2407 | #endif |
2361 | |
2408 | |
|
|
2409 | #if EV_CHECK_ENABLE |
2362 | /* queue check watchers, to be executed first */ |
2410 | /* queue check watchers, to be executed first */ |
2363 | if (expect_false (checkcnt)) |
2411 | if (expect_false (checkcnt)) |
2364 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
2412 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
|
|
2413 | #endif |
2365 | |
2414 | |
2366 | EV_INVOKE_PENDING; |
2415 | EV_INVOKE_PENDING; |
2367 | } |
2416 | } |
2368 | while (expect_true ( |
2417 | while (expect_true ( |
2369 | activecnt |
2418 | activecnt |
… | |
… | |
2372 | )); |
2421 | )); |
2373 | |
2422 | |
2374 | if (loop_done == EVUNLOOP_ONE) |
2423 | if (loop_done == EVUNLOOP_ONE) |
2375 | loop_done = EVUNLOOP_CANCEL; |
2424 | loop_done = EVUNLOOP_CANCEL; |
2376 | |
2425 | |
2377 | #if EV_MINIMAL < 2 |
2426 | #if EV_FEATURE_API |
2378 | --loop_depth; |
2427 | --loop_depth; |
2379 | #endif |
2428 | #endif |
2380 | } |
2429 | } |
2381 | |
2430 | |
2382 | void |
2431 | void |
… | |
… | |
2699 | |
2748 | |
2700 | #ifndef SA_RESTART |
2749 | #ifndef SA_RESTART |
2701 | # define SA_RESTART 0 |
2750 | # define SA_RESTART 0 |
2702 | #endif |
2751 | #endif |
2703 | |
2752 | |
|
|
2753 | #if EV_SIGNAL_ENABLE |
|
|
2754 | |
2704 | void noinline |
2755 | void noinline |
2705 | ev_signal_start (EV_P_ ev_signal *w) |
2756 | ev_signal_start (EV_P_ ev_signal *w) |
2706 | { |
2757 | { |
2707 | if (expect_false (ev_is_active (w))) |
2758 | if (expect_false (ev_is_active (w))) |
2708 | return; |
2759 | return; |
… | |
… | |
2814 | } |
2865 | } |
2815 | |
2866 | |
2816 | EV_FREQUENT_CHECK; |
2867 | EV_FREQUENT_CHECK; |
2817 | } |
2868 | } |
2818 | |
2869 | |
|
|
2870 | #endif |
|
|
2871 | |
|
|
2872 | #if EV_CHILD_ENABLE |
|
|
2873 | |
2819 | void |
2874 | void |
2820 | ev_child_start (EV_P_ ev_child *w) |
2875 | ev_child_start (EV_P_ ev_child *w) |
2821 | { |
2876 | { |
2822 | #if EV_MULTIPLICITY |
2877 | #if EV_MULTIPLICITY |
2823 | assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
2878 | assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
… | |
… | |
2826 | return; |
2881 | return; |
2827 | |
2882 | |
2828 | EV_FREQUENT_CHECK; |
2883 | EV_FREQUENT_CHECK; |
2829 | |
2884 | |
2830 | ev_start (EV_A_ (W)w, 1); |
2885 | ev_start (EV_A_ (W)w, 1); |
2831 | wlist_add (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
2886 | wlist_add (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); |
2832 | |
2887 | |
2833 | EV_FREQUENT_CHECK; |
2888 | EV_FREQUENT_CHECK; |
2834 | } |
2889 | } |
2835 | |
2890 | |
2836 | void |
2891 | void |
… | |
… | |
2840 | if (expect_false (!ev_is_active (w))) |
2895 | if (expect_false (!ev_is_active (w))) |
2841 | return; |
2896 | return; |
2842 | |
2897 | |
2843 | EV_FREQUENT_CHECK; |
2898 | EV_FREQUENT_CHECK; |
2844 | |
2899 | |
2845 | wlist_del (&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w); |
2900 | wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); |
2846 | ev_stop (EV_A_ (W)w); |
2901 | ev_stop (EV_A_ (W)w); |
2847 | |
2902 | |
2848 | EV_FREQUENT_CHECK; |
2903 | EV_FREQUENT_CHECK; |
2849 | } |
2904 | } |
|
|
2905 | |
|
|
2906 | #endif |
2850 | |
2907 | |
2851 | #if EV_STAT_ENABLE |
2908 | #if EV_STAT_ENABLE |
2852 | |
2909 | |
2853 | # ifdef _WIN32 |
2910 | # ifdef _WIN32 |
2854 | # undef lstat |
2911 | # undef lstat |
… | |
… | |
2921 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2978 | while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); |
2922 | } |
2979 | } |
2923 | } |
2980 | } |
2924 | |
2981 | |
2925 | if (w->wd >= 0) |
2982 | if (w->wd >= 0) |
2926 | wlist_add (&fs_hash [w->wd & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
2983 | wlist_add (&fs_hash [w->wd & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); |
2927 | |
2984 | |
2928 | /* now re-arm timer, if required */ |
2985 | /* now re-arm timer, if required */ |
2929 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
2986 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
2930 | ev_timer_again (EV_A_ &w->timer); |
2987 | ev_timer_again (EV_A_ &w->timer); |
2931 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
2988 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
… | |
… | |
2939 | |
2996 | |
2940 | if (wd < 0) |
2997 | if (wd < 0) |
2941 | return; |
2998 | return; |
2942 | |
2999 | |
2943 | w->wd = -2; |
3000 | w->wd = -2; |
2944 | slot = wd & (EV_INOTIFY_HASHSIZE - 1); |
3001 | slot = wd & ((EV_INOTIFY_HASHSIZE) - 1); |
2945 | wlist_del (&fs_hash [slot].head, (WL)w); |
3002 | wlist_del (&fs_hash [slot].head, (WL)w); |
2946 | |
3003 | |
2947 | /* remove this watcher, if others are watching it, they will rearm */ |
3004 | /* remove this watcher, if others are watching it, they will rearm */ |
2948 | inotify_rm_watch (fs_fd, wd); |
3005 | inotify_rm_watch (fs_fd, wd); |
2949 | } |
3006 | } |
… | |
… | |
2951 | static void noinline |
3008 | static void noinline |
2952 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
3009 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
2953 | { |
3010 | { |
2954 | if (slot < 0) |
3011 | if (slot < 0) |
2955 | /* overflow, need to check for all hash slots */ |
3012 | /* overflow, need to check for all hash slots */ |
2956 | for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) |
3013 | for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) |
2957 | infy_wd (EV_A_ slot, wd, ev); |
3014 | infy_wd (EV_A_ slot, wd, ev); |
2958 | else |
3015 | else |
2959 | { |
3016 | { |
2960 | WL w_; |
3017 | WL w_; |
2961 | |
3018 | |
2962 | for (w_ = fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head; w_; ) |
3019 | for (w_ = fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head; w_; ) |
2963 | { |
3020 | { |
2964 | ev_stat *w = (ev_stat *)w_; |
3021 | ev_stat *w = (ev_stat *)w_; |
2965 | w_ = w_->next; /* lets us remove this watcher and all before it */ |
3022 | w_ = w_->next; /* lets us remove this watcher and all before it */ |
2966 | |
3023 | |
2967 | if (w->wd == wd || wd == -1) |
3024 | if (w->wd == wd || wd == -1) |
2968 | { |
3025 | { |
2969 | if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) |
3026 | if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) |
2970 | { |
3027 | { |
2971 | wlist_del (&fs_hash [slot & (EV_INOTIFY_HASHSIZE - 1)].head, (WL)w); |
3028 | wlist_del (&fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); |
2972 | w->wd = -1; |
3029 | w->wd = -1; |
2973 | infy_add (EV_A_ w); /* re-add, no matter what */ |
3030 | infy_add (EV_A_ w); /* re-add, no matter what */ |
2974 | } |
3031 | } |
2975 | |
3032 | |
2976 | stat_timer_cb (EV_A_ &w->timer, 0); |
3033 | stat_timer_cb (EV_A_ &w->timer, 0); |
… | |
… | |
2992 | infy_wd (EV_A_ ev->wd, ev->wd, ev); |
3049 | infy_wd (EV_A_ ev->wd, ev->wd, ev); |
2993 | ofs += sizeof (struct inotify_event) + ev->len; |
3050 | ofs += sizeof (struct inotify_event) + ev->len; |
2994 | } |
3051 | } |
2995 | } |
3052 | } |
2996 | |
3053 | |
|
|
3054 | inline_size unsigned int |
|
|
3055 | ev_linux_version (void) |
|
|
3056 | { |
|
|
3057 | struct utsname buf; |
|
|
3058 | unsigned int v; |
|
|
3059 | int i; |
|
|
3060 | char *p = buf.release; |
|
|
3061 | |
|
|
3062 | if (uname (&buf)) |
|
|
3063 | return 0; |
|
|
3064 | |
|
|
3065 | for (i = 3+1; --i; ) |
|
|
3066 | { |
|
|
3067 | unsigned int c = 0; |
|
|
3068 | |
|
|
3069 | for (;;) |
|
|
3070 | { |
|
|
3071 | if (*p >= '0' && *p <= '9') |
|
|
3072 | c = c * 10 + *p++ - '0'; |
|
|
3073 | else |
|
|
3074 | { |
|
|
3075 | p += *p == '.'; |
|
|
3076 | break; |
|
|
3077 | } |
|
|
3078 | } |
|
|
3079 | |
|
|
3080 | v = (v << 8) | c; |
|
|
3081 | } |
|
|
3082 | |
|
|
3083 | return v; |
|
|
3084 | } |
|
|
3085 | |
2997 | inline_size void |
3086 | inline_size void |
2998 | check_2625 (EV_P) |
3087 | ev_check_2625 (EV_P) |
2999 | { |
3088 | { |
3000 | /* kernels < 2.6.25 are borked |
3089 | /* kernels < 2.6.25 are borked |
3001 | * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html |
3090 | * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html |
3002 | */ |
3091 | */ |
3003 | struct utsname buf; |
3092 | if (ev_linux_version () < 0x020619) |
3004 | int major, minor, micro; |
|
|
3005 | |
|
|
3006 | if (uname (&buf)) |
|
|
3007 | return; |
|
|
3008 | |
|
|
3009 | if (sscanf (buf.release, "%d.%d.%d", &major, &minor, µ) != 3) |
|
|
3010 | return; |
|
|
3011 | |
|
|
3012 | if (major < 2 |
|
|
3013 | || (major == 2 && minor < 6) |
|
|
3014 | || (major == 2 && minor == 6 && micro < 25)) |
|
|
3015 | return; |
3093 | return; |
3016 | |
3094 | |
3017 | fs_2625 = 1; |
3095 | fs_2625 = 1; |
3018 | } |
3096 | } |
3019 | |
3097 | |
… | |
… | |
3034 | if (fs_fd != -2) |
3112 | if (fs_fd != -2) |
3035 | return; |
3113 | return; |
3036 | |
3114 | |
3037 | fs_fd = -1; |
3115 | fs_fd = -1; |
3038 | |
3116 | |
3039 | check_2625 (EV_A); |
3117 | ev_check_2625 (EV_A); |
3040 | |
3118 | |
3041 | fs_fd = infy_newfd (); |
3119 | fs_fd = infy_newfd (); |
3042 | |
3120 | |
3043 | if (fs_fd >= 0) |
3121 | if (fs_fd >= 0) |
3044 | { |
3122 | { |
… | |
… | |
3069 | ev_io_set (&fs_w, fs_fd, EV_READ); |
3147 | ev_io_set (&fs_w, fs_fd, EV_READ); |
3070 | ev_io_start (EV_A_ &fs_w); |
3148 | ev_io_start (EV_A_ &fs_w); |
3071 | ev_unref (EV_A); |
3149 | ev_unref (EV_A); |
3072 | } |
3150 | } |
3073 | |
3151 | |
3074 | for (slot = 0; slot < EV_INOTIFY_HASHSIZE; ++slot) |
3152 | for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) |
3075 | { |
3153 | { |
3076 | WL w_ = fs_hash [slot].head; |
3154 | WL w_ = fs_hash [slot].head; |
3077 | fs_hash [slot].head = 0; |
3155 | fs_hash [slot].head = 0; |
3078 | |
3156 | |
3079 | while (w_) |
3157 | while (w_) |
… | |
… | |
3254 | |
3332 | |
3255 | EV_FREQUENT_CHECK; |
3333 | EV_FREQUENT_CHECK; |
3256 | } |
3334 | } |
3257 | #endif |
3335 | #endif |
3258 | |
3336 | |
|
|
3337 | #if EV_PREPARE_ENABLE |
3259 | void |
3338 | void |
3260 | ev_prepare_start (EV_P_ ev_prepare *w) |
3339 | ev_prepare_start (EV_P_ ev_prepare *w) |
3261 | { |
3340 | { |
3262 | if (expect_false (ev_is_active (w))) |
3341 | if (expect_false (ev_is_active (w))) |
3263 | return; |
3342 | return; |
… | |
… | |
3289 | |
3368 | |
3290 | ev_stop (EV_A_ (W)w); |
3369 | ev_stop (EV_A_ (W)w); |
3291 | |
3370 | |
3292 | EV_FREQUENT_CHECK; |
3371 | EV_FREQUENT_CHECK; |
3293 | } |
3372 | } |
|
|
3373 | #endif |
3294 | |
3374 | |
|
|
3375 | #if EV_CHECK_ENABLE |
3295 | void |
3376 | void |
3296 | ev_check_start (EV_P_ ev_check *w) |
3377 | ev_check_start (EV_P_ ev_check *w) |
3297 | { |
3378 | { |
3298 | if (expect_false (ev_is_active (w))) |
3379 | if (expect_false (ev_is_active (w))) |
3299 | return; |
3380 | return; |
… | |
… | |
3325 | |
3406 | |
3326 | ev_stop (EV_A_ (W)w); |
3407 | ev_stop (EV_A_ (W)w); |
3327 | |
3408 | |
3328 | EV_FREQUENT_CHECK; |
3409 | EV_FREQUENT_CHECK; |
3329 | } |
3410 | } |
|
|
3411 | #endif |
3330 | |
3412 | |
3331 | #if EV_EMBED_ENABLE |
3413 | #if EV_EMBED_ENABLE |
3332 | void noinline |
3414 | void noinline |
3333 | ev_embed_sweep (EV_P_ ev_embed *w) |
3415 | ev_embed_sweep (EV_P_ ev_embed *w) |
3334 | { |
3416 | { |
… | |
… | |
3566 | { |
3648 | { |
3567 | struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); |
3649 | struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); |
3568 | |
3650 | |
3569 | if (expect_false (!once)) |
3651 | if (expect_false (!once)) |
3570 | { |
3652 | { |
3571 | cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); |
3653 | cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMER, arg); |
3572 | return; |
3654 | return; |
3573 | } |
3655 | } |
3574 | |
3656 | |
3575 | once->cb = cb; |
3657 | once->cb = cb; |
3576 | once->arg = arg; |
3658 | once->arg = arg; |
… | |
… | |
3663 | if (types & EV_ASYNC) |
3745 | if (types & EV_ASYNC) |
3664 | for (i = asynccnt; i--; ) |
3746 | for (i = asynccnt; i--; ) |
3665 | cb (EV_A_ EV_ASYNC, asyncs [i]); |
3747 | cb (EV_A_ EV_ASYNC, asyncs [i]); |
3666 | #endif |
3748 | #endif |
3667 | |
3749 | |
|
|
3750 | #if EV_PREPARE_ENABLE |
3668 | if (types & EV_PREPARE) |
3751 | if (types & EV_PREPARE) |
3669 | for (i = preparecnt; i--; ) |
3752 | for (i = preparecnt; i--; ) |
3670 | #if EV_EMBED_ENABLE |
3753 | # if EV_EMBED_ENABLE |
3671 | if (ev_cb (prepares [i]) != embed_prepare_cb) |
3754 | if (ev_cb (prepares [i]) != embed_prepare_cb) |
3672 | #endif |
3755 | # endif |
3673 | cb (EV_A_ EV_PREPARE, prepares [i]); |
3756 | cb (EV_A_ EV_PREPARE, prepares [i]); |
|
|
3757 | #endif |
3674 | |
3758 | |
|
|
3759 | #if EV_CHECK_ENABLE |
3675 | if (types & EV_CHECK) |
3760 | if (types & EV_CHECK) |
3676 | for (i = checkcnt; i--; ) |
3761 | for (i = checkcnt; i--; ) |
3677 | cb (EV_A_ EV_CHECK, checks [i]); |
3762 | cb (EV_A_ EV_CHECK, checks [i]); |
|
|
3763 | #endif |
3678 | |
3764 | |
|
|
3765 | #if EV_SIGNAL_ENABLE |
3679 | if (types & EV_SIGNAL) |
3766 | if (types & EV_SIGNAL) |
3680 | for (i = 0; i < EV_NSIG - 1; ++i) |
3767 | for (i = 0; i < EV_NSIG - 1; ++i) |
3681 | for (wl = signals [i].head; wl; ) |
3768 | for (wl = signals [i].head; wl; ) |
3682 | { |
3769 | { |
3683 | wn = wl->next; |
3770 | wn = wl->next; |
3684 | cb (EV_A_ EV_SIGNAL, wl); |
3771 | cb (EV_A_ EV_SIGNAL, wl); |
3685 | wl = wn; |
3772 | wl = wn; |
3686 | } |
3773 | } |
|
|
3774 | #endif |
3687 | |
3775 | |
|
|
3776 | #if EV_CHILD_ENABLE |
3688 | if (types & EV_CHILD) |
3777 | if (types & EV_CHILD) |
3689 | for (i = EV_PID_HASHSIZE; i--; ) |
3778 | for (i = (EV_PID_HASHSIZE); i--; ) |
3690 | for (wl = childs [i]; wl; ) |
3779 | for (wl = childs [i]; wl; ) |
3691 | { |
3780 | { |
3692 | wn = wl->next; |
3781 | wn = wl->next; |
3693 | cb (EV_A_ EV_CHILD, wl); |
3782 | cb (EV_A_ EV_CHILD, wl); |
3694 | wl = wn; |
3783 | wl = wn; |
3695 | } |
3784 | } |
|
|
3785 | #endif |
3696 | /* EV_STAT 0x00001000 /* stat data changed */ |
3786 | /* EV_STAT 0x00001000 /* stat data changed */ |
3697 | /* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ |
3787 | /* EV_EMBED 0x00010000 /* embedded event loop needs sweep */ |
3698 | } |
3788 | } |
3699 | #endif |
3789 | #endif |
3700 | |
3790 | |