… | |
… | |
225 | |
225 | |
226 | /*****************************************************************************/ |
226 | /*****************************************************************************/ |
227 | |
227 | |
228 | static void (*syserr_cb)(const char *msg); |
228 | static void (*syserr_cb)(const char *msg); |
229 | |
229 | |
|
|
230 | void |
230 | void ev_set_syserr_cb (void (*cb)(const char *msg)) |
231 | ev_set_syserr_cb (void (*cb)(const char *msg)) |
231 | { |
232 | { |
232 | syserr_cb = cb; |
233 | syserr_cb = cb; |
233 | } |
234 | } |
234 | |
235 | |
235 | static void |
236 | static void noinline |
236 | syserr (const char *msg) |
237 | syserr (const char *msg) |
237 | { |
238 | { |
238 | if (!msg) |
239 | if (!msg) |
239 | msg = "(libev) system error"; |
240 | msg = "(libev) system error"; |
240 | |
241 | |
… | |
… | |
247 | } |
248 | } |
248 | } |
249 | } |
249 | |
250 | |
250 | static void *(*alloc)(void *ptr, long size); |
251 | static void *(*alloc)(void *ptr, long size); |
251 | |
252 | |
|
|
253 | void |
252 | void ev_set_allocator (void *(*cb)(void *ptr, long size)) |
254 | ev_set_allocator (void *(*cb)(void *ptr, long size)) |
253 | { |
255 | { |
254 | alloc = cb; |
256 | alloc = cb; |
255 | } |
257 | } |
256 | |
258 | |
257 | static void * |
259 | static void * |
… | |
… | |
315 | |
317 | |
316 | #endif |
318 | #endif |
317 | |
319 | |
318 | /*****************************************************************************/ |
320 | /*****************************************************************************/ |
319 | |
321 | |
320 | ev_tstamp noinline |
322 | ev_tstamp |
321 | ev_time (void) |
323 | ev_time (void) |
322 | { |
324 | { |
323 | #if EV_USE_REALTIME |
325 | #if EV_USE_REALTIME |
324 | struct timespec ts; |
326 | struct timespec ts; |
325 | clock_gettime (CLOCK_REALTIME, &ts); |
327 | clock_gettime (CLOCK_REALTIME, &ts); |
… | |
… | |
382 | #define array_free(stem, idx) \ |
384 | #define array_free(stem, idx) \ |
383 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; |
385 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; |
384 | |
386 | |
385 | /*****************************************************************************/ |
387 | /*****************************************************************************/ |
386 | |
388 | |
387 | void inline_size |
|
|
388 | anfds_init (ANFD *base, int count) |
|
|
389 | { |
|
|
390 | while (count--) |
|
|
391 | { |
|
|
392 | base->head = 0; |
|
|
393 | base->events = EV_NONE; |
|
|
394 | base->reify = 0; |
|
|
395 | |
|
|
396 | ++base; |
|
|
397 | } |
|
|
398 | } |
|
|
399 | |
|
|
400 | void noinline |
389 | void noinline |
401 | ev_feed_event (EV_P_ void *w, int revents) |
390 | ev_feed_event (EV_P_ void *w, int revents) |
402 | { |
391 | { |
403 | W w_ = (W)w; |
392 | W w_ = (W)w; |
404 | |
393 | |
… | |
… | |
412 | array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2); |
401 | array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2); |
413 | pendings [ABSPRI (w_)][w_->pending - 1].w = w_; |
402 | pendings [ABSPRI (w_)][w_->pending - 1].w = w_; |
414 | pendings [ABSPRI (w_)][w_->pending - 1].events = revents; |
403 | pendings [ABSPRI (w_)][w_->pending - 1].events = revents; |
415 | } |
404 | } |
416 | |
405 | |
417 | static void |
406 | void inline_size |
418 | queue_events (EV_P_ W *events, int eventcnt, int type) |
407 | queue_events (EV_P_ W *events, int eventcnt, int type) |
419 | { |
408 | { |
420 | int i; |
409 | int i; |
421 | |
410 | |
422 | for (i = 0; i < eventcnt; ++i) |
411 | for (i = 0; i < eventcnt; ++i) |
423 | ev_feed_event (EV_A_ events [i], type); |
412 | ev_feed_event (EV_A_ events [i], type); |
424 | } |
413 | } |
425 | |
414 | |
|
|
415 | /*****************************************************************************/ |
|
|
416 | |
|
|
417 | void inline_size |
|
|
418 | anfds_init (ANFD *base, int count) |
|
|
419 | { |
|
|
420 | while (count--) |
|
|
421 | { |
|
|
422 | base->head = 0; |
|
|
423 | base->events = EV_NONE; |
|
|
424 | base->reify = 0; |
|
|
425 | |
|
|
426 | ++base; |
|
|
427 | } |
|
|
428 | } |
|
|
429 | |
426 | void inline_speed |
430 | void inline_speed |
427 | fd_event (EV_P_ int fd, int revents) |
431 | fd_event (EV_P_ int fd, int revents) |
428 | { |
432 | { |
429 | ANFD *anfd = anfds + fd; |
433 | ANFD *anfd = anfds + fd; |
430 | ev_io *w; |
434 | ev_io *w; |
… | |
… | |
441 | void |
445 | void |
442 | ev_feed_fd_event (EV_P_ int fd, int revents) |
446 | ev_feed_fd_event (EV_P_ int fd, int revents) |
443 | { |
447 | { |
444 | fd_event (EV_A_ fd, revents); |
448 | fd_event (EV_A_ fd, revents); |
445 | } |
449 | } |
446 | |
|
|
447 | /*****************************************************************************/ |
|
|
448 | |
450 | |
449 | void inline_size |
451 | void inline_size |
450 | fd_reify (EV_P) |
452 | fd_reify (EV_P) |
451 | { |
453 | { |
452 | int i; |
454 | int i; |