… | |
… | |
403 | # endif |
403 | # endif |
404 | # endif |
404 | # endif |
405 | # ifdef __cplusplus |
405 | # ifdef __cplusplus |
406 | extern "C" { |
406 | extern "C" { |
407 | # endif |
407 | # endif |
408 | int eventfd (unsigned int initval, int flags); |
408 | int (eventfd) (unsigned int initval, int flags); |
409 | # ifdef __cplusplus |
409 | # ifdef __cplusplus |
410 | } |
410 | } |
411 | # endif |
411 | # endif |
412 | #endif |
412 | #endif |
413 | |
413 | |
… | |
… | |
542 | |
542 | |
543 | if (syserr_cb) |
543 | if (syserr_cb) |
544 | syserr_cb (msg); |
544 | syserr_cb (msg); |
545 | else |
545 | else |
546 | { |
546 | { |
|
|
547 | #if EV_AVOID_STDIO |
|
|
548 | write (STDERR_FILENO, msg, strlen (msg)); |
|
|
549 | write (STDERR_FILENO, ": ", 2); |
|
|
550 | msg = strerror (errno); |
|
|
551 | write (STDERR_FILENO, msg, strlen (msg)); |
|
|
552 | write (STDERR_FILENO, "\n", 1); |
|
|
553 | #else |
547 | perror (msg); |
554 | perror (msg); |
|
|
555 | #endif |
548 | abort (); |
556 | abort (); |
549 | } |
557 | } |
550 | } |
558 | } |
551 | |
559 | |
552 | static void * |
560 | static void * |
… | |
… | |
577 | { |
585 | { |
578 | ptr = alloc (ptr, size); |
586 | ptr = alloc (ptr, size); |
579 | |
587 | |
580 | if (!ptr && size) |
588 | if (!ptr && size) |
581 | { |
589 | { |
|
|
590 | #if EV_AVOID_STDIO |
|
|
591 | write (STDERR_FILENO, "libev: memory allocation failed, aborting.", |
|
|
592 | sizeof ("libev: memory allocation failed, aborting.") - 1); |
|
|
593 | #else |
582 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
594 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
|
|
595 | #endif |
583 | abort (); |
596 | abort (); |
584 | } |
597 | } |
585 | |
598 | |
586 | return ptr; |
599 | return ptr; |
587 | } |
600 | } |
… | |
… | |
2588 | timers [active] = timers [timercnt + HEAP0]; |
2601 | timers [active] = timers [timercnt + HEAP0]; |
2589 | adjustheap (timers, timercnt, active); |
2602 | adjustheap (timers, timercnt, active); |
2590 | } |
2603 | } |
2591 | } |
2604 | } |
2592 | |
2605 | |
2593 | EV_FREQUENT_CHECK; |
|
|
2594 | |
|
|
2595 | ev_at (w) -= mn_now; |
2606 | ev_at (w) -= mn_now; |
2596 | |
2607 | |
2597 | ev_stop (EV_A_ (W)w); |
2608 | ev_stop (EV_A_ (W)w); |
|
|
2609 | |
|
|
2610 | EV_FREQUENT_CHECK; |
2598 | } |
2611 | } |
2599 | |
2612 | |
2600 | void noinline |
2613 | void noinline |
2601 | ev_timer_again (EV_P_ ev_timer *w) |
2614 | ev_timer_again (EV_P_ ev_timer *w) |
2602 | { |
2615 | { |
… | |
… | |
2681 | periodics [active] = periodics [periodiccnt + HEAP0]; |
2694 | periodics [active] = periodics [periodiccnt + HEAP0]; |
2682 | adjustheap (periodics, periodiccnt, active); |
2695 | adjustheap (periodics, periodiccnt, active); |
2683 | } |
2696 | } |
2684 | } |
2697 | } |
2685 | |
2698 | |
2686 | EV_FREQUENT_CHECK; |
|
|
2687 | |
|
|
2688 | ev_stop (EV_A_ (W)w); |
2699 | ev_stop (EV_A_ (W)w); |
|
|
2700 | |
|
|
2701 | EV_FREQUENT_CHECK; |
2689 | } |
2702 | } |
2690 | |
2703 | |
2691 | void noinline |
2704 | void noinline |
2692 | ev_periodic_again (EV_P_ ev_periodic *w) |
2705 | ev_periodic_again (EV_P_ ev_periodic *w) |
2693 | { |
2706 | { |
… | |
… | |
2992 | infy_wd (EV_A_ ev->wd, ev->wd, ev); |
3005 | infy_wd (EV_A_ ev->wd, ev->wd, ev); |
2993 | ofs += sizeof (struct inotify_event) + ev->len; |
3006 | ofs += sizeof (struct inotify_event) + ev->len; |
2994 | } |
3007 | } |
2995 | } |
3008 | } |
2996 | |
3009 | |
|
|
3010 | inline_size unsigned int |
|
|
3011 | ev_linux_version (void) |
|
|
3012 | { |
|
|
3013 | struct utsname buf; |
|
|
3014 | unsigned int v; |
|
|
3015 | int i; |
|
|
3016 | char *p = buf.release; |
|
|
3017 | |
|
|
3018 | if (uname (&buf)) |
|
|
3019 | return 0; |
|
|
3020 | |
|
|
3021 | for (i = 3+1; --i; ) |
|
|
3022 | { |
|
|
3023 | unsigned int c = 0; |
|
|
3024 | |
|
|
3025 | for (;;) |
|
|
3026 | { |
|
|
3027 | if (*p >= '0' && *p <= '9') |
|
|
3028 | c = c * 10 + *p++ - '0'; |
|
|
3029 | else |
|
|
3030 | { |
|
|
3031 | p += *p == '.'; |
|
|
3032 | break; |
|
|
3033 | } |
|
|
3034 | } |
|
|
3035 | |
|
|
3036 | v = (v << 8) | c; |
|
|
3037 | } |
|
|
3038 | |
|
|
3039 | return v; |
|
|
3040 | } |
|
|
3041 | |
2997 | inline_size void |
3042 | inline_size void |
2998 | check_2625 (EV_P) |
3043 | ev_check_2625 (EV_P) |
2999 | { |
3044 | { |
3000 | /* kernels < 2.6.25 are borked |
3045 | /* kernels < 2.6.25 are borked |
3001 | * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html |
3046 | * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html |
3002 | */ |
3047 | */ |
3003 | struct utsname buf; |
3048 | 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; |
3049 | return; |
3016 | |
3050 | |
3017 | fs_2625 = 1; |
3051 | fs_2625 = 1; |
3018 | } |
3052 | } |
3019 | |
3053 | |
… | |
… | |
3034 | if (fs_fd != -2) |
3068 | if (fs_fd != -2) |
3035 | return; |
3069 | return; |
3036 | |
3070 | |
3037 | fs_fd = -1; |
3071 | fs_fd = -1; |
3038 | |
3072 | |
3039 | check_2625 (EV_A); |
3073 | ev_check_2625 (EV_A); |
3040 | |
3074 | |
3041 | fs_fd = infy_newfd (); |
3075 | fs_fd = infy_newfd (); |
3042 | |
3076 | |
3043 | if (fs_fd >= 0) |
3077 | if (fs_fd >= 0) |
3044 | { |
3078 | { |
… | |
… | |
3429 | |
3463 | |
3430 | ev_io_stop (EV_A_ &w->io); |
3464 | ev_io_stop (EV_A_ &w->io); |
3431 | ev_prepare_stop (EV_A_ &w->prepare); |
3465 | ev_prepare_stop (EV_A_ &w->prepare); |
3432 | ev_fork_stop (EV_A_ &w->fork); |
3466 | ev_fork_stop (EV_A_ &w->fork); |
3433 | |
3467 | |
|
|
3468 | ev_stop (EV_A_ (W)w); |
|
|
3469 | |
3434 | EV_FREQUENT_CHECK; |
3470 | EV_FREQUENT_CHECK; |
3435 | } |
3471 | } |
3436 | #endif |
3472 | #endif |
3437 | |
3473 | |
3438 | #if EV_FORK_ENABLE |
3474 | #if EV_FORK_ENABLE |