… | |
… | |
530 | |
530 | |
531 | static unsigned int noinline |
531 | static unsigned int noinline |
532 | ev_linux_version (void) |
532 | ev_linux_version (void) |
533 | { |
533 | { |
534 | #ifdef __linux |
534 | #ifdef __linux |
|
|
535 | unsigned int v = 0; |
535 | struct utsname buf; |
536 | struct utsname buf; |
536 | unsigned int v; |
|
|
537 | int i; |
537 | int i; |
538 | char *p = buf.release; |
538 | char *p = buf.release; |
539 | |
539 | |
540 | if (uname (&buf)) |
540 | if (uname (&buf)) |
541 | return 0; |
541 | return 0; |
… | |
… | |
1731 | #endif |
1731 | #endif |
1732 | } |
1732 | } |
1733 | } |
1733 | } |
1734 | |
1734 | |
1735 | /* free up a loop structure */ |
1735 | /* free up a loop structure */ |
1736 | static void noinline |
1736 | void |
1737 | loop_destroy (EV_P) |
1737 | ev_loop_destroy (EV_P) |
1738 | { |
1738 | { |
1739 | int i; |
1739 | int i; |
|
|
1740 | |
|
|
1741 | #if EV_CHILD_ENABLE |
|
|
1742 | if (ev_is_active (&childev)) |
|
|
1743 | { |
|
|
1744 | ev_ref (EV_A); /* child watcher */ |
|
|
1745 | ev_signal_stop (EV_A_ &childev); |
|
|
1746 | } |
|
|
1747 | #endif |
1740 | |
1748 | |
1741 | if (ev_is_active (&pipe_w)) |
1749 | if (ev_is_active (&pipe_w)) |
1742 | { |
1750 | { |
1743 | /*ev_ref (EV_A);*/ |
1751 | /*ev_ref (EV_A);*/ |
1744 | /*ev_io_stop (EV_A_ &pipe_w);*/ |
1752 | /*ev_io_stop (EV_A_ &pipe_w);*/ |
… | |
… | |
1805 | array_free (periodic, EMPTY); |
1813 | array_free (periodic, EMPTY); |
1806 | #endif |
1814 | #endif |
1807 | #if EV_FORK_ENABLE |
1815 | #if EV_FORK_ENABLE |
1808 | array_free (fork, EMPTY); |
1816 | array_free (fork, EMPTY); |
1809 | #endif |
1817 | #endif |
|
|
1818 | #if EV_CLEANUP_ENABLE |
|
|
1819 | array_free (cleanup, EMPTY); |
|
|
1820 | #endif |
1810 | array_free (prepare, EMPTY); |
1821 | array_free (prepare, EMPTY); |
1811 | array_free (check, EMPTY); |
1822 | array_free (check, EMPTY); |
1812 | #if EV_ASYNC_ENABLE |
1823 | #if EV_ASYNC_ENABLE |
1813 | array_free (async, EMPTY); |
1824 | array_free (async, EMPTY); |
1814 | #endif |
1825 | #endif |
1815 | |
1826 | |
1816 | backend = 0; |
1827 | backend = 0; |
|
|
1828 | |
|
|
1829 | #if EV_MULTIPLICITY |
|
|
1830 | if (ev_is_default_loop (EV_A)) |
|
|
1831 | #endif |
|
|
1832 | ev_default_loop_ptr = 0; |
|
|
1833 | #if EV_MULTIPLICITY |
|
|
1834 | else |
|
|
1835 | ev_free (EV_A); |
|
|
1836 | #endif |
1817 | } |
1837 | } |
1818 | |
1838 | |
1819 | #if EV_USE_INOTIFY |
1839 | #if EV_USE_INOTIFY |
1820 | inline_size void infy_fork (EV_P); |
1840 | inline_size void infy_fork (EV_P); |
1821 | #endif |
1841 | #endif |
… | |
… | |
1880 | loop_init (EV_A_ flags); |
1900 | loop_init (EV_A_ flags); |
1881 | |
1901 | |
1882 | if (ev_backend (EV_A)) |
1902 | if (ev_backend (EV_A)) |
1883 | return EV_A; |
1903 | return EV_A; |
1884 | |
1904 | |
|
|
1905 | ev_free (EV_A); |
1885 | return 0; |
1906 | return 0; |
1886 | } |
1907 | } |
1887 | |
1908 | |
1888 | void |
|
|
1889 | ev_loop_destroy (EV_P) |
|
|
1890 | { |
|
|
1891 | loop_destroy (EV_A); |
|
|
1892 | ev_free (loop); |
|
|
1893 | } |
|
|
1894 | |
|
|
1895 | void |
|
|
1896 | ev_loop_fork (EV_P) |
|
|
1897 | { |
|
|
1898 | postfork = 1; /* must be in line with ev_default_fork */ |
|
|
1899 | } |
|
|
1900 | #endif /* multiplicity */ |
1909 | #endif /* multiplicity */ |
1901 | |
1910 | |
1902 | #if EV_VERIFY |
1911 | #if EV_VERIFY |
1903 | static void noinline |
1912 | static void noinline |
1904 | verify_watcher (EV_P_ W w) |
1913 | verify_watcher (EV_P_ W w) |
… | |
… | |
1979 | #if EV_FORK_ENABLE |
1988 | #if EV_FORK_ENABLE |
1980 | assert (forkmax >= forkcnt); |
1989 | assert (forkmax >= forkcnt); |
1981 | array_verify (EV_A_ (W *)forks, forkcnt); |
1990 | array_verify (EV_A_ (W *)forks, forkcnt); |
1982 | #endif |
1991 | #endif |
1983 | |
1992 | |
|
|
1993 | #if EV_CLEANUP_ENABLE |
|
|
1994 | assert (cleanupmax >= cleanupcnt); |
|
|
1995 | array_verify (EV_A_ (W *)cleanups, cleanupcnt); |
|
|
1996 | #endif |
|
|
1997 | |
1984 | #if EV_ASYNC_ENABLE |
1998 | #if EV_ASYNC_ENABLE |
1985 | assert (asyncmax >= asynccnt); |
1999 | assert (asyncmax >= asynccnt); |
1986 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
2000 | array_verify (EV_A_ (W *)asyncs, asynccnt); |
1987 | #endif |
2001 | #endif |
1988 | |
2002 | |
… | |
… | |
2038 | |
2052 | |
2039 | return ev_default_loop_ptr; |
2053 | return ev_default_loop_ptr; |
2040 | } |
2054 | } |
2041 | |
2055 | |
2042 | void |
2056 | void |
2043 | ev_default_destroy (void) |
2057 | ev_loop_fork (EV_P) |
2044 | { |
2058 | { |
2045 | #if EV_MULTIPLICITY |
|
|
2046 | EV_P = ev_default_loop_ptr; |
|
|
2047 | #endif |
|
|
2048 | |
|
|
2049 | ev_default_loop_ptr = 0; |
|
|
2050 | |
|
|
2051 | #if EV_CHILD_ENABLE |
|
|
2052 | ev_ref (EV_A); /* child watcher */ |
|
|
2053 | ev_signal_stop (EV_A_ &childev); |
|
|
2054 | #endif |
|
|
2055 | |
|
|
2056 | loop_destroy (EV_A); |
|
|
2057 | } |
|
|
2058 | |
|
|
2059 | void |
|
|
2060 | ev_default_fork (void) |
|
|
2061 | { |
|
|
2062 | #if EV_MULTIPLICITY |
|
|
2063 | EV_P = ev_default_loop_ptr; |
|
|
2064 | #endif |
|
|
2065 | |
|
|
2066 | postfork = 1; /* must be in line with ev_loop_fork */ |
2059 | postfork = 1; /* must be in line with ev_default_fork */ |
2067 | } |
2060 | } |
2068 | |
2061 | |
2069 | /*****************************************************************************/ |
2062 | /*****************************************************************************/ |
2070 | |
2063 | |
2071 | void |
2064 | void |
… | |
… | |
3577 | |
3570 | |
3578 | EV_FREQUENT_CHECK; |
3571 | EV_FREQUENT_CHECK; |
3579 | } |
3572 | } |
3580 | #endif |
3573 | #endif |
3581 | |
3574 | |
|
|
3575 | #if EV_CLEANUP_ENABLE |
|
|
3576 | void |
|
|
3577 | ev_cleanup_start (EV_P_ ev_cleanup *w) |
|
|
3578 | { |
|
|
3579 | if (expect_false (ev_is_active (w))) |
|
|
3580 | return; |
|
|
3581 | |
|
|
3582 | EV_FREQUENT_CHECK; |
|
|
3583 | |
|
|
3584 | ev_start (EV_A_ (W)w, ++cleanupcnt); |
|
|
3585 | array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); |
|
|
3586 | cleanups [cleanupcnt - 1] = w; |
|
|
3587 | |
|
|
3588 | EV_FREQUENT_CHECK; |
|
|
3589 | } |
|
|
3590 | |
|
|
3591 | void |
|
|
3592 | ev_cleanup_stop (EV_P_ ev_cleanup *w) |
|
|
3593 | { |
|
|
3594 | clear_pending (EV_A_ (W)w); |
|
|
3595 | if (expect_false (!ev_is_active (w))) |
|
|
3596 | return; |
|
|
3597 | |
|
|
3598 | EV_FREQUENT_CHECK; |
|
|
3599 | |
|
|
3600 | { |
|
|
3601 | int active = ev_active (w); |
|
|
3602 | |
|
|
3603 | cleanups [active - 1] = cleanups [--cleanupcnt]; |
|
|
3604 | ev_active (cleanups [active - 1]) = active; |
|
|
3605 | } |
|
|
3606 | |
|
|
3607 | ev_stop (EV_A_ (W)w); |
|
|
3608 | |
|
|
3609 | EV_FREQUENT_CHECK; |
|
|
3610 | } |
|
|
3611 | #endif |
|
|
3612 | |
3582 | #if EV_ASYNC_ENABLE |
3613 | #if EV_ASYNC_ENABLE |
3583 | void |
3614 | void |
3584 | ev_async_start (EV_P_ ev_async *w) |
3615 | ev_async_start (EV_P_ ev_async *w) |
3585 | { |
3616 | { |
3586 | if (expect_false (ev_is_active (w))) |
3617 | if (expect_false (ev_is_active (w))) |