… | |
… | |
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 |
… | |
… | |
1527 | #define inline_size ecb_inline |
1529 | #define inline_size ecb_inline |
1528 | |
1530 | |
1529 | #if EV_FEATURE_CODE |
1531 | #if EV_FEATURE_CODE |
1530 | # define inline_speed ecb_inline |
1532 | # define inline_speed ecb_inline |
1531 | #else |
1533 | #else |
1532 | # define inline_speed static noinline |
1534 | # define inline_speed noinline static |
1533 | #endif |
1535 | #endif |
1534 | |
1536 | |
1535 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
1537 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
1536 | |
1538 | |
1537 | #if EV_MINPRI == EV_MAXPRI |
1539 | #if EV_MINPRI == EV_MAXPRI |
… | |
… | |
1584 | #else |
1586 | #else |
1585 | |
1587 | |
1586 | #include <float.h> |
1588 | #include <float.h> |
1587 | |
1589 | |
1588 | /* a floor() replacement function, should be independent of ev_tstamp type */ |
1590 | /* a floor() replacement function, should be independent of ev_tstamp type */ |
|
|
1591 | noinline |
1589 | static ev_tstamp noinline |
1592 | static ev_tstamp |
1590 | ev_floor (ev_tstamp v) |
1593 | ev_floor (ev_tstamp v) |
1591 | { |
1594 | { |
1592 | /* the choice of shift factor is not terribly important */ |
1595 | /* the choice of shift factor is not terribly important */ |
1593 | #if FLT_RADIX != 2 /* assume FLT_RADIX == 10 */ |
1596 | #if FLT_RADIX != 2 /* assume FLT_RADIX == 10 */ |
1594 | const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 10000000000000000000. : 1000000000.; |
1597 | const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 10000000000000000000. : 1000000000.; |
… | |
… | |
1626 | |
1629 | |
1627 | #ifdef __linux |
1630 | #ifdef __linux |
1628 | # include <sys/utsname.h> |
1631 | # include <sys/utsname.h> |
1629 | #endif |
1632 | #endif |
1630 | |
1633 | |
1631 | static unsigned int noinline ecb_cold |
1634 | noinline ecb_cold |
|
|
1635 | static unsigned int |
1632 | ev_linux_version (void) |
1636 | ev_linux_version (void) |
1633 | { |
1637 | { |
1634 | #ifdef __linux |
1638 | #ifdef __linux |
1635 | unsigned int v = 0; |
1639 | unsigned int v = 0; |
1636 | struct utsname buf; |
1640 | struct utsname buf; |
… | |
… | |
1665 | } |
1669 | } |
1666 | |
1670 | |
1667 | /*****************************************************************************/ |
1671 | /*****************************************************************************/ |
1668 | |
1672 | |
1669 | #if EV_AVOID_STDIO |
1673 | #if EV_AVOID_STDIO |
1670 | static void noinline ecb_cold |
1674 | noinline ecb_cold |
|
|
1675 | static void |
1671 | ev_printerr (const char *msg) |
1676 | ev_printerr (const char *msg) |
1672 | { |
1677 | { |
1673 | write (STDERR_FILENO, msg, strlen (msg)); |
1678 | write (STDERR_FILENO, msg, strlen (msg)); |
1674 | } |
1679 | } |
1675 | #endif |
1680 | #endif |
1676 | |
1681 | |
1677 | static void (*syserr_cb)(const char *msg) EV_THROW; |
1682 | static void (*syserr_cb)(const char *msg) EV_NOEXCEPT; |
1678 | |
1683 | |
1679 | void ecb_cold |
1684 | ecb_cold |
|
|
1685 | void |
1680 | ev_set_syserr_cb (void (*cb)(const char *msg) EV_THROW) EV_THROW |
1686 | ev_set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT |
1681 | { |
1687 | { |
1682 | syserr_cb = cb; |
1688 | syserr_cb = cb; |
1683 | } |
1689 | } |
1684 | |
1690 | |
1685 | static void noinline ecb_cold |
1691 | noinline ecb_cold |
|
|
1692 | static void |
1686 | ev_syserr (const char *msg) |
1693 | ev_syserr (const char *msg) |
1687 | { |
1694 | { |
1688 | if (!msg) |
1695 | if (!msg) |
1689 | msg = "(libev) system error"; |
1696 | msg = "(libev) system error"; |
1690 | |
1697 | |
… | |
… | |
1703 | abort (); |
1710 | abort (); |
1704 | } |
1711 | } |
1705 | } |
1712 | } |
1706 | |
1713 | |
1707 | static void * |
1714 | static void * |
1708 | ev_realloc_emul (void *ptr, long size) EV_THROW |
1715 | ev_realloc_emul (void *ptr, long size) EV_NOEXCEPT |
1709 | { |
1716 | { |
1710 | /* some systems, notably openbsd and darwin, fail to properly |
1717 | /* some systems, notably openbsd and darwin, fail to properly |
1711 | * implement realloc (x, 0) (as required by both ansi c-89 and |
1718 | * implement realloc (x, 0) (as required by both ansi c-89 and |
1712 | * the single unix specification, so work around them here. |
1719 | * the single unix specification, so work around them here. |
1713 | * recently, also (at least) fedora and debian started breaking it, |
1720 | * recently, also (at least) fedora and debian started breaking it, |
… | |
… | |
1719 | |
1726 | |
1720 | free (ptr); |
1727 | free (ptr); |
1721 | return 0; |
1728 | return 0; |
1722 | } |
1729 | } |
1723 | |
1730 | |
1724 | static void *(*alloc)(void *ptr, long size) EV_THROW = ev_realloc_emul; |
1731 | static void *(*alloc)(void *ptr, long size) EV_NOEXCEPT = ev_realloc_emul; |
1725 | |
1732 | |
1726 | void ecb_cold |
1733 | ecb_cold |
|
|
1734 | void |
1727 | ev_set_allocator (void *(*cb)(void *ptr, long size) EV_THROW) EV_THROW |
1735 | ev_set_allocator (void *(*cb)(void *ptr, long size) EV_NOEXCEPT) EV_NOEXCEPT |
1728 | { |
1736 | { |
1729 | alloc = cb; |
1737 | alloc = cb; |
1730 | } |
1738 | } |
1731 | |
1739 | |
1732 | inline_speed void * |
1740 | inline_speed void * |
… | |
… | |
1849 | |
1857 | |
1850 | /*****************************************************************************/ |
1858 | /*****************************************************************************/ |
1851 | |
1859 | |
1852 | #ifndef EV_HAVE_EV_TIME |
1860 | #ifndef EV_HAVE_EV_TIME |
1853 | ev_tstamp |
1861 | ev_tstamp |
1854 | ev_time (void) EV_THROW |
1862 | ev_time (void) EV_NOEXCEPT |
1855 | { |
1863 | { |
1856 | #if EV_USE_REALTIME |
1864 | #if EV_USE_REALTIME |
1857 | if (expect_true (have_realtime)) |
1865 | if (expect_true (have_realtime)) |
1858 | { |
1866 | { |
1859 | struct timespec ts; |
1867 | struct timespec ts; |
… | |
… | |
1883 | return ev_time (); |
1891 | return ev_time (); |
1884 | } |
1892 | } |
1885 | |
1893 | |
1886 | #if EV_MULTIPLICITY |
1894 | #if EV_MULTIPLICITY |
1887 | ev_tstamp |
1895 | ev_tstamp |
1888 | ev_now (EV_P) EV_THROW |
1896 | ev_now (EV_P) EV_NOEXCEPT |
1889 | { |
1897 | { |
1890 | return ev_rt_now; |
1898 | return ev_rt_now; |
1891 | } |
1899 | } |
1892 | #endif |
1900 | #endif |
1893 | |
1901 | |
1894 | void |
1902 | void |
1895 | ev_sleep (ev_tstamp delay) EV_THROW |
1903 | ev_sleep (ev_tstamp delay) EV_NOEXCEPT |
1896 | { |
1904 | { |
1897 | if (delay > 0.) |
1905 | if (delay > 0.) |
1898 | { |
1906 | { |
1899 | #if EV_USE_NANOSLEEP |
1907 | #if EV_USE_NANOSLEEP |
1900 | struct timespec ts; |
1908 | struct timespec ts; |
1901 | |
1909 | |
1902 | EV_TS_SET (ts, delay); |
1910 | EV_TS_SET (ts, delay); |
1903 | nanosleep (&ts, 0); |
1911 | nanosleep (&ts, 0); |
1904 | #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) */ |
1905 | Sleep ((unsigned long)(delay * 1e3)); |
1915 | Sleep ((unsigned long)(delay * 1e3)); |
1906 | #else |
1916 | #else |
1907 | struct timeval tv; |
1917 | struct timeval tv; |
1908 | |
1918 | |
1909 | /* 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 */ |
… | |
… | |
1940 | } |
1950 | } |
1941 | |
1951 | |
1942 | return ncur; |
1952 | return ncur; |
1943 | } |
1953 | } |
1944 | |
1954 | |
1945 | static void * noinline ecb_cold |
1955 | noinline ecb_cold |
|
|
1956 | static void * |
1946 | array_realloc (int elem, void *base, int *cur, int cnt) |
1957 | array_realloc (int elem, void *base, int *cur, int cnt) |
1947 | { |
1958 | { |
1948 | *cur = array_nextsize (elem, *cur, cnt); |
1959 | *cur = array_nextsize (elem, *cur, cnt); |
1949 | return ev_realloc (base, elem * *cur); |
1960 | return ev_realloc (base, elem * *cur); |
1950 | } |
1961 | } |
… | |
… | |
1953 | memset ((void *)(base), 0, sizeof (*(base)) * (count)) |
1964 | memset ((void *)(base), 0, sizeof (*(base)) * (count)) |
1954 | |
1965 | |
1955 | #define array_needsize(type,base,cur,cnt,init) \ |
1966 | #define array_needsize(type,base,cur,cnt,init) \ |
1956 | if (expect_false ((cnt) > (cur))) \ |
1967 | if (expect_false ((cnt) > (cur))) \ |
1957 | { \ |
1968 | { \ |
1958 | int ecb_unused ocur_ = (cur); \ |
1969 | ecb_unused int ocur_ = (cur); \ |
1959 | (base) = (type *)array_realloc \ |
1970 | (base) = (type *)array_realloc \ |
1960 | (sizeof (type), (base), &(cur), (cnt)); \ |
1971 | (sizeof (type), (base), &(cur), (cnt)); \ |
1961 | init ((base) + (ocur_), (cur) - ocur_); \ |
1972 | init ((base) + (ocur_), (cur) - ocur_); \ |
1962 | } |
1973 | } |
1963 | |
1974 | |
… | |
… | |
1975 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 |
1986 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 |
1976 | |
1987 | |
1977 | /*****************************************************************************/ |
1988 | /*****************************************************************************/ |
1978 | |
1989 | |
1979 | /* dummy callback for pending events */ |
1990 | /* dummy callback for pending events */ |
1980 | static void noinline |
1991 | noinline |
|
|
1992 | static void |
1981 | pendingcb (EV_P_ ev_prepare *w, int revents) |
1993 | pendingcb (EV_P_ ev_prepare *w, int revents) |
1982 | { |
1994 | { |
1983 | } |
1995 | } |
1984 | |
1996 | |
1985 | void noinline |
1997 | noinline |
|
|
1998 | void |
1986 | ev_feed_event (EV_P_ void *w, int revents) EV_THROW |
1999 | ev_feed_event (EV_P_ void *w, int revents) EV_NOEXCEPT |
1987 | { |
2000 | { |
1988 | W w_ = (W)w; |
2001 | W w_ = (W)w; |
1989 | int pri = ABSPRI (w_); |
2002 | int pri = ABSPRI (w_); |
1990 | |
2003 | |
1991 | if (expect_false (w_->pending)) |
2004 | if (expect_false (w_->pending)) |
… | |
… | |
2052 | if (expect_true (!anfd->reify)) |
2065 | if (expect_true (!anfd->reify)) |
2053 | fd_event_nocheck (EV_A_ fd, revents); |
2066 | fd_event_nocheck (EV_A_ fd, revents); |
2054 | } |
2067 | } |
2055 | |
2068 | |
2056 | void |
2069 | void |
2057 | ev_feed_fd_event (EV_P_ int fd, int revents) EV_THROW |
2070 | ev_feed_fd_event (EV_P_ int fd, int revents) EV_NOEXCEPT |
2058 | { |
2071 | { |
2059 | if (fd >= 0 && fd < anfdmax) |
2072 | if (fd >= 0 && fd < anfdmax) |
2060 | fd_event_nocheck (EV_A_ fd, revents); |
2073 | fd_event_nocheck (EV_A_ fd, revents); |
2061 | } |
2074 | } |
2062 | |
2075 | |
… | |
… | |
2120 | |
2133 | |
2121 | fdchangecnt = 0; |
2134 | fdchangecnt = 0; |
2122 | } |
2135 | } |
2123 | |
2136 | |
2124 | /* something about the given fd changed */ |
2137 | /* something about the given fd changed */ |
2125 | inline_size void |
2138 | inline_size |
|
|
2139 | void |
2126 | fd_change (EV_P_ int fd, int flags) |
2140 | fd_change (EV_P_ int fd, int flags) |
2127 | { |
2141 | { |
2128 | unsigned char reify = anfds [fd].reify; |
2142 | unsigned char reify = anfds [fd].reify; |
2129 | anfds [fd].reify |= flags; |
2143 | anfds [fd].reify |= flags; |
2130 | |
2144 | |
… | |
… | |
2135 | fdchanges [fdchangecnt - 1] = fd; |
2149 | fdchanges [fdchangecnt - 1] = fd; |
2136 | } |
2150 | } |
2137 | } |
2151 | } |
2138 | |
2152 | |
2139 | /* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */ |
2153 | /* the given fd is invalid/unusable, so make sure it doesn't hurt us anymore */ |
2140 | inline_speed void ecb_cold |
2154 | inline_speed ecb_cold void |
2141 | fd_kill (EV_P_ int fd) |
2155 | fd_kill (EV_P_ int fd) |
2142 | { |
2156 | { |
2143 | ev_io *w; |
2157 | ev_io *w; |
2144 | |
2158 | |
2145 | while ((w = (ev_io *)anfds [fd].head)) |
2159 | while ((w = (ev_io *)anfds [fd].head)) |
… | |
… | |
2148 | ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); |
2162 | ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); |
2149 | } |
2163 | } |
2150 | } |
2164 | } |
2151 | |
2165 | |
2152 | /* check whether the given fd is actually valid, for error recovery */ |
2166 | /* check whether the given fd is actually valid, for error recovery */ |
2153 | inline_size int ecb_cold |
2167 | inline_size ecb_cold int |
2154 | fd_valid (int fd) |
2168 | fd_valid (int fd) |
2155 | { |
2169 | { |
2156 | #ifdef _WIN32 |
2170 | #ifdef _WIN32 |
2157 | return EV_FD_TO_WIN32_HANDLE (fd) != -1; |
2171 | return EV_FD_TO_WIN32_HANDLE (fd) != -1; |
2158 | #else |
2172 | #else |
2159 | return fcntl (fd, F_GETFD) != -1; |
2173 | return fcntl (fd, F_GETFD) != -1; |
2160 | #endif |
2174 | #endif |
2161 | } |
2175 | } |
2162 | |
2176 | |
2163 | /* called on EBADF to verify fds */ |
2177 | /* called on EBADF to verify fds */ |
2164 | static void noinline ecb_cold |
2178 | noinline ecb_cold |
|
|
2179 | static void |
2165 | fd_ebadf (EV_P) |
2180 | fd_ebadf (EV_P) |
2166 | { |
2181 | { |
2167 | int fd; |
2182 | int fd; |
2168 | |
2183 | |
2169 | for (fd = 0; fd < anfdmax; ++fd) |
2184 | for (fd = 0; fd < anfdmax; ++fd) |
… | |
… | |
2171 | if (!fd_valid (fd) && errno == EBADF) |
2186 | if (!fd_valid (fd) && errno == EBADF) |
2172 | fd_kill (EV_A_ fd); |
2187 | fd_kill (EV_A_ fd); |
2173 | } |
2188 | } |
2174 | |
2189 | |
2175 | /* called on ENOMEM in select/poll to kill some fds and retry */ |
2190 | /* called on ENOMEM in select/poll to kill some fds and retry */ |
2176 | static void noinline ecb_cold |
2191 | noinline ecb_cold |
|
|
2192 | static void |
2177 | fd_enomem (EV_P) |
2193 | fd_enomem (EV_P) |
2178 | { |
2194 | { |
2179 | int fd; |
2195 | int fd; |
2180 | |
2196 | |
2181 | for (fd = anfdmax; fd--; ) |
2197 | for (fd = anfdmax; fd--; ) |
… | |
… | |
2185 | break; |
2201 | break; |
2186 | } |
2202 | } |
2187 | } |
2203 | } |
2188 | |
2204 | |
2189 | /* usually called after fork if backend needs to re-arm all fds from scratch */ |
2205 | /* usually called after fork if backend needs to re-arm all fds from scratch */ |
2190 | static void noinline |
2206 | noinline |
|
|
2207 | static void |
2191 | fd_rearm_all (EV_P) |
2208 | fd_rearm_all (EV_P) |
2192 | { |
2209 | { |
2193 | int fd; |
2210 | int fd; |
2194 | |
2211 | |
2195 | for (fd = 0; fd < anfdmax; ++fd) |
2212 | for (fd = 0; fd < anfdmax; ++fd) |
… | |
… | |
2376 | |
2393 | |
2377 | /*****************************************************************************/ |
2394 | /*****************************************************************************/ |
2378 | |
2395 | |
2379 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
2396 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
2380 | |
2397 | |
2381 | static void noinline ecb_cold |
2398 | noinline ecb_cold |
|
|
2399 | static void |
2382 | evpipe_init (EV_P) |
2400 | evpipe_init (EV_P) |
2383 | { |
2401 | { |
2384 | if (!ev_is_active (&pipe_w)) |
2402 | if (!ev_is_active (&pipe_w)) |
2385 | { |
2403 | { |
2386 | int fds [2]; |
2404 | int fds [2]; |
… | |
… | |
2457 | #endif |
2475 | #endif |
2458 | { |
2476 | { |
2459 | #ifdef _WIN32 |
2477 | #ifdef _WIN32 |
2460 | WSABUF buf; |
2478 | WSABUF buf; |
2461 | DWORD sent; |
2479 | DWORD sent; |
2462 | buf.buf = &buf; |
2480 | buf.buf = (char *)&buf; |
2463 | buf.len = 1; |
2481 | buf.len = 1; |
2464 | 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); |
2465 | #else |
2483 | #else |
2466 | write (evpipe [1], &(evpipe [1]), 1); |
2484 | write (evpipe [1], &(evpipe [1]), 1); |
2467 | #endif |
2485 | #endif |
… | |
… | |
2539 | } |
2557 | } |
2540 | |
2558 | |
2541 | /*****************************************************************************/ |
2559 | /*****************************************************************************/ |
2542 | |
2560 | |
2543 | void |
2561 | void |
2544 | ev_feed_signal (int signum) EV_THROW |
2562 | ev_feed_signal (int signum) EV_NOEXCEPT |
2545 | { |
2563 | { |
2546 | #if EV_MULTIPLICITY |
2564 | #if EV_MULTIPLICITY |
2547 | EV_P; |
2565 | EV_P; |
2548 | ECB_MEMORY_FENCE_ACQUIRE; |
2566 | ECB_MEMORY_FENCE_ACQUIRE; |
2549 | EV_A = signals [signum - 1].loop; |
2567 | EV_A = signals [signum - 1].loop; |
… | |
… | |
2564 | #endif |
2582 | #endif |
2565 | |
2583 | |
2566 | ev_feed_signal (signum); |
2584 | ev_feed_signal (signum); |
2567 | } |
2585 | } |
2568 | |
2586 | |
2569 | void noinline |
2587 | noinline |
|
|
2588 | void |
2570 | ev_feed_signal_event (EV_P_ int signum) EV_THROW |
2589 | ev_feed_signal_event (EV_P_ int signum) EV_NOEXCEPT |
2571 | { |
2590 | { |
2572 | WL w; |
2591 | WL w; |
2573 | |
2592 | |
2574 | if (expect_false (signum <= 0 || signum >= EV_NSIG)) |
2593 | if (expect_false (signum <= 0 || signum >= EV_NSIG)) |
2575 | return; |
2594 | return; |
… | |
… | |
2691 | #endif |
2710 | #endif |
2692 | #if EV_USE_SELECT |
2711 | #if EV_USE_SELECT |
2693 | # include "ev_select.c" |
2712 | # include "ev_select.c" |
2694 | #endif |
2713 | #endif |
2695 | |
2714 | |
2696 | int ecb_cold |
2715 | ecb_cold int |
2697 | ev_version_major (void) EV_THROW |
2716 | ev_version_major (void) EV_NOEXCEPT |
2698 | { |
2717 | { |
2699 | return EV_VERSION_MAJOR; |
2718 | return EV_VERSION_MAJOR; |
2700 | } |
2719 | } |
2701 | |
2720 | |
2702 | int ecb_cold |
2721 | ecb_cold int |
2703 | ev_version_minor (void) EV_THROW |
2722 | ev_version_minor (void) EV_NOEXCEPT |
2704 | { |
2723 | { |
2705 | return EV_VERSION_MINOR; |
2724 | return EV_VERSION_MINOR; |
2706 | } |
2725 | } |
2707 | |
2726 | |
2708 | /* return true if we are running with elevated privileges and should ignore env variables */ |
2727 | /* return true if we are running with elevated privileges and should ignore env variables */ |
2709 | int inline_size ecb_cold |
2728 | inline_size ecb_cold int |
2710 | enable_secure (void) |
2729 | enable_secure (void) |
2711 | { |
2730 | { |
2712 | #ifdef _WIN32 |
2731 | #ifdef _WIN32 |
2713 | return 0; |
2732 | return 0; |
2714 | #else |
2733 | #else |
2715 | return getuid () != geteuid () |
2734 | return getuid () != geteuid () |
2716 | || getgid () != getegid (); |
2735 | || getgid () != getegid (); |
2717 | #endif |
2736 | #endif |
2718 | } |
2737 | } |
2719 | |
2738 | |
2720 | unsigned int ecb_cold |
2739 | ecb_cold |
|
|
2740 | unsigned int |
2721 | ev_supported_backends (void) EV_THROW |
2741 | ev_supported_backends (void) EV_NOEXCEPT |
2722 | { |
2742 | { |
2723 | unsigned int flags = 0; |
2743 | unsigned int flags = 0; |
2724 | |
2744 | |
2725 | if (EV_USE_PORT ) flags |= EVBACKEND_PORT; |
2745 | if (EV_USE_PORT ) flags |= EVBACKEND_PORT; |
2726 | if (EV_USE_KQUEUE) flags |= EVBACKEND_KQUEUE; |
2746 | if (EV_USE_KQUEUE) flags |= EVBACKEND_KQUEUE; |
… | |
… | |
2729 | if (EV_USE_SELECT) flags |= EVBACKEND_SELECT; |
2749 | if (EV_USE_SELECT) flags |= EVBACKEND_SELECT; |
2730 | |
2750 | |
2731 | return flags; |
2751 | return flags; |
2732 | } |
2752 | } |
2733 | |
2753 | |
2734 | unsigned int ecb_cold |
2754 | ecb_cold |
|
|
2755 | unsigned int |
2735 | ev_recommended_backends (void) EV_THROW |
2756 | ev_recommended_backends (void) EV_NOEXCEPT |
2736 | { |
2757 | { |
2737 | unsigned int flags = ev_supported_backends (); |
2758 | unsigned int flags = ev_supported_backends (); |
2738 | |
2759 | |
2739 | #ifndef __NetBSD__ |
2760 | #ifndef __NetBSD__ |
2740 | /* kqueue is borked on everything but netbsd apparently */ |
2761 | /* kqueue is borked on everything but netbsd apparently */ |
… | |
… | |
2751 | #endif |
2772 | #endif |
2752 | |
2773 | |
2753 | return flags; |
2774 | return flags; |
2754 | } |
2775 | } |
2755 | |
2776 | |
2756 | unsigned int ecb_cold |
2777 | ecb_cold |
|
|
2778 | unsigned int |
2757 | ev_embeddable_backends (void) EV_THROW |
2779 | ev_embeddable_backends (void) EV_NOEXCEPT |
2758 | { |
2780 | { |
2759 | int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; |
2781 | int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; |
2760 | |
2782 | |
2761 | /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ |
2783 | /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ |
2762 | if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ |
2784 | if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ |
… | |
… | |
2764 | |
2786 | |
2765 | return flags; |
2787 | return flags; |
2766 | } |
2788 | } |
2767 | |
2789 | |
2768 | unsigned int |
2790 | unsigned int |
2769 | ev_backend (EV_P) EV_THROW |
2791 | ev_backend (EV_P) EV_NOEXCEPT |
2770 | { |
2792 | { |
2771 | return backend; |
2793 | return backend; |
2772 | } |
2794 | } |
2773 | |
2795 | |
2774 | #if EV_FEATURE_API |
2796 | #if EV_FEATURE_API |
2775 | unsigned int |
2797 | unsigned int |
2776 | ev_iteration (EV_P) EV_THROW |
2798 | ev_iteration (EV_P) EV_NOEXCEPT |
2777 | { |
2799 | { |
2778 | return loop_count; |
2800 | return loop_count; |
2779 | } |
2801 | } |
2780 | |
2802 | |
2781 | unsigned int |
2803 | unsigned int |
2782 | ev_depth (EV_P) EV_THROW |
2804 | ev_depth (EV_P) EV_NOEXCEPT |
2783 | { |
2805 | { |
2784 | return loop_depth; |
2806 | return loop_depth; |
2785 | } |
2807 | } |
2786 | |
2808 | |
2787 | void |
2809 | void |
2788 | ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_THROW |
2810 | ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_NOEXCEPT |
2789 | { |
2811 | { |
2790 | io_blocktime = interval; |
2812 | io_blocktime = interval; |
2791 | } |
2813 | } |
2792 | |
2814 | |
2793 | void |
2815 | void |
2794 | ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW |
2816 | ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_NOEXCEPT |
2795 | { |
2817 | { |
2796 | timeout_blocktime = interval; |
2818 | timeout_blocktime = interval; |
2797 | } |
2819 | } |
2798 | |
2820 | |
2799 | void |
2821 | void |
2800 | ev_set_userdata (EV_P_ void *data) EV_THROW |
2822 | ev_set_userdata (EV_P_ void *data) EV_NOEXCEPT |
2801 | { |
2823 | { |
2802 | userdata = data; |
2824 | userdata = data; |
2803 | } |
2825 | } |
2804 | |
2826 | |
2805 | void * |
2827 | void * |
2806 | ev_userdata (EV_P) EV_THROW |
2828 | ev_userdata (EV_P) EV_NOEXCEPT |
2807 | { |
2829 | { |
2808 | return userdata; |
2830 | return userdata; |
2809 | } |
2831 | } |
2810 | |
2832 | |
2811 | void |
2833 | void |
2812 | ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW |
2834 | ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_NOEXCEPT |
2813 | { |
2835 | { |
2814 | invoke_cb = invoke_pending_cb; |
2836 | invoke_cb = invoke_pending_cb; |
2815 | } |
2837 | } |
2816 | |
2838 | |
2817 | void |
2839 | void |
2818 | ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW |
2840 | ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_NOEXCEPT, void (*acquire)(EV_P) EV_NOEXCEPT) EV_NOEXCEPT |
2819 | { |
2841 | { |
2820 | release_cb = release; |
2842 | release_cb = release; |
2821 | acquire_cb = acquire; |
2843 | acquire_cb = acquire; |
2822 | } |
2844 | } |
2823 | #endif |
2845 | #endif |
2824 | |
2846 | |
2825 | /* initialise a loop structure, must be zero-initialised */ |
2847 | /* initialise a loop structure, must be zero-initialised */ |
2826 | static void noinline ecb_cold |
2848 | noinline ecb_cold |
|
|
2849 | static void |
2827 | loop_init (EV_P_ unsigned int flags) EV_THROW |
2850 | loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT |
2828 | { |
2851 | { |
2829 | if (!backend) |
2852 | if (!backend) |
2830 | { |
2853 | { |
2831 | origflags = flags; |
2854 | origflags = flags; |
2832 | |
2855 | |
… | |
… | |
2918 | #endif |
2941 | #endif |
2919 | } |
2942 | } |
2920 | } |
2943 | } |
2921 | |
2944 | |
2922 | /* free up a loop structure */ |
2945 | /* free up a loop structure */ |
2923 | void ecb_cold |
2946 | ecb_cold |
|
|
2947 | void |
2924 | ev_loop_destroy (EV_P) |
2948 | ev_loop_destroy (EV_P) |
2925 | { |
2949 | { |
2926 | int i; |
2950 | int i; |
2927 | |
2951 | |
2928 | #if EV_MULTIPLICITY |
2952 | #if EV_MULTIPLICITY |
… | |
… | |
3070 | postfork = 0; |
3094 | postfork = 0; |
3071 | } |
3095 | } |
3072 | |
3096 | |
3073 | #if EV_MULTIPLICITY |
3097 | #if EV_MULTIPLICITY |
3074 | |
3098 | |
|
|
3099 | ecb_cold |
3075 | struct ev_loop * ecb_cold |
3100 | struct ev_loop * |
3076 | ev_loop_new (unsigned int flags) EV_THROW |
3101 | ev_loop_new (unsigned int flags) EV_NOEXCEPT |
3077 | { |
3102 | { |
3078 | EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); |
3103 | EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); |
3079 | |
3104 | |
3080 | memset (EV_A, 0, sizeof (struct ev_loop)); |
3105 | memset (EV_A, 0, sizeof (struct ev_loop)); |
3081 | loop_init (EV_A_ flags); |
3106 | loop_init (EV_A_ flags); |
… | |
… | |
3088 | } |
3113 | } |
3089 | |
3114 | |
3090 | #endif /* multiplicity */ |
3115 | #endif /* multiplicity */ |
3091 | |
3116 | |
3092 | #if EV_VERIFY |
3117 | #if EV_VERIFY |
3093 | static void noinline ecb_cold |
3118 | noinline ecb_cold |
|
|
3119 | static void |
3094 | verify_watcher (EV_P_ W w) |
3120 | verify_watcher (EV_P_ W w) |
3095 | { |
3121 | { |
3096 | assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); |
3122 | assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); |
3097 | |
3123 | |
3098 | if (w->pending) |
3124 | if (w->pending) |
3099 | assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w)); |
3125 | assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w)); |
3100 | } |
3126 | } |
3101 | |
3127 | |
3102 | static void noinline ecb_cold |
3128 | noinline ecb_cold |
|
|
3129 | static void |
3103 | verify_heap (EV_P_ ANHE *heap, int N) |
3130 | verify_heap (EV_P_ ANHE *heap, int N) |
3104 | { |
3131 | { |
3105 | int i; |
3132 | int i; |
3106 | |
3133 | |
3107 | for (i = HEAP0; i < N + HEAP0; ++i) |
3134 | for (i = HEAP0; i < N + HEAP0; ++i) |
… | |
… | |
3112 | |
3139 | |
3113 | verify_watcher (EV_A_ (W)ANHE_w (heap [i])); |
3140 | verify_watcher (EV_A_ (W)ANHE_w (heap [i])); |
3114 | } |
3141 | } |
3115 | } |
3142 | } |
3116 | |
3143 | |
3117 | static void noinline ecb_cold |
3144 | noinline ecb_cold |
|
|
3145 | static void |
3118 | array_verify (EV_P_ W *ws, int cnt) |
3146 | array_verify (EV_P_ W *ws, int cnt) |
3119 | { |
3147 | { |
3120 | while (cnt--) |
3148 | while (cnt--) |
3121 | { |
3149 | { |
3122 | assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1)); |
3150 | assert (("libev: active index mismatch", ev_active (ws [cnt]) == cnt + 1)); |
… | |
… | |
3125 | } |
3153 | } |
3126 | #endif |
3154 | #endif |
3127 | |
3155 | |
3128 | #if EV_FEATURE_API |
3156 | #if EV_FEATURE_API |
3129 | void ecb_cold |
3157 | void ecb_cold |
3130 | ev_verify (EV_P) EV_THROW |
3158 | ev_verify (EV_P) EV_NOEXCEPT |
3131 | { |
3159 | { |
3132 | #if EV_VERIFY |
3160 | #if EV_VERIFY |
3133 | int i; |
3161 | int i; |
3134 | WL w, w2; |
3162 | WL w, w2; |
3135 | |
3163 | |
… | |
… | |
3211 | #endif |
3239 | #endif |
3212 | } |
3240 | } |
3213 | #endif |
3241 | #endif |
3214 | |
3242 | |
3215 | #if EV_MULTIPLICITY |
3243 | #if EV_MULTIPLICITY |
|
|
3244 | ecb_cold |
3216 | struct ev_loop * ecb_cold |
3245 | struct ev_loop * |
3217 | #else |
3246 | #else |
3218 | int |
3247 | int |
3219 | #endif |
3248 | #endif |
3220 | ev_default_loop (unsigned int flags) EV_THROW |
3249 | ev_default_loop (unsigned int flags) EV_NOEXCEPT |
3221 | { |
3250 | { |
3222 | if (!ev_default_loop_ptr) |
3251 | if (!ev_default_loop_ptr) |
3223 | { |
3252 | { |
3224 | #if EV_MULTIPLICITY |
3253 | #if EV_MULTIPLICITY |
3225 | EV_P = ev_default_loop_ptr = &default_loop_struct; |
3254 | EV_P = ev_default_loop_ptr = &default_loop_struct; |
… | |
… | |
3244 | |
3273 | |
3245 | return ev_default_loop_ptr; |
3274 | return ev_default_loop_ptr; |
3246 | } |
3275 | } |
3247 | |
3276 | |
3248 | void |
3277 | void |
3249 | ev_loop_fork (EV_P) EV_THROW |
3278 | ev_loop_fork (EV_P) EV_NOEXCEPT |
3250 | { |
3279 | { |
3251 | postfork = 1; |
3280 | postfork = 1; |
3252 | } |
3281 | } |
3253 | |
3282 | |
3254 | /*****************************************************************************/ |
3283 | /*****************************************************************************/ |
… | |
… | |
3258 | { |
3287 | { |
3259 | EV_CB_INVOKE ((W)w, revents); |
3288 | EV_CB_INVOKE ((W)w, revents); |
3260 | } |
3289 | } |
3261 | |
3290 | |
3262 | unsigned int |
3291 | unsigned int |
3263 | ev_pending_count (EV_P) EV_THROW |
3292 | ev_pending_count (EV_P) EV_NOEXCEPT |
3264 | { |
3293 | { |
3265 | int pri; |
3294 | int pri; |
3266 | unsigned int count = 0; |
3295 | unsigned int count = 0; |
3267 | |
3296 | |
3268 | for (pri = NUMPRI; pri--; ) |
3297 | for (pri = NUMPRI; pri--; ) |
3269 | count += pendingcnt [pri]; |
3298 | count += pendingcnt [pri]; |
3270 | |
3299 | |
3271 | return count; |
3300 | return count; |
3272 | } |
3301 | } |
3273 | |
3302 | |
3274 | void noinline |
3303 | noinline |
|
|
3304 | void |
3275 | ev_invoke_pending (EV_P) |
3305 | ev_invoke_pending (EV_P) |
3276 | { |
3306 | { |
3277 | pendingpri = NUMPRI; |
3307 | pendingpri = NUMPRI; |
3278 | |
3308 | |
3279 | while (pendingpri) /* pendingpri possibly gets modified in the inner loop */ |
3309 | do |
3280 | { |
3310 | { |
3281 | --pendingpri; |
3311 | --pendingpri; |
3282 | |
3312 | |
|
|
3313 | /* pendingpri possibly gets modified in the inner loop */ |
3283 | while (pendingcnt [pendingpri]) |
3314 | while (pendingcnt [pendingpri]) |
3284 | { |
3315 | { |
3285 | ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; |
3316 | ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; |
3286 | |
3317 | |
3287 | p->w->pending = 0; |
3318 | p->w->pending = 0; |
3288 | EV_CB_INVOKE (p->w, p->events); |
3319 | EV_CB_INVOKE (p->w, p->events); |
3289 | EV_FREQUENT_CHECK; |
3320 | EV_FREQUENT_CHECK; |
3290 | } |
3321 | } |
3291 | } |
3322 | } |
|
|
3323 | while (pendingpri); |
3292 | } |
3324 | } |
3293 | |
3325 | |
3294 | #if EV_IDLE_ENABLE |
3326 | #if EV_IDLE_ENABLE |
3295 | /* make idle watchers pending. this handles the "call-idle */ |
3327 | /* make idle watchers pending. this handles the "call-idle */ |
3296 | /* only when higher priorities are idle" logic */ |
3328 | /* only when higher priorities are idle" logic */ |
… | |
… | |
3354 | } |
3386 | } |
3355 | } |
3387 | } |
3356 | |
3388 | |
3357 | #if EV_PERIODIC_ENABLE |
3389 | #if EV_PERIODIC_ENABLE |
3358 | |
3390 | |
3359 | static void noinline |
3391 | noinline |
|
|
3392 | static void |
3360 | periodic_recalc (EV_P_ ev_periodic *w) |
3393 | periodic_recalc (EV_P_ ev_periodic *w) |
3361 | { |
3394 | { |
3362 | ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; |
3395 | ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; |
3363 | ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); |
3396 | ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); |
3364 | |
3397 | |
… | |
… | |
3422 | } |
3455 | } |
3423 | } |
3456 | } |
3424 | |
3457 | |
3425 | /* simply recalculate all periodics */ |
3458 | /* simply recalculate all periodics */ |
3426 | /* TODO: maybe ensure that at least one event happens when jumping forward? */ |
3459 | /* TODO: maybe ensure that at least one event happens when jumping forward? */ |
3427 | static void noinline ecb_cold |
3460 | noinline ecb_cold |
|
|
3461 | static void |
3428 | periodics_reschedule (EV_P) |
3462 | periodics_reschedule (EV_P) |
3429 | { |
3463 | { |
3430 | int i; |
3464 | int i; |
3431 | |
3465 | |
3432 | /* adjust periodics after time jump */ |
3466 | /* adjust periodics after time jump */ |
… | |
… | |
3445 | reheap (periodics, periodiccnt); |
3479 | reheap (periodics, periodiccnt); |
3446 | } |
3480 | } |
3447 | #endif |
3481 | #endif |
3448 | |
3482 | |
3449 | /* adjust all timers by a given offset */ |
3483 | /* adjust all timers by a given offset */ |
3450 | static void noinline ecb_cold |
3484 | noinline ecb_cold |
|
|
3485 | static void |
3451 | timers_reschedule (EV_P_ ev_tstamp adjust) |
3486 | timers_reschedule (EV_P_ ev_tstamp adjust) |
3452 | { |
3487 | { |
3453 | int i; |
3488 | int i; |
3454 | |
3489 | |
3455 | for (i = 0; i < timercnt; ++i) |
3490 | for (i = 0; i < timercnt; ++i) |
… | |
… | |
3702 | |
3737 | |
3703 | return activecnt; |
3738 | return activecnt; |
3704 | } |
3739 | } |
3705 | |
3740 | |
3706 | void |
3741 | void |
3707 | ev_break (EV_P_ int how) EV_THROW |
3742 | ev_break (EV_P_ int how) EV_NOEXCEPT |
3708 | { |
3743 | { |
3709 | loop_done = how; |
3744 | loop_done = how; |
3710 | } |
3745 | } |
3711 | |
3746 | |
3712 | void |
3747 | void |
3713 | ev_ref (EV_P) EV_THROW |
3748 | ev_ref (EV_P) EV_NOEXCEPT |
3714 | { |
3749 | { |
3715 | ++activecnt; |
3750 | ++activecnt; |
3716 | } |
3751 | } |
3717 | |
3752 | |
3718 | void |
3753 | void |
3719 | ev_unref (EV_P) EV_THROW |
3754 | ev_unref (EV_P) EV_NOEXCEPT |
3720 | { |
3755 | { |
3721 | --activecnt; |
3756 | --activecnt; |
3722 | } |
3757 | } |
3723 | |
3758 | |
3724 | void |
3759 | void |
3725 | ev_now_update (EV_P) EV_THROW |
3760 | ev_now_update (EV_P) EV_NOEXCEPT |
3726 | { |
3761 | { |
3727 | time_update (EV_A_ 1e100); |
3762 | time_update (EV_A_ 1e100); |
3728 | } |
3763 | } |
3729 | |
3764 | |
3730 | void |
3765 | void |
3731 | ev_suspend (EV_P) EV_THROW |
3766 | ev_suspend (EV_P) EV_NOEXCEPT |
3732 | { |
3767 | { |
3733 | ev_now_update (EV_A); |
3768 | ev_now_update (EV_A); |
3734 | } |
3769 | } |
3735 | |
3770 | |
3736 | void |
3771 | void |
3737 | ev_resume (EV_P) EV_THROW |
3772 | ev_resume (EV_P) EV_NOEXCEPT |
3738 | { |
3773 | { |
3739 | ev_tstamp mn_prev = mn_now; |
3774 | ev_tstamp mn_prev = mn_now; |
3740 | |
3775 | |
3741 | ev_now_update (EV_A); |
3776 | ev_now_update (EV_A); |
3742 | timers_reschedule (EV_A_ mn_now - mn_prev); |
3777 | timers_reschedule (EV_A_ mn_now - mn_prev); |
… | |
… | |
3781 | w->pending = 0; |
3816 | w->pending = 0; |
3782 | } |
3817 | } |
3783 | } |
3818 | } |
3784 | |
3819 | |
3785 | int |
3820 | int |
3786 | ev_clear_pending (EV_P_ void *w) EV_THROW |
3821 | ev_clear_pending (EV_P_ void *w) EV_NOEXCEPT |
3787 | { |
3822 | { |
3788 | W w_ = (W)w; |
3823 | W w_ = (W)w; |
3789 | int pending = w_->pending; |
3824 | int pending = w_->pending; |
3790 | |
3825 | |
3791 | if (expect_true (pending)) |
3826 | if (expect_true (pending)) |
… | |
… | |
3823 | w->active = 0; |
3858 | w->active = 0; |
3824 | } |
3859 | } |
3825 | |
3860 | |
3826 | /*****************************************************************************/ |
3861 | /*****************************************************************************/ |
3827 | |
3862 | |
3828 | void noinline |
3863 | noinline |
|
|
3864 | void |
3829 | ev_io_start (EV_P_ ev_io *w) EV_THROW |
3865 | ev_io_start (EV_P_ ev_io *w) EV_NOEXCEPT |
3830 | { |
3866 | { |
3831 | int fd = w->fd; |
3867 | int fd = w->fd; |
3832 | |
3868 | |
3833 | if (expect_false (ev_is_active (w))) |
3869 | if (expect_false (ev_is_active (w))) |
3834 | return; |
3870 | return; |
… | |
… | |
3849 | w->events &= ~EV__IOFDSET; |
3885 | w->events &= ~EV__IOFDSET; |
3850 | |
3886 | |
3851 | EV_FREQUENT_CHECK; |
3887 | EV_FREQUENT_CHECK; |
3852 | } |
3888 | } |
3853 | |
3889 | |
3854 | void noinline |
3890 | noinline |
|
|
3891 | void |
3855 | ev_io_stop (EV_P_ ev_io *w) EV_THROW |
3892 | ev_io_stop (EV_P_ ev_io *w) EV_NOEXCEPT |
3856 | { |
3893 | { |
3857 | clear_pending (EV_A_ (W)w); |
3894 | clear_pending (EV_A_ (W)w); |
3858 | if (expect_false (!ev_is_active (w))) |
3895 | if (expect_false (!ev_is_active (w))) |
3859 | return; |
3896 | return; |
3860 | |
3897 | |
… | |
… | |
3868 | fd_change (EV_A_ w->fd, EV_ANFD_REIFY); |
3905 | fd_change (EV_A_ w->fd, EV_ANFD_REIFY); |
3869 | |
3906 | |
3870 | EV_FREQUENT_CHECK; |
3907 | EV_FREQUENT_CHECK; |
3871 | } |
3908 | } |
3872 | |
3909 | |
3873 | void noinline |
3910 | noinline |
|
|
3911 | void |
3874 | ev_timer_start (EV_P_ ev_timer *w) EV_THROW |
3912 | ev_timer_start (EV_P_ ev_timer *w) EV_NOEXCEPT |
3875 | { |
3913 | { |
3876 | if (expect_false (ev_is_active (w))) |
3914 | if (expect_false (ev_is_active (w))) |
3877 | return; |
3915 | return; |
3878 | |
3916 | |
3879 | ev_at (w) += mn_now; |
3917 | ev_at (w) += mn_now; |
… | |
… | |
3892 | EV_FREQUENT_CHECK; |
3930 | EV_FREQUENT_CHECK; |
3893 | |
3931 | |
3894 | /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ |
3932 | /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ |
3895 | } |
3933 | } |
3896 | |
3934 | |
3897 | void noinline |
3935 | noinline |
|
|
3936 | void |
3898 | ev_timer_stop (EV_P_ ev_timer *w) EV_THROW |
3937 | ev_timer_stop (EV_P_ ev_timer *w) EV_NOEXCEPT |
3899 | { |
3938 | { |
3900 | clear_pending (EV_A_ (W)w); |
3939 | clear_pending (EV_A_ (W)w); |
3901 | if (expect_false (!ev_is_active (w))) |
3940 | if (expect_false (!ev_is_active (w))) |
3902 | return; |
3941 | return; |
3903 | |
3942 | |
… | |
… | |
3922 | ev_stop (EV_A_ (W)w); |
3961 | ev_stop (EV_A_ (W)w); |
3923 | |
3962 | |
3924 | EV_FREQUENT_CHECK; |
3963 | EV_FREQUENT_CHECK; |
3925 | } |
3964 | } |
3926 | |
3965 | |
3927 | void noinline |
3966 | noinline |
|
|
3967 | void |
3928 | ev_timer_again (EV_P_ ev_timer *w) EV_THROW |
3968 | ev_timer_again (EV_P_ ev_timer *w) EV_NOEXCEPT |
3929 | { |
3969 | { |
3930 | EV_FREQUENT_CHECK; |
3970 | EV_FREQUENT_CHECK; |
3931 | |
3971 | |
3932 | clear_pending (EV_A_ (W)w); |
3972 | clear_pending (EV_A_ (W)w); |
3933 | |
3973 | |
… | |
… | |
3950 | |
3990 | |
3951 | EV_FREQUENT_CHECK; |
3991 | EV_FREQUENT_CHECK; |
3952 | } |
3992 | } |
3953 | |
3993 | |
3954 | ev_tstamp |
3994 | ev_tstamp |
3955 | ev_timer_remaining (EV_P_ ev_timer *w) EV_THROW |
3995 | ev_timer_remaining (EV_P_ ev_timer *w) EV_NOEXCEPT |
3956 | { |
3996 | { |
3957 | return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); |
3997 | return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); |
3958 | } |
3998 | } |
3959 | |
3999 | |
3960 | #if EV_PERIODIC_ENABLE |
4000 | #if EV_PERIODIC_ENABLE |
3961 | void noinline |
4001 | noinline |
|
|
4002 | void |
3962 | ev_periodic_start (EV_P_ ev_periodic *w) EV_THROW |
4003 | ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT |
3963 | { |
4004 | { |
3964 | if (expect_false (ev_is_active (w))) |
4005 | if (expect_false (ev_is_active (w))) |
3965 | return; |
4006 | return; |
3966 | |
4007 | |
3967 | if (w->reschedule_cb) |
4008 | if (w->reschedule_cb) |
… | |
… | |
3986 | EV_FREQUENT_CHECK; |
4027 | EV_FREQUENT_CHECK; |
3987 | |
4028 | |
3988 | /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ |
4029 | /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ |
3989 | } |
4030 | } |
3990 | |
4031 | |
3991 | void noinline |
4032 | noinline |
|
|
4033 | void |
3992 | ev_periodic_stop (EV_P_ ev_periodic *w) EV_THROW |
4034 | ev_periodic_stop (EV_P_ ev_periodic *w) EV_NOEXCEPT |
3993 | { |
4035 | { |
3994 | clear_pending (EV_A_ (W)w); |
4036 | clear_pending (EV_A_ (W)w); |
3995 | if (expect_false (!ev_is_active (w))) |
4037 | if (expect_false (!ev_is_active (w))) |
3996 | return; |
4038 | return; |
3997 | |
4039 | |
… | |
… | |
4014 | ev_stop (EV_A_ (W)w); |
4056 | ev_stop (EV_A_ (W)w); |
4015 | |
4057 | |
4016 | EV_FREQUENT_CHECK; |
4058 | EV_FREQUENT_CHECK; |
4017 | } |
4059 | } |
4018 | |
4060 | |
4019 | void noinline |
4061 | noinline |
|
|
4062 | void |
4020 | ev_periodic_again (EV_P_ ev_periodic *w) EV_THROW |
4063 | ev_periodic_again (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4021 | { |
4064 | { |
4022 | /* TODO: use adjustheap and recalculation */ |
4065 | /* TODO: use adjustheap and recalculation */ |
4023 | ev_periodic_stop (EV_A_ w); |
4066 | ev_periodic_stop (EV_A_ w); |
4024 | ev_periodic_start (EV_A_ w); |
4067 | ev_periodic_start (EV_A_ w); |
4025 | } |
4068 | } |
… | |
… | |
4029 | # define SA_RESTART 0 |
4072 | # define SA_RESTART 0 |
4030 | #endif |
4073 | #endif |
4031 | |
4074 | |
4032 | #if EV_SIGNAL_ENABLE |
4075 | #if EV_SIGNAL_ENABLE |
4033 | |
4076 | |
4034 | void noinline |
4077 | noinline |
|
|
4078 | void |
4035 | ev_signal_start (EV_P_ ev_signal *w) EV_THROW |
4079 | ev_signal_start (EV_P_ ev_signal *w) EV_NOEXCEPT |
4036 | { |
4080 | { |
4037 | if (expect_false (ev_is_active (w))) |
4081 | if (expect_false (ev_is_active (w))) |
4038 | return; |
4082 | return; |
4039 | |
4083 | |
4040 | assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); |
4084 | assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); |
… | |
… | |
4111 | } |
4155 | } |
4112 | |
4156 | |
4113 | EV_FREQUENT_CHECK; |
4157 | EV_FREQUENT_CHECK; |
4114 | } |
4158 | } |
4115 | |
4159 | |
4116 | void noinline |
4160 | noinline |
|
|
4161 | void |
4117 | ev_signal_stop (EV_P_ ev_signal *w) EV_THROW |
4162 | ev_signal_stop (EV_P_ ev_signal *w) EV_NOEXCEPT |
4118 | { |
4163 | { |
4119 | clear_pending (EV_A_ (W)w); |
4164 | clear_pending (EV_A_ (W)w); |
4120 | if (expect_false (!ev_is_active (w))) |
4165 | if (expect_false (!ev_is_active (w))) |
4121 | return; |
4166 | return; |
4122 | |
4167 | |
… | |
… | |
4153 | #endif |
4198 | #endif |
4154 | |
4199 | |
4155 | #if EV_CHILD_ENABLE |
4200 | #if EV_CHILD_ENABLE |
4156 | |
4201 | |
4157 | void |
4202 | void |
4158 | ev_child_start (EV_P_ ev_child *w) EV_THROW |
4203 | ev_child_start (EV_P_ ev_child *w) EV_NOEXCEPT |
4159 | { |
4204 | { |
4160 | #if EV_MULTIPLICITY |
4205 | #if EV_MULTIPLICITY |
4161 | assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
4206 | assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
4162 | #endif |
4207 | #endif |
4163 | if (expect_false (ev_is_active (w))) |
4208 | if (expect_false (ev_is_active (w))) |
… | |
… | |
4170 | |
4215 | |
4171 | EV_FREQUENT_CHECK; |
4216 | EV_FREQUENT_CHECK; |
4172 | } |
4217 | } |
4173 | |
4218 | |
4174 | void |
4219 | void |
4175 | ev_child_stop (EV_P_ ev_child *w) EV_THROW |
4220 | ev_child_stop (EV_P_ ev_child *w) EV_NOEXCEPT |
4176 | { |
4221 | { |
4177 | clear_pending (EV_A_ (W)w); |
4222 | clear_pending (EV_A_ (W)w); |
4178 | if (expect_false (!ev_is_active (w))) |
4223 | if (expect_false (!ev_is_active (w))) |
4179 | return; |
4224 | return; |
4180 | |
4225 | |
… | |
… | |
4197 | |
4242 | |
4198 | #define DEF_STAT_INTERVAL 5.0074891 |
4243 | #define DEF_STAT_INTERVAL 5.0074891 |
4199 | #define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */ |
4244 | #define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */ |
4200 | #define MIN_STAT_INTERVAL 0.1074891 |
4245 | #define MIN_STAT_INTERVAL 0.1074891 |
4201 | |
4246 | |
4202 | static void noinline stat_timer_cb (EV_P_ ev_timer *w_, int revents); |
4247 | noinline static void stat_timer_cb (EV_P_ ev_timer *w_, int revents); |
4203 | |
4248 | |
4204 | #if EV_USE_INOTIFY |
4249 | #if EV_USE_INOTIFY |
4205 | |
4250 | |
4206 | /* the * 2 is to allow for alignment padding, which for some reason is >> 8 */ |
4251 | /* the * 2 is to allow for alignment padding, which for some reason is >> 8 */ |
4207 | # define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX) |
4252 | # define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX) |
4208 | |
4253 | |
4209 | static void noinline |
4254 | noinline |
|
|
4255 | static void |
4210 | infy_add (EV_P_ ev_stat *w) |
4256 | infy_add (EV_P_ ev_stat *w) |
4211 | { |
4257 | { |
4212 | w->wd = inotify_add_watch (fs_fd, w->path, |
4258 | w->wd = inotify_add_watch (fs_fd, w->path, |
4213 | IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY |
4259 | IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY |
4214 | | IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO |
4260 | | IN_CREATE | IN_DELETE | IN_MOVED_FROM | IN_MOVED_TO |
… | |
… | |
4278 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
4324 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
4279 | ev_timer_again (EV_A_ &w->timer); |
4325 | ev_timer_again (EV_A_ &w->timer); |
4280 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
4326 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
4281 | } |
4327 | } |
4282 | |
4328 | |
4283 | static void noinline |
4329 | noinline |
|
|
4330 | static void |
4284 | infy_del (EV_P_ ev_stat *w) |
4331 | infy_del (EV_P_ ev_stat *w) |
4285 | { |
4332 | { |
4286 | int slot; |
4333 | int slot; |
4287 | int wd = w->wd; |
4334 | int wd = w->wd; |
4288 | |
4335 | |
… | |
… | |
4295 | |
4342 | |
4296 | /* remove this watcher, if others are watching it, they will rearm */ |
4343 | /* remove this watcher, if others are watching it, they will rearm */ |
4297 | inotify_rm_watch (fs_fd, wd); |
4344 | inotify_rm_watch (fs_fd, wd); |
4298 | } |
4345 | } |
4299 | |
4346 | |
4300 | static void noinline |
4347 | noinline |
|
|
4348 | static void |
4301 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
4349 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
4302 | { |
4350 | { |
4303 | if (slot < 0) |
4351 | if (slot < 0) |
4304 | /* overflow, need to check for all hash slots */ |
4352 | /* overflow, need to check for all hash slots */ |
4305 | for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) |
4353 | for (slot = 0; slot < (EV_INOTIFY_HASHSIZE); ++slot) |
… | |
… | |
4341 | infy_wd (EV_A_ ev->wd, ev->wd, ev); |
4389 | infy_wd (EV_A_ ev->wd, ev->wd, ev); |
4342 | ofs += sizeof (struct inotify_event) + ev->len; |
4390 | ofs += sizeof (struct inotify_event) + ev->len; |
4343 | } |
4391 | } |
4344 | } |
4392 | } |
4345 | |
4393 | |
4346 | inline_size void ecb_cold |
4394 | inline_size ecb_cold |
|
|
4395 | void |
4347 | ev_check_2625 (EV_P) |
4396 | ev_check_2625 (EV_P) |
4348 | { |
4397 | { |
4349 | /* kernels < 2.6.25 are borked |
4398 | /* kernels < 2.6.25 are borked |
4350 | * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html |
4399 | * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html |
4351 | */ |
4400 | */ |
… | |
… | |
4441 | #else |
4490 | #else |
4442 | # define EV_LSTAT(p,b) lstat (p, b) |
4491 | # define EV_LSTAT(p,b) lstat (p, b) |
4443 | #endif |
4492 | #endif |
4444 | |
4493 | |
4445 | void |
4494 | void |
4446 | ev_stat_stat (EV_P_ ev_stat *w) EV_THROW |
4495 | ev_stat_stat (EV_P_ ev_stat *w) EV_NOEXCEPT |
4447 | { |
4496 | { |
4448 | if (lstat (w->path, &w->attr) < 0) |
4497 | if (lstat (w->path, &w->attr) < 0) |
4449 | w->attr.st_nlink = 0; |
4498 | w->attr.st_nlink = 0; |
4450 | else if (!w->attr.st_nlink) |
4499 | else if (!w->attr.st_nlink) |
4451 | w->attr.st_nlink = 1; |
4500 | w->attr.st_nlink = 1; |
4452 | } |
4501 | } |
4453 | |
4502 | |
4454 | static void noinline |
4503 | noinline |
|
|
4504 | static void |
4455 | stat_timer_cb (EV_P_ ev_timer *w_, int revents) |
4505 | stat_timer_cb (EV_P_ ev_timer *w_, int revents) |
4456 | { |
4506 | { |
4457 | ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); |
4507 | ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); |
4458 | |
4508 | |
4459 | ev_statdata prev = w->attr; |
4509 | ev_statdata prev = w->attr; |
… | |
… | |
4490 | ev_feed_event (EV_A_ w, EV_STAT); |
4540 | ev_feed_event (EV_A_ w, EV_STAT); |
4491 | } |
4541 | } |
4492 | } |
4542 | } |
4493 | |
4543 | |
4494 | void |
4544 | void |
4495 | ev_stat_start (EV_P_ ev_stat *w) EV_THROW |
4545 | ev_stat_start (EV_P_ ev_stat *w) EV_NOEXCEPT |
4496 | { |
4546 | { |
4497 | if (expect_false (ev_is_active (w))) |
4547 | if (expect_false (ev_is_active (w))) |
4498 | return; |
4548 | return; |
4499 | |
4549 | |
4500 | ev_stat_stat (EV_A_ w); |
4550 | ev_stat_stat (EV_A_ w); |
… | |
… | |
4521 | |
4571 | |
4522 | EV_FREQUENT_CHECK; |
4572 | EV_FREQUENT_CHECK; |
4523 | } |
4573 | } |
4524 | |
4574 | |
4525 | void |
4575 | void |
4526 | ev_stat_stop (EV_P_ ev_stat *w) EV_THROW |
4576 | ev_stat_stop (EV_P_ ev_stat *w) EV_NOEXCEPT |
4527 | { |
4577 | { |
4528 | clear_pending (EV_A_ (W)w); |
4578 | clear_pending (EV_A_ (W)w); |
4529 | if (expect_false (!ev_is_active (w))) |
4579 | if (expect_false (!ev_is_active (w))) |
4530 | return; |
4580 | return; |
4531 | |
4581 | |
… | |
… | |
4547 | } |
4597 | } |
4548 | #endif |
4598 | #endif |
4549 | |
4599 | |
4550 | #if EV_IDLE_ENABLE |
4600 | #if EV_IDLE_ENABLE |
4551 | void |
4601 | void |
4552 | ev_idle_start (EV_P_ ev_idle *w) EV_THROW |
4602 | ev_idle_start (EV_P_ ev_idle *w) EV_NOEXCEPT |
4553 | { |
4603 | { |
4554 | if (expect_false (ev_is_active (w))) |
4604 | if (expect_false (ev_is_active (w))) |
4555 | return; |
4605 | return; |
4556 | |
4606 | |
4557 | pri_adjust (EV_A_ (W)w); |
4607 | pri_adjust (EV_A_ (W)w); |
… | |
… | |
4570 | |
4620 | |
4571 | EV_FREQUENT_CHECK; |
4621 | EV_FREQUENT_CHECK; |
4572 | } |
4622 | } |
4573 | |
4623 | |
4574 | void |
4624 | void |
4575 | ev_idle_stop (EV_P_ ev_idle *w) EV_THROW |
4625 | ev_idle_stop (EV_P_ ev_idle *w) EV_NOEXCEPT |
4576 | { |
4626 | { |
4577 | clear_pending (EV_A_ (W)w); |
4627 | clear_pending (EV_A_ (W)w); |
4578 | if (expect_false (!ev_is_active (w))) |
4628 | if (expect_false (!ev_is_active (w))) |
4579 | return; |
4629 | return; |
4580 | |
4630 | |
… | |
… | |
4594 | } |
4644 | } |
4595 | #endif |
4645 | #endif |
4596 | |
4646 | |
4597 | #if EV_PREPARE_ENABLE |
4647 | #if EV_PREPARE_ENABLE |
4598 | void |
4648 | void |
4599 | ev_prepare_start (EV_P_ ev_prepare *w) EV_THROW |
4649 | ev_prepare_start (EV_P_ ev_prepare *w) EV_NOEXCEPT |
4600 | { |
4650 | { |
4601 | if (expect_false (ev_is_active (w))) |
4651 | if (expect_false (ev_is_active (w))) |
4602 | return; |
4652 | return; |
4603 | |
4653 | |
4604 | EV_FREQUENT_CHECK; |
4654 | EV_FREQUENT_CHECK; |
… | |
… | |
4609 | |
4659 | |
4610 | EV_FREQUENT_CHECK; |
4660 | EV_FREQUENT_CHECK; |
4611 | } |
4661 | } |
4612 | |
4662 | |
4613 | void |
4663 | void |
4614 | ev_prepare_stop (EV_P_ ev_prepare *w) EV_THROW |
4664 | ev_prepare_stop (EV_P_ ev_prepare *w) EV_NOEXCEPT |
4615 | { |
4665 | { |
4616 | clear_pending (EV_A_ (W)w); |
4666 | clear_pending (EV_A_ (W)w); |
4617 | if (expect_false (!ev_is_active (w))) |
4667 | if (expect_false (!ev_is_active (w))) |
4618 | return; |
4668 | return; |
4619 | |
4669 | |
… | |
… | |
4632 | } |
4682 | } |
4633 | #endif |
4683 | #endif |
4634 | |
4684 | |
4635 | #if EV_CHECK_ENABLE |
4685 | #if EV_CHECK_ENABLE |
4636 | void |
4686 | void |
4637 | ev_check_start (EV_P_ ev_check *w) EV_THROW |
4687 | ev_check_start (EV_P_ ev_check *w) EV_NOEXCEPT |
4638 | { |
4688 | { |
4639 | if (expect_false (ev_is_active (w))) |
4689 | if (expect_false (ev_is_active (w))) |
4640 | return; |
4690 | return; |
4641 | |
4691 | |
4642 | EV_FREQUENT_CHECK; |
4692 | EV_FREQUENT_CHECK; |
… | |
… | |
4647 | |
4697 | |
4648 | EV_FREQUENT_CHECK; |
4698 | EV_FREQUENT_CHECK; |
4649 | } |
4699 | } |
4650 | |
4700 | |
4651 | void |
4701 | void |
4652 | ev_check_stop (EV_P_ ev_check *w) EV_THROW |
4702 | ev_check_stop (EV_P_ ev_check *w) EV_NOEXCEPT |
4653 | { |
4703 | { |
4654 | clear_pending (EV_A_ (W)w); |
4704 | clear_pending (EV_A_ (W)w); |
4655 | if (expect_false (!ev_is_active (w))) |
4705 | if (expect_false (!ev_is_active (w))) |
4656 | return; |
4706 | return; |
4657 | |
4707 | |
… | |
… | |
4669 | EV_FREQUENT_CHECK; |
4719 | EV_FREQUENT_CHECK; |
4670 | } |
4720 | } |
4671 | #endif |
4721 | #endif |
4672 | |
4722 | |
4673 | #if EV_EMBED_ENABLE |
4723 | #if EV_EMBED_ENABLE |
4674 | void noinline |
4724 | noinline |
|
|
4725 | void |
4675 | ev_embed_sweep (EV_P_ ev_embed *w) EV_THROW |
4726 | ev_embed_sweep (EV_P_ ev_embed *w) EV_NOEXCEPT |
4676 | { |
4727 | { |
4677 | ev_run (w->other, EVRUN_NOWAIT); |
4728 | ev_run (w->other, EVRUN_NOWAIT); |
4678 | } |
4729 | } |
4679 | |
4730 | |
4680 | static void |
4731 | static void |
… | |
… | |
4728 | ev_idle_stop (EV_A_ idle); |
4779 | ev_idle_stop (EV_A_ idle); |
4729 | } |
4780 | } |
4730 | #endif |
4781 | #endif |
4731 | |
4782 | |
4732 | void |
4783 | void |
4733 | ev_embed_start (EV_P_ ev_embed *w) EV_THROW |
4784 | ev_embed_start (EV_P_ ev_embed *w) EV_NOEXCEPT |
4734 | { |
4785 | { |
4735 | if (expect_false (ev_is_active (w))) |
4786 | if (expect_false (ev_is_active (w))) |
4736 | return; |
4787 | return; |
4737 | |
4788 | |
4738 | { |
4789 | { |
… | |
… | |
4759 | |
4810 | |
4760 | EV_FREQUENT_CHECK; |
4811 | EV_FREQUENT_CHECK; |
4761 | } |
4812 | } |
4762 | |
4813 | |
4763 | void |
4814 | void |
4764 | ev_embed_stop (EV_P_ ev_embed *w) EV_THROW |
4815 | ev_embed_stop (EV_P_ ev_embed *w) EV_NOEXCEPT |
4765 | { |
4816 | { |
4766 | clear_pending (EV_A_ (W)w); |
4817 | clear_pending (EV_A_ (W)w); |
4767 | if (expect_false (!ev_is_active (w))) |
4818 | if (expect_false (!ev_is_active (w))) |
4768 | return; |
4819 | return; |
4769 | |
4820 | |
… | |
… | |
4779 | } |
4830 | } |
4780 | #endif |
4831 | #endif |
4781 | |
4832 | |
4782 | #if EV_FORK_ENABLE |
4833 | #if EV_FORK_ENABLE |
4783 | void |
4834 | void |
4784 | ev_fork_start (EV_P_ ev_fork *w) EV_THROW |
4835 | ev_fork_start (EV_P_ ev_fork *w) EV_NOEXCEPT |
4785 | { |
4836 | { |
4786 | if (expect_false (ev_is_active (w))) |
4837 | if (expect_false (ev_is_active (w))) |
4787 | return; |
4838 | return; |
4788 | |
4839 | |
4789 | EV_FREQUENT_CHECK; |
4840 | EV_FREQUENT_CHECK; |
… | |
… | |
4794 | |
4845 | |
4795 | EV_FREQUENT_CHECK; |
4846 | EV_FREQUENT_CHECK; |
4796 | } |
4847 | } |
4797 | |
4848 | |
4798 | void |
4849 | void |
4799 | ev_fork_stop (EV_P_ ev_fork *w) EV_THROW |
4850 | ev_fork_stop (EV_P_ ev_fork *w) EV_NOEXCEPT |
4800 | { |
4851 | { |
4801 | clear_pending (EV_A_ (W)w); |
4852 | clear_pending (EV_A_ (W)w); |
4802 | if (expect_false (!ev_is_active (w))) |
4853 | if (expect_false (!ev_is_active (w))) |
4803 | return; |
4854 | return; |
4804 | |
4855 | |
… | |
… | |
4817 | } |
4868 | } |
4818 | #endif |
4869 | #endif |
4819 | |
4870 | |
4820 | #if EV_CLEANUP_ENABLE |
4871 | #if EV_CLEANUP_ENABLE |
4821 | void |
4872 | void |
4822 | ev_cleanup_start (EV_P_ ev_cleanup *w) EV_THROW |
4873 | ev_cleanup_start (EV_P_ ev_cleanup *w) EV_NOEXCEPT |
4823 | { |
4874 | { |
4824 | if (expect_false (ev_is_active (w))) |
4875 | if (expect_false (ev_is_active (w))) |
4825 | return; |
4876 | return; |
4826 | |
4877 | |
4827 | EV_FREQUENT_CHECK; |
4878 | EV_FREQUENT_CHECK; |
… | |
… | |
4834 | ev_unref (EV_A); |
4885 | ev_unref (EV_A); |
4835 | EV_FREQUENT_CHECK; |
4886 | EV_FREQUENT_CHECK; |
4836 | } |
4887 | } |
4837 | |
4888 | |
4838 | void |
4889 | void |
4839 | ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_THROW |
4890 | ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_NOEXCEPT |
4840 | { |
4891 | { |
4841 | clear_pending (EV_A_ (W)w); |
4892 | clear_pending (EV_A_ (W)w); |
4842 | if (expect_false (!ev_is_active (w))) |
4893 | if (expect_false (!ev_is_active (w))) |
4843 | return; |
4894 | return; |
4844 | |
4895 | |
… | |
… | |
4858 | } |
4909 | } |
4859 | #endif |
4910 | #endif |
4860 | |
4911 | |
4861 | #if EV_ASYNC_ENABLE |
4912 | #if EV_ASYNC_ENABLE |
4862 | void |
4913 | void |
4863 | ev_async_start (EV_P_ ev_async *w) EV_THROW |
4914 | ev_async_start (EV_P_ ev_async *w) EV_NOEXCEPT |
4864 | { |
4915 | { |
4865 | if (expect_false (ev_is_active (w))) |
4916 | if (expect_false (ev_is_active (w))) |
4866 | return; |
4917 | return; |
4867 | |
4918 | |
4868 | w->sent = 0; |
4919 | w->sent = 0; |
… | |
… | |
4877 | |
4928 | |
4878 | EV_FREQUENT_CHECK; |
4929 | EV_FREQUENT_CHECK; |
4879 | } |
4930 | } |
4880 | |
4931 | |
4881 | void |
4932 | void |
4882 | ev_async_stop (EV_P_ ev_async *w) EV_THROW |
4933 | ev_async_stop (EV_P_ ev_async *w) EV_NOEXCEPT |
4883 | { |
4934 | { |
4884 | clear_pending (EV_A_ (W)w); |
4935 | clear_pending (EV_A_ (W)w); |
4885 | if (expect_false (!ev_is_active (w))) |
4936 | if (expect_false (!ev_is_active (w))) |
4886 | return; |
4937 | return; |
4887 | |
4938 | |
… | |
… | |
4898 | |
4949 | |
4899 | EV_FREQUENT_CHECK; |
4950 | EV_FREQUENT_CHECK; |
4900 | } |
4951 | } |
4901 | |
4952 | |
4902 | void |
4953 | void |
4903 | ev_async_send (EV_P_ ev_async *w) EV_THROW |
4954 | ev_async_send (EV_P_ ev_async *w) EV_NOEXCEPT |
4904 | { |
4955 | { |
4905 | w->sent = 1; |
4956 | w->sent = 1; |
4906 | evpipe_write (EV_A_ &async_pending); |
4957 | evpipe_write (EV_A_ &async_pending); |
4907 | } |
4958 | } |
4908 | #endif |
4959 | #endif |
… | |
… | |
4945 | |
4996 | |
4946 | once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); |
4997 | once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); |
4947 | } |
4998 | } |
4948 | |
4999 | |
4949 | void |
5000 | void |
4950 | ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_THROW |
5001 | ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_NOEXCEPT |
4951 | { |
5002 | { |
4952 | struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); |
5003 | struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); |
4953 | |
5004 | |
4954 | if (expect_false (!once)) |
5005 | if (expect_false (!once)) |
4955 | { |
5006 | { |
… | |
… | |
4976 | } |
5027 | } |
4977 | |
5028 | |
4978 | /*****************************************************************************/ |
5029 | /*****************************************************************************/ |
4979 | |
5030 | |
4980 | #if EV_WALK_ENABLE |
5031 | #if EV_WALK_ENABLE |
4981 | void ecb_cold |
5032 | ecb_cold |
|
|
5033 | void |
4982 | ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_THROW |
5034 | ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_NOEXCEPT |
4983 | { |
5035 | { |
4984 | int i, j; |
5036 | int i, j; |
4985 | ev_watcher_list *wl, *wn; |
5037 | ev_watcher_list *wl, *wn; |
4986 | |
5038 | |
4987 | if (types & (EV_IO | EV_EMBED)) |
5039 | if (types & (EV_IO | EV_EMBED)) |