… | |
… | |
162 | # define EV_USE_EVENTFD 0 |
162 | # define EV_USE_EVENTFD 0 |
163 | # endif |
163 | # endif |
164 | |
164 | |
165 | #endif |
165 | #endif |
166 | |
166 | |
|
|
167 | /* OS X, in its infinite idiocy, actually HARDCODES |
|
|
168 | * a limit of 1024 into their select. Where people have brains, |
|
|
169 | * OS X engineers apparently have a vacuum. Or maybe they were |
|
|
170 | * ordered to have a vacuum, or they do anything for money. |
|
|
171 | * This might help. Or not. |
|
|
172 | * Note that this must be defined early, as other include files |
|
|
173 | * will rely on this define as well. |
|
|
174 | */ |
|
|
175 | #define _DARWIN_UNLIMITED_SELECT 1 |
|
|
176 | |
167 | #include <stdlib.h> |
177 | #include <stdlib.h> |
168 | #include <string.h> |
178 | #include <string.h> |
169 | #include <fcntl.h> |
179 | #include <fcntl.h> |
170 | #include <stddef.h> |
180 | #include <stddef.h> |
171 | |
181 | |
… | |
… | |
208 | # ifndef EV_SELECT_IS_WINSOCKET |
218 | # ifndef EV_SELECT_IS_WINSOCKET |
209 | # define EV_SELECT_IS_WINSOCKET 1 |
219 | # define EV_SELECT_IS_WINSOCKET 1 |
210 | # endif |
220 | # endif |
211 | # undef EV_AVOID_STDIO |
221 | # undef EV_AVOID_STDIO |
212 | #endif |
222 | #endif |
213 | |
|
|
214 | /* OS X, in its infinite idiocy, actually HARDCODES |
|
|
215 | * a limit of 1024 into their select. Where people have brains, |
|
|
216 | * OS X engineers apparently have a vacuum. Or maybe they were |
|
|
217 | * ordered to have a vacuum, or they do anything for money. |
|
|
218 | * This might help. Or not. |
|
|
219 | */ |
|
|
220 | #define _DARWIN_UNLIMITED_SELECT 1 |
|
|
221 | |
223 | |
222 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
224 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
223 | |
225 | |
224 | /* try to deduce the maximum number of signals on this platform */ |
226 | /* try to deduce the maximum number of signals on this platform */ |
225 | #if defined EV_NSIG |
227 | #if defined EV_NSIG |
… | |
… | |
363 | |
365 | |
364 | #ifndef EV_HEAP_CACHE_AT |
366 | #ifndef EV_HEAP_CACHE_AT |
365 | # define EV_HEAP_CACHE_AT EV_FEATURE_DATA |
367 | # define EV_HEAP_CACHE_AT EV_FEATURE_DATA |
366 | #endif |
368 | #endif |
367 | |
369 | |
368 | #ifdef ANDROID |
370 | #ifdef __ANDROID__ |
369 | /* supposedly, android doesn't typedef fd_mask */ |
371 | /* supposedly, android doesn't typedef fd_mask */ |
370 | # undef EV_USE_SELECT |
372 | # undef EV_USE_SELECT |
371 | # define EV_USE_SELECT 0 |
373 | # define EV_USE_SELECT 0 |
372 | /* supposedly, we need to include syscall.h, not sys/syscall.h, so just disable */ |
374 | /* supposedly, we need to include syscall.h, not sys/syscall.h, so just disable */ |
373 | # undef EV_USE_CLOCK_SYSCALL |
375 | # undef EV_USE_CLOCK_SYSCALL |
… | |
… | |
1906 | struct timespec ts; |
1908 | struct timespec ts; |
1907 | |
1909 | |
1908 | EV_TS_SET (ts, delay); |
1910 | EV_TS_SET (ts, delay); |
1909 | nanosleep (&ts, 0); |
1911 | nanosleep (&ts, 0); |
1910 | #elif defined _WIN32 |
1912 | #elif defined _WIN32 |
|
|
1913 | /* maybe this should round up, as ms is very low resolution */ |
|
|
1914 | /* compared to select (µs) or nanosleep (ns) */ |
1911 | Sleep ((unsigned long)(delay * 1e3)); |
1915 | Sleep ((unsigned long)(delay * 1e3)); |
1912 | #else |
1916 | #else |
1913 | struct timeval tv; |
1917 | struct timeval tv; |
1914 | |
1918 | |
1915 | /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ |
1919 | /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ |
… | |
… | |
2471 | #endif |
2475 | #endif |
2472 | { |
2476 | { |
2473 | #ifdef _WIN32 |
2477 | #ifdef _WIN32 |
2474 | WSABUF buf; |
2478 | WSABUF buf; |
2475 | DWORD sent; |
2479 | DWORD sent; |
2476 | buf.buf = &buf; |
2480 | buf.buf = (char *)&buf; |
2477 | buf.len = 1; |
2481 | buf.len = 1; |
2478 | WSASend (EV_FD_TO_WIN32_HANDLE (evpipe [1]), &buf, 1, &sent, 0, 0, 0); |
2482 | WSASend (EV_FD_TO_WIN32_HANDLE (evpipe [1]), &buf, 1, &sent, 0, 0, 0); |
2479 | #else |
2483 | #else |
2480 | write (evpipe [1], &(evpipe [1]), 1); |
2484 | write (evpipe [1], &(evpipe [1]), 1); |
2481 | #endif |
2485 | #endif |
… | |
… | |
3300 | void |
3304 | void |
3301 | ev_invoke_pending (EV_P) |
3305 | ev_invoke_pending (EV_P) |
3302 | { |
3306 | { |
3303 | pendingpri = NUMPRI; |
3307 | pendingpri = NUMPRI; |
3304 | |
3308 | |
3305 | while (pendingpri) /* pendingpri possibly gets modified in the inner loop */ |
3309 | do |
3306 | { |
3310 | { |
3307 | --pendingpri; |
3311 | --pendingpri; |
3308 | |
3312 | |
|
|
3313 | /* pendingpri possibly gets modified in the inner loop */ |
3309 | while (pendingcnt [pendingpri]) |
3314 | while (pendingcnt [pendingpri]) |
3310 | { |
3315 | { |
3311 | ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; |
3316 | ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; |
3312 | |
3317 | |
3313 | p->w->pending = 0; |
3318 | p->w->pending = 0; |
3314 | EV_CB_INVOKE (p->w, p->events); |
3319 | EV_CB_INVOKE (p->w, p->events); |
3315 | EV_FREQUENT_CHECK; |
3320 | EV_FREQUENT_CHECK; |
3316 | } |
3321 | } |
3317 | } |
3322 | } |
|
|
3323 | while (pendingpri); |
3318 | } |
3324 | } |
3319 | |
3325 | |
3320 | #if EV_IDLE_ENABLE |
3326 | #if EV_IDLE_ENABLE |
3321 | /* make idle watchers pending. this handles the "call-idle */ |
3327 | /* make idle watchers pending. this handles the "call-idle */ |
3322 | /* only when higher priorities are idle" logic */ |
3328 | /* only when higher priorities are idle" logic */ |