… | |
… | |
1536 | /* ECB.H END */ |
1536 | /* ECB.H END */ |
1537 | |
1537 | |
1538 | #if ECB_MEMORY_FENCE_NEEDS_PTHREADS |
1538 | #if ECB_MEMORY_FENCE_NEEDS_PTHREADS |
1539 | /* if your architecture doesn't need memory fences, e.g. because it is |
1539 | /* if your architecture doesn't need memory fences, e.g. because it is |
1540 | * single-cpu/core, or if you use libev in a project that doesn't use libev |
1540 | * single-cpu/core, or if you use libev in a project that doesn't use libev |
1541 | * from multiple threads, then you can define ECB_AVOID_PTHREADS when compiling |
1541 | * from multiple threads, then you can define ECB_NO_THREADS when compiling |
1542 | * libev, in which cases the memory fences become nops. |
1542 | * libev, in which cases the memory fences become nops. |
1543 | * alternatively, you can remove this #error and link against libpthread, |
1543 | * alternatively, you can remove this #error and link against libpthread, |
1544 | * which will then provide the memory fences. |
1544 | * which will then provide the memory fences. |
1545 | */ |
1545 | */ |
1546 | # error "memory fences not defined for your architecture, please report" |
1546 | # error "memory fences not defined for your architecture, please report" |
… | |
… | |
1550 | # define ECB_MEMORY_FENCE do { } while (0) |
1550 | # define ECB_MEMORY_FENCE do { } while (0) |
1551 | # define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE |
1551 | # define ECB_MEMORY_FENCE_ACQUIRE ECB_MEMORY_FENCE |
1552 | # define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE |
1552 | # define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE |
1553 | #endif |
1553 | #endif |
1554 | |
1554 | |
1555 | #define expect_false(cond) ecb_expect_false (cond) |
|
|
1556 | #define expect_true(cond) ecb_expect_true (cond) |
|
|
1557 | #define noinline ecb_noinline |
|
|
1558 | |
|
|
1559 | #define inline_size ecb_inline |
1555 | #define inline_size ecb_inline |
1560 | |
1556 | |
1561 | #if EV_FEATURE_CODE |
1557 | #if EV_FEATURE_CODE |
1562 | # define inline_speed ecb_inline |
1558 | # define inline_speed ecb_inline |
1563 | #else |
1559 | #else |
1564 | # define inline_speed noinline static |
1560 | # define inline_speed ecb_noinline static |
1565 | #endif |
1561 | #endif |
1566 | |
1562 | |
1567 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
1563 | #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) |
1568 | |
1564 | |
1569 | #if EV_MINPRI == EV_MAXPRI |
1565 | #if EV_MINPRI == EV_MAXPRI |
… | |
… | |
1619 | #else |
1615 | #else |
1620 | |
1616 | |
1621 | #include <float.h> |
1617 | #include <float.h> |
1622 | |
1618 | |
1623 | /* a floor() replacement function, should be independent of ev_tstamp type */ |
1619 | /* a floor() replacement function, should be independent of ev_tstamp type */ |
1624 | noinline |
1620 | ecb_noinline |
1625 | static ev_tstamp |
1621 | static ev_tstamp |
1626 | ev_floor (ev_tstamp v) |
1622 | ev_floor (ev_tstamp v) |
1627 | { |
1623 | { |
1628 | /* the choice of shift factor is not terribly important */ |
1624 | /* the choice of shift factor is not terribly important */ |
1629 | #if FLT_RADIX != 2 /* assume FLT_RADIX == 10 */ |
1625 | #if FLT_RADIX != 2 /* assume FLT_RADIX == 10 */ |
… | |
… | |
1631 | #else |
1627 | #else |
1632 | const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 18446744073709551616. : 4294967296.; |
1628 | const ev_tstamp shift = sizeof (unsigned long) >= 8 ? 18446744073709551616. : 4294967296.; |
1633 | #endif |
1629 | #endif |
1634 | |
1630 | |
1635 | /* argument too large for an unsigned long? */ |
1631 | /* argument too large for an unsigned long? */ |
1636 | if (expect_false (v >= shift)) |
1632 | if (ecb_expect_false (v >= shift)) |
1637 | { |
1633 | { |
1638 | ev_tstamp f; |
1634 | ev_tstamp f; |
1639 | |
1635 | |
1640 | if (v == v - 1.) |
1636 | if (v == v - 1.) |
1641 | return v; /* very large number */ |
1637 | return v; /* very large number */ |
… | |
… | |
1643 | f = shift * ev_floor (v * (1. / shift)); |
1639 | f = shift * ev_floor (v * (1. / shift)); |
1644 | return f + ev_floor (v - f); |
1640 | return f + ev_floor (v - f); |
1645 | } |
1641 | } |
1646 | |
1642 | |
1647 | /* special treatment for negative args? */ |
1643 | /* special treatment for negative args? */ |
1648 | if (expect_false (v < 0.)) |
1644 | if (ecb_expect_false (v < 0.)) |
1649 | { |
1645 | { |
1650 | ev_tstamp f = -ev_floor (-v); |
1646 | ev_tstamp f = -ev_floor (-v); |
1651 | |
1647 | |
1652 | return f - (f == v ? 0 : 1); |
1648 | return f - (f == v ? 0 : 1); |
1653 | } |
1649 | } |
… | |
… | |
1662 | |
1658 | |
1663 | #ifdef __linux |
1659 | #ifdef __linux |
1664 | # include <sys/utsname.h> |
1660 | # include <sys/utsname.h> |
1665 | #endif |
1661 | #endif |
1666 | |
1662 | |
1667 | noinline ecb_cold |
1663 | ecb_noinline ecb_cold |
1668 | static unsigned int |
1664 | static unsigned int |
1669 | ev_linux_version (void) |
1665 | ev_linux_version (void) |
1670 | { |
1666 | { |
1671 | #ifdef __linux |
1667 | #ifdef __linux |
1672 | unsigned int v = 0; |
1668 | unsigned int v = 0; |
… | |
… | |
1702 | } |
1698 | } |
1703 | |
1699 | |
1704 | /*****************************************************************************/ |
1700 | /*****************************************************************************/ |
1705 | |
1701 | |
1706 | #if EV_AVOID_STDIO |
1702 | #if EV_AVOID_STDIO |
1707 | noinline ecb_cold |
1703 | ecb_noinline ecb_cold |
1708 | static void |
1704 | static void |
1709 | ev_printerr (const char *msg) |
1705 | ev_printerr (const char *msg) |
1710 | { |
1706 | { |
1711 | write (STDERR_FILENO, msg, strlen (msg)); |
1707 | write (STDERR_FILENO, msg, strlen (msg)); |
1712 | } |
1708 | } |
… | |
… | |
1719 | ev_set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT |
1715 | ev_set_syserr_cb (void (*cb)(const char *msg) EV_NOEXCEPT) EV_NOEXCEPT |
1720 | { |
1716 | { |
1721 | syserr_cb = cb; |
1717 | syserr_cb = cb; |
1722 | } |
1718 | } |
1723 | |
1719 | |
1724 | noinline ecb_cold |
1720 | ecb_noinline ecb_cold |
1725 | static void |
1721 | static void |
1726 | ev_syserr (const char *msg) |
1722 | ev_syserr (const char *msg) |
1727 | { |
1723 | { |
1728 | if (!msg) |
1724 | if (!msg) |
1729 | msg = "(libev) system error"; |
1725 | msg = "(libev) system error"; |
… | |
… | |
1875 | static int ev_default_loop_ptr; |
1871 | static int ev_default_loop_ptr; |
1876 | |
1872 | |
1877 | #endif |
1873 | #endif |
1878 | |
1874 | |
1879 | #if EV_FEATURE_API |
1875 | #if EV_FEATURE_API |
1880 | # define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A) |
1876 | # define EV_RELEASE_CB if (ecb_expect_false (release_cb)) release_cb (EV_A) |
1881 | # define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A) |
1877 | # define EV_ACQUIRE_CB if (ecb_expect_false (acquire_cb)) acquire_cb (EV_A) |
1882 | # define EV_INVOKE_PENDING invoke_cb (EV_A) |
1878 | # define EV_INVOKE_PENDING invoke_cb (EV_A) |
1883 | #else |
1879 | #else |
1884 | # define EV_RELEASE_CB (void)0 |
1880 | # define EV_RELEASE_CB (void)0 |
1885 | # define EV_ACQUIRE_CB (void)0 |
1881 | # define EV_ACQUIRE_CB (void)0 |
1886 | # define EV_INVOKE_PENDING ev_invoke_pending (EV_A) |
1882 | # define EV_INVOKE_PENDING ev_invoke_pending (EV_A) |
… | |
… | |
1893 | #ifndef EV_HAVE_EV_TIME |
1889 | #ifndef EV_HAVE_EV_TIME |
1894 | ev_tstamp |
1890 | ev_tstamp |
1895 | ev_time (void) EV_NOEXCEPT |
1891 | ev_time (void) EV_NOEXCEPT |
1896 | { |
1892 | { |
1897 | #if EV_USE_REALTIME |
1893 | #if EV_USE_REALTIME |
1898 | if (expect_true (have_realtime)) |
1894 | if (ecb_expect_true (have_realtime)) |
1899 | { |
1895 | { |
1900 | struct timespec ts; |
1896 | struct timespec ts; |
1901 | clock_gettime (CLOCK_REALTIME, &ts); |
1897 | clock_gettime (CLOCK_REALTIME, &ts); |
1902 | return ts.tv_sec + ts.tv_nsec * 1e-9; |
1898 | return ts.tv_sec + ts.tv_nsec * 1e-9; |
1903 | } |
1899 | } |
… | |
… | |
1911 | |
1907 | |
1912 | inline_size ev_tstamp |
1908 | inline_size ev_tstamp |
1913 | get_clock (void) |
1909 | get_clock (void) |
1914 | { |
1910 | { |
1915 | #if EV_USE_MONOTONIC |
1911 | #if EV_USE_MONOTONIC |
1916 | if (expect_true (have_monotonic)) |
1912 | if (ecb_expect_true (have_monotonic)) |
1917 | { |
1913 | { |
1918 | struct timespec ts; |
1914 | struct timespec ts; |
1919 | clock_gettime (CLOCK_MONOTONIC, &ts); |
1915 | clock_gettime (CLOCK_MONOTONIC, &ts); |
1920 | return ts.tv_sec + ts.tv_nsec * 1e-9; |
1916 | return ts.tv_sec + ts.tv_nsec * 1e-9; |
1921 | } |
1917 | } |
… | |
… | |
1983 | } |
1979 | } |
1984 | |
1980 | |
1985 | return ncur; |
1981 | return ncur; |
1986 | } |
1982 | } |
1987 | |
1983 | |
1988 | noinline ecb_cold |
1984 | ecb_noinline ecb_cold |
1989 | static void * |
1985 | static void * |
1990 | array_realloc (int elem, void *base, int *cur, int cnt) |
1986 | array_realloc (int elem, void *base, int *cur, int cnt) |
1991 | { |
1987 | { |
1992 | *cur = array_nextsize (elem, *cur, cnt); |
1988 | *cur = array_nextsize (elem, *cur, cnt); |
1993 | return ev_realloc (base, elem * *cur); |
1989 | return ev_realloc (base, elem * *cur); |
… | |
… | |
1997 | |
1993 | |
1998 | #define array_needsize_zerofill(base,offset,count) \ |
1994 | #define array_needsize_zerofill(base,offset,count) \ |
1999 | memset ((void *)(base + offset), 0, sizeof (*(base)) * (count)) |
1995 | memset ((void *)(base + offset), 0, sizeof (*(base)) * (count)) |
2000 | |
1996 | |
2001 | #define array_needsize(type,base,cur,cnt,init) \ |
1997 | #define array_needsize(type,base,cur,cnt,init) \ |
2002 | if (expect_false ((cnt) > (cur))) \ |
1998 | if (ecb_expect_false ((cnt) > (cur))) \ |
2003 | { \ |
1999 | { \ |
2004 | ecb_unused int ocur_ = (cur); \ |
2000 | ecb_unused int ocur_ = (cur); \ |
2005 | (base) = (type *)array_realloc \ |
2001 | (base) = (type *)array_realloc \ |
2006 | (sizeof (type), (base), &(cur), (cnt)); \ |
2002 | (sizeof (type), (base), &(cur), (cnt)); \ |
2007 | init ((base), ocur_, ((cur) - ocur_)); \ |
2003 | init ((base), ocur_, ((cur) - ocur_)); \ |
… | |
… | |
2021 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 |
2017 | ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; stem ## s idx = 0 |
2022 | |
2018 | |
2023 | /*****************************************************************************/ |
2019 | /*****************************************************************************/ |
2024 | |
2020 | |
2025 | /* dummy callback for pending events */ |
2021 | /* dummy callback for pending events */ |
2026 | noinline |
2022 | ecb_noinline |
2027 | static void |
2023 | static void |
2028 | pendingcb (EV_P_ ev_prepare *w, int revents) |
2024 | pendingcb (EV_P_ ev_prepare *w, int revents) |
2029 | { |
2025 | { |
2030 | } |
2026 | } |
2031 | |
2027 | |
2032 | noinline |
2028 | ecb_noinline |
2033 | void |
2029 | void |
2034 | ev_feed_event (EV_P_ void *w, int revents) EV_NOEXCEPT |
2030 | ev_feed_event (EV_P_ void *w, int revents) EV_NOEXCEPT |
2035 | { |
2031 | { |
2036 | W w_ = (W)w; |
2032 | W w_ = (W)w; |
2037 | int pri = ABSPRI (w_); |
2033 | int pri = ABSPRI (w_); |
2038 | |
2034 | |
2039 | if (expect_false (w_->pending)) |
2035 | if (ecb_expect_false (w_->pending)) |
2040 | pendings [pri][w_->pending - 1].events |= revents; |
2036 | pendings [pri][w_->pending - 1].events |= revents; |
2041 | else |
2037 | else |
2042 | { |
2038 | { |
2043 | w_->pending = ++pendingcnt [pri]; |
2039 | w_->pending = ++pendingcnt [pri]; |
2044 | array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, array_needsize_noinit); |
2040 | array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, array_needsize_noinit); |
… | |
… | |
2095 | inline_speed void |
2091 | inline_speed void |
2096 | fd_event (EV_P_ int fd, int revents) |
2092 | fd_event (EV_P_ int fd, int revents) |
2097 | { |
2093 | { |
2098 | ANFD *anfd = anfds + fd; |
2094 | ANFD *anfd = anfds + fd; |
2099 | |
2095 | |
2100 | if (expect_true (!anfd->reify)) |
2096 | if (ecb_expect_true (!anfd->reify)) |
2101 | fd_event_nocheck (EV_A_ fd, revents); |
2097 | fd_event_nocheck (EV_A_ fd, revents); |
2102 | } |
2098 | } |
2103 | |
2099 | |
2104 | void |
2100 | void |
2105 | ev_feed_fd_event (EV_P_ int fd, int revents) EV_NOEXCEPT |
2101 | ev_feed_fd_event (EV_P_ int fd, int revents) EV_NOEXCEPT |
… | |
… | |
2149 | unsigned char o_events = anfd->events; |
2145 | unsigned char o_events = anfd->events; |
2150 | unsigned char o_reify = anfd->reify; |
2146 | unsigned char o_reify = anfd->reify; |
2151 | |
2147 | |
2152 | anfd->reify = 0; |
2148 | anfd->reify = 0; |
2153 | |
2149 | |
2154 | /*if (expect_true (o_reify & EV_ANFD_REIFY)) probably a deoptimisation */ |
2150 | /*if (ecb_expect_true (o_reify & EV_ANFD_REIFY)) probably a deoptimisation */ |
2155 | { |
2151 | { |
2156 | anfd->events = 0; |
2152 | anfd->events = 0; |
2157 | |
2153 | |
2158 | for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) |
2154 | for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) |
2159 | anfd->events |= (unsigned char)w->events; |
2155 | anfd->events |= (unsigned char)w->events; |
… | |
… | |
2175 | fd_change (EV_P_ int fd, int flags) |
2171 | fd_change (EV_P_ int fd, int flags) |
2176 | { |
2172 | { |
2177 | unsigned char reify = anfds [fd].reify; |
2173 | unsigned char reify = anfds [fd].reify; |
2178 | anfds [fd].reify |= flags; |
2174 | anfds [fd].reify |= flags; |
2179 | |
2175 | |
2180 | if (expect_true (!reify)) |
2176 | if (ecb_expect_true (!reify)) |
2181 | { |
2177 | { |
2182 | ++fdchangecnt; |
2178 | ++fdchangecnt; |
2183 | array_needsize (int, fdchanges, fdchangemax, fdchangecnt, array_needsize_noinit); |
2179 | array_needsize (int, fdchanges, fdchangemax, fdchangecnt, array_needsize_noinit); |
2184 | fdchanges [fdchangecnt - 1] = fd; |
2180 | fdchanges [fdchangecnt - 1] = fd; |
2185 | } |
2181 | } |
… | |
… | |
2208 | return fcntl (fd, F_GETFD) != -1; |
2204 | return fcntl (fd, F_GETFD) != -1; |
2209 | #endif |
2205 | #endif |
2210 | } |
2206 | } |
2211 | |
2207 | |
2212 | /* called on EBADF to verify fds */ |
2208 | /* called on EBADF to verify fds */ |
2213 | noinline ecb_cold |
2209 | ecb_noinline ecb_cold |
2214 | static void |
2210 | static void |
2215 | fd_ebadf (EV_P) |
2211 | fd_ebadf (EV_P) |
2216 | { |
2212 | { |
2217 | int fd; |
2213 | int fd; |
2218 | |
2214 | |
… | |
… | |
2221 | if (!fd_valid (fd) && errno == EBADF) |
2217 | if (!fd_valid (fd) && errno == EBADF) |
2222 | fd_kill (EV_A_ fd); |
2218 | fd_kill (EV_A_ fd); |
2223 | } |
2219 | } |
2224 | |
2220 | |
2225 | /* called on ENOMEM in select/poll to kill some fds and retry */ |
2221 | /* called on ENOMEM in select/poll to kill some fds and retry */ |
2226 | noinline ecb_cold |
2222 | ecb_noinline ecb_cold |
2227 | static void |
2223 | static void |
2228 | fd_enomem (EV_P) |
2224 | fd_enomem (EV_P) |
2229 | { |
2225 | { |
2230 | int fd; |
2226 | int fd; |
2231 | |
2227 | |
… | |
… | |
2236 | break; |
2232 | break; |
2237 | } |
2233 | } |
2238 | } |
2234 | } |
2239 | |
2235 | |
2240 | /* usually called after fork if backend needs to re-arm all fds from scratch */ |
2236 | /* usually called after fork if backend needs to re-arm all fds from scratch */ |
2241 | noinline |
2237 | ecb_noinline |
2242 | static void |
2238 | static void |
2243 | fd_rearm_all (EV_P) |
2239 | fd_rearm_all (EV_P) |
2244 | { |
2240 | { |
2245 | int fd; |
2241 | int fd; |
2246 | |
2242 | |
… | |
… | |
2300 | ev_tstamp minat; |
2296 | ev_tstamp minat; |
2301 | ANHE *minpos; |
2297 | ANHE *minpos; |
2302 | ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0 + 1; |
2298 | ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0 + 1; |
2303 | |
2299 | |
2304 | /* find minimum child */ |
2300 | /* find minimum child */ |
2305 | if (expect_true (pos + DHEAP - 1 < E)) |
2301 | if (ecb_expect_true (pos + DHEAP - 1 < E)) |
2306 | { |
2302 | { |
2307 | /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); |
2303 | /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); |
2308 | if ( ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); |
2304 | if ( ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); |
2309 | if ( ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); |
2305 | if ( ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); |
2310 | if ( ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); |
2306 | if ( ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); |
… | |
… | |
2428 | |
2424 | |
2429 | /*****************************************************************************/ |
2425 | /*****************************************************************************/ |
2430 | |
2426 | |
2431 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
2427 | #if EV_SIGNAL_ENABLE || EV_ASYNC_ENABLE |
2432 | |
2428 | |
2433 | noinline ecb_cold |
2429 | ecb_noinline ecb_cold |
2434 | static void |
2430 | static void |
2435 | evpipe_init (EV_P) |
2431 | evpipe_init (EV_P) |
2436 | { |
2432 | { |
2437 | if (!ev_is_active (&pipe_w)) |
2433 | if (!ev_is_active (&pipe_w)) |
2438 | { |
2434 | { |
… | |
… | |
2479 | inline_speed void |
2475 | inline_speed void |
2480 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
2476 | evpipe_write (EV_P_ EV_ATOMIC_T *flag) |
2481 | { |
2477 | { |
2482 | ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */ |
2478 | ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */ |
2483 | |
2479 | |
2484 | if (expect_true (*flag)) |
2480 | if (ecb_expect_true (*flag)) |
2485 | return; |
2481 | return; |
2486 | |
2482 | |
2487 | *flag = 1; |
2483 | *flag = 1; |
2488 | ECB_MEMORY_FENCE_RELEASE; /* make sure flag is visible before the wakeup */ |
2484 | ECB_MEMORY_FENCE_RELEASE; /* make sure flag is visible before the wakeup */ |
2489 | |
2485 | |
… | |
… | |
2566 | sig_pending = 0; |
2562 | sig_pending = 0; |
2567 | |
2563 | |
2568 | ECB_MEMORY_FENCE; |
2564 | ECB_MEMORY_FENCE; |
2569 | |
2565 | |
2570 | for (i = EV_NSIG - 1; i--; ) |
2566 | for (i = EV_NSIG - 1; i--; ) |
2571 | if (expect_false (signals [i].pending)) |
2567 | if (ecb_expect_false (signals [i].pending)) |
2572 | ev_feed_signal_event (EV_A_ i + 1); |
2568 | ev_feed_signal_event (EV_A_ i + 1); |
2573 | } |
2569 | } |
2574 | #endif |
2570 | #endif |
2575 | |
2571 | |
2576 | #if EV_ASYNC_ENABLE |
2572 | #if EV_ASYNC_ENABLE |
… | |
… | |
2617 | #endif |
2613 | #endif |
2618 | |
2614 | |
2619 | ev_feed_signal (signum); |
2615 | ev_feed_signal (signum); |
2620 | } |
2616 | } |
2621 | |
2617 | |
2622 | noinline |
2618 | ecb_noinline |
2623 | void |
2619 | void |
2624 | ev_feed_signal_event (EV_P_ int signum) EV_NOEXCEPT |
2620 | ev_feed_signal_event (EV_P_ int signum) EV_NOEXCEPT |
2625 | { |
2621 | { |
2626 | WL w; |
2622 | WL w; |
2627 | |
2623 | |
2628 | if (expect_false (signum <= 0 || signum >= EV_NSIG)) |
2624 | if (ecb_expect_false (signum <= 0 || signum >= EV_NSIG)) |
2629 | return; |
2625 | return; |
2630 | |
2626 | |
2631 | --signum; |
2627 | --signum; |
2632 | |
2628 | |
2633 | #if EV_MULTIPLICITY |
2629 | #if EV_MULTIPLICITY |
2634 | /* it is permissible to try to feed a signal to the wrong loop */ |
2630 | /* it is permissible to try to feed a signal to the wrong loop */ |
2635 | /* or, likely more useful, feeding a signal nobody is waiting for */ |
2631 | /* or, likely more useful, feeding a signal nobody is waiting for */ |
2636 | |
2632 | |
2637 | if (expect_false (signals [signum].loop != EV_A)) |
2633 | if (ecb_expect_false (signals [signum].loop != EV_A)) |
2638 | return; |
2634 | return; |
2639 | #endif |
2635 | #endif |
2640 | |
2636 | |
2641 | signals [signum].pending = 0; |
2637 | signals [signum].pending = 0; |
2642 | ECB_MEMORY_FENCE_RELEASE; |
2638 | ECB_MEMORY_FENCE_RELEASE; |
… | |
… | |
2887 | acquire_cb = acquire; |
2883 | acquire_cb = acquire; |
2888 | } |
2884 | } |
2889 | #endif |
2885 | #endif |
2890 | |
2886 | |
2891 | /* initialise a loop structure, must be zero-initialised */ |
2887 | /* initialise a loop structure, must be zero-initialised */ |
2892 | noinline ecb_cold |
2888 | ecb_noinline ecb_cold |
2893 | static void |
2889 | static void |
2894 | loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT |
2890 | loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT |
2895 | { |
2891 | { |
2896 | if (!backend) |
2892 | if (!backend) |
2897 | { |
2893 | { |
… | |
… | |
3002 | return; |
2998 | return; |
3003 | #endif |
2999 | #endif |
3004 | |
3000 | |
3005 | #if EV_CLEANUP_ENABLE |
3001 | #if EV_CLEANUP_ENABLE |
3006 | /* queue cleanup watchers (and execute them) */ |
3002 | /* queue cleanup watchers (and execute them) */ |
3007 | if (expect_false (cleanupcnt)) |
3003 | if (ecb_expect_false (cleanupcnt)) |
3008 | { |
3004 | { |
3009 | queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); |
3005 | queue_events (EV_A_ (W *)cleanups, cleanupcnt, EV_CLEANUP); |
3010 | EV_INVOKE_PENDING; |
3006 | EV_INVOKE_PENDING; |
3011 | } |
3007 | } |
3012 | #endif |
3008 | #endif |
… | |
… | |
3166 | } |
3162 | } |
3167 | |
3163 | |
3168 | #endif /* multiplicity */ |
3164 | #endif /* multiplicity */ |
3169 | |
3165 | |
3170 | #if EV_VERIFY |
3166 | #if EV_VERIFY |
3171 | noinline ecb_cold |
3167 | ecb_noinline ecb_cold |
3172 | static void |
3168 | static void |
3173 | verify_watcher (EV_P_ W w) |
3169 | verify_watcher (EV_P_ W w) |
3174 | { |
3170 | { |
3175 | assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); |
3171 | assert (("libev: watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); |
3176 | |
3172 | |
3177 | if (w->pending) |
3173 | if (w->pending) |
3178 | assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w)); |
3174 | assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w == w)); |
3179 | } |
3175 | } |
3180 | |
3176 | |
3181 | noinline ecb_cold |
3177 | ecb_noinline ecb_cold |
3182 | static void |
3178 | static void |
3183 | verify_heap (EV_P_ ANHE *heap, int N) |
3179 | verify_heap (EV_P_ ANHE *heap, int N) |
3184 | { |
3180 | { |
3185 | int i; |
3181 | int i; |
3186 | |
3182 | |
… | |
… | |
3192 | |
3188 | |
3193 | verify_watcher (EV_A_ (W)ANHE_w (heap [i])); |
3189 | verify_watcher (EV_A_ (W)ANHE_w (heap [i])); |
3194 | } |
3190 | } |
3195 | } |
3191 | } |
3196 | |
3192 | |
3197 | noinline ecb_cold |
3193 | ecb_noinline ecb_cold |
3198 | static void |
3194 | static void |
3199 | array_verify (EV_P_ W *ws, int cnt) |
3195 | array_verify (EV_P_ W *ws, int cnt) |
3200 | { |
3196 | { |
3201 | while (cnt--) |
3197 | while (cnt--) |
3202 | { |
3198 | { |
… | |
… | |
3351 | count += pendingcnt [pri]; |
3347 | count += pendingcnt [pri]; |
3352 | |
3348 | |
3353 | return count; |
3349 | return count; |
3354 | } |
3350 | } |
3355 | |
3351 | |
3356 | noinline |
3352 | ecb_noinline |
3357 | void |
3353 | void |
3358 | ev_invoke_pending (EV_P) |
3354 | ev_invoke_pending (EV_P) |
3359 | { |
3355 | { |
3360 | pendingpri = NUMPRI; |
3356 | pendingpri = NUMPRI; |
3361 | |
3357 | |
… | |
… | |
3380 | /* make idle watchers pending. this handles the "call-idle */ |
3376 | /* make idle watchers pending. this handles the "call-idle */ |
3381 | /* only when higher priorities are idle" logic */ |
3377 | /* only when higher priorities are idle" logic */ |
3382 | inline_size void |
3378 | inline_size void |
3383 | idle_reify (EV_P) |
3379 | idle_reify (EV_P) |
3384 | { |
3380 | { |
3385 | if (expect_false (idleall)) |
3381 | if (ecb_expect_false (idleall)) |
3386 | { |
3382 | { |
3387 | int pri; |
3383 | int pri; |
3388 | |
3384 | |
3389 | for (pri = NUMPRI; pri--; ) |
3385 | for (pri = NUMPRI; pri--; ) |
3390 | { |
3386 | { |
… | |
… | |
3439 | } |
3435 | } |
3440 | } |
3436 | } |
3441 | |
3437 | |
3442 | #if EV_PERIODIC_ENABLE |
3438 | #if EV_PERIODIC_ENABLE |
3443 | |
3439 | |
3444 | noinline |
3440 | ecb_noinline |
3445 | static void |
3441 | static void |
3446 | periodic_recalc (EV_P_ ev_periodic *w) |
3442 | periodic_recalc (EV_P_ ev_periodic *w) |
3447 | { |
3443 | { |
3448 | ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; |
3444 | ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; |
3449 | ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); |
3445 | ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); |
… | |
… | |
3452 | while (at <= ev_rt_now) |
3448 | while (at <= ev_rt_now) |
3453 | { |
3449 | { |
3454 | ev_tstamp nat = at + w->interval; |
3450 | ev_tstamp nat = at + w->interval; |
3455 | |
3451 | |
3456 | /* when resolution fails us, we use ev_rt_now */ |
3452 | /* when resolution fails us, we use ev_rt_now */ |
3457 | if (expect_false (nat == at)) |
3453 | if (ecb_expect_false (nat == at)) |
3458 | { |
3454 | { |
3459 | at = ev_rt_now; |
3455 | at = ev_rt_now; |
3460 | break; |
3456 | break; |
3461 | } |
3457 | } |
3462 | |
3458 | |
… | |
… | |
3508 | } |
3504 | } |
3509 | } |
3505 | } |
3510 | |
3506 | |
3511 | /* simply recalculate all periodics */ |
3507 | /* simply recalculate all periodics */ |
3512 | /* TODO: maybe ensure that at least one event happens when jumping forward? */ |
3508 | /* TODO: maybe ensure that at least one event happens when jumping forward? */ |
3513 | noinline ecb_cold |
3509 | ecb_noinline ecb_cold |
3514 | static void |
3510 | static void |
3515 | periodics_reschedule (EV_P) |
3511 | periodics_reschedule (EV_P) |
3516 | { |
3512 | { |
3517 | int i; |
3513 | int i; |
3518 | |
3514 | |
… | |
… | |
3532 | reheap (periodics, periodiccnt); |
3528 | reheap (periodics, periodiccnt); |
3533 | } |
3529 | } |
3534 | #endif |
3530 | #endif |
3535 | |
3531 | |
3536 | /* adjust all timers by a given offset */ |
3532 | /* adjust all timers by a given offset */ |
3537 | noinline ecb_cold |
3533 | ecb_noinline ecb_cold |
3538 | static void |
3534 | static void |
3539 | timers_reschedule (EV_P_ ev_tstamp adjust) |
3535 | timers_reschedule (EV_P_ ev_tstamp adjust) |
3540 | { |
3536 | { |
3541 | int i; |
3537 | int i; |
3542 | |
3538 | |
… | |
… | |
3552 | /* also detect if there was a timejump, and act accordingly */ |
3548 | /* also detect if there was a timejump, and act accordingly */ |
3553 | inline_speed void |
3549 | inline_speed void |
3554 | time_update (EV_P_ ev_tstamp max_block) |
3550 | time_update (EV_P_ ev_tstamp max_block) |
3555 | { |
3551 | { |
3556 | #if EV_USE_MONOTONIC |
3552 | #if EV_USE_MONOTONIC |
3557 | if (expect_true (have_monotonic)) |
3553 | if (ecb_expect_true (have_monotonic)) |
3558 | { |
3554 | { |
3559 | int i; |
3555 | int i; |
3560 | ev_tstamp odiff = rtmn_diff; |
3556 | ev_tstamp odiff = rtmn_diff; |
3561 | |
3557 | |
3562 | mn_now = get_clock (); |
3558 | mn_now = get_clock (); |
3563 | |
3559 | |
3564 | /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */ |
3560 | /* only fetch the realtime clock every 0.5*MIN_TIMEJUMP seconds */ |
3565 | /* interpolate in the meantime */ |
3561 | /* interpolate in the meantime */ |
3566 | if (expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5)) |
3562 | if (ecb_expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5)) |
3567 | { |
3563 | { |
3568 | ev_rt_now = rtmn_diff + mn_now; |
3564 | ev_rt_now = rtmn_diff + mn_now; |
3569 | return; |
3565 | return; |
3570 | } |
3566 | } |
3571 | |
3567 | |
… | |
… | |
3585 | ev_tstamp diff; |
3581 | ev_tstamp diff; |
3586 | rtmn_diff = ev_rt_now - mn_now; |
3582 | rtmn_diff = ev_rt_now - mn_now; |
3587 | |
3583 | |
3588 | diff = odiff - rtmn_diff; |
3584 | diff = odiff - rtmn_diff; |
3589 | |
3585 | |
3590 | if (expect_true ((diff < 0. ? -diff : diff) < MIN_TIMEJUMP)) |
3586 | if (ecb_expect_true ((diff < 0. ? -diff : diff) < MIN_TIMEJUMP)) |
3591 | return; /* all is well */ |
3587 | return; /* all is well */ |
3592 | |
3588 | |
3593 | ev_rt_now = ev_time (); |
3589 | ev_rt_now = ev_time (); |
3594 | mn_now = get_clock (); |
3590 | mn_now = get_clock (); |
3595 | now_floor = mn_now; |
3591 | now_floor = mn_now; |
… | |
… | |
3604 | else |
3600 | else |
3605 | #endif |
3601 | #endif |
3606 | { |
3602 | { |
3607 | ev_rt_now = ev_time (); |
3603 | ev_rt_now = ev_time (); |
3608 | |
3604 | |
3609 | if (expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP)) |
3605 | if (ecb_expect_false (mn_now > ev_rt_now || ev_rt_now > mn_now + max_block + MIN_TIMEJUMP)) |
3610 | { |
3606 | { |
3611 | /* adjust timers. this is easy, as the offset is the same for all of them */ |
3607 | /* adjust timers. this is easy, as the offset is the same for all of them */ |
3612 | timers_reschedule (EV_A_ ev_rt_now - mn_now); |
3608 | timers_reschedule (EV_A_ ev_rt_now - mn_now); |
3613 | #if EV_PERIODIC_ENABLE |
3609 | #if EV_PERIODIC_ENABLE |
3614 | periodics_reschedule (EV_A); |
3610 | periodics_reschedule (EV_A); |
… | |
… | |
3637 | #if EV_VERIFY >= 2 |
3633 | #if EV_VERIFY >= 2 |
3638 | ev_verify (EV_A); |
3634 | ev_verify (EV_A); |
3639 | #endif |
3635 | #endif |
3640 | |
3636 | |
3641 | #ifndef _WIN32 |
3637 | #ifndef _WIN32 |
3642 | if (expect_false (curpid)) /* penalise the forking check even more */ |
3638 | if (ecb_expect_false (curpid)) /* penalise the forking check even more */ |
3643 | if (expect_false (getpid () != curpid)) |
3639 | if (ecb_expect_false (getpid () != curpid)) |
3644 | { |
3640 | { |
3645 | curpid = getpid (); |
3641 | curpid = getpid (); |
3646 | postfork = 1; |
3642 | postfork = 1; |
3647 | } |
3643 | } |
3648 | #endif |
3644 | #endif |
3649 | |
3645 | |
3650 | #if EV_FORK_ENABLE |
3646 | #if EV_FORK_ENABLE |
3651 | /* we might have forked, so queue fork handlers */ |
3647 | /* we might have forked, so queue fork handlers */ |
3652 | if (expect_false (postfork)) |
3648 | if (ecb_expect_false (postfork)) |
3653 | if (forkcnt) |
3649 | if (forkcnt) |
3654 | { |
3650 | { |
3655 | queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); |
3651 | queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); |
3656 | EV_INVOKE_PENDING; |
3652 | EV_INVOKE_PENDING; |
3657 | } |
3653 | } |
3658 | #endif |
3654 | #endif |
3659 | |
3655 | |
3660 | #if EV_PREPARE_ENABLE |
3656 | #if EV_PREPARE_ENABLE |
3661 | /* queue prepare watchers (and execute them) */ |
3657 | /* queue prepare watchers (and execute them) */ |
3662 | if (expect_false (preparecnt)) |
3658 | if (ecb_expect_false (preparecnt)) |
3663 | { |
3659 | { |
3664 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
3660 | queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); |
3665 | EV_INVOKE_PENDING; |
3661 | EV_INVOKE_PENDING; |
3666 | } |
3662 | } |
3667 | #endif |
3663 | #endif |
3668 | |
3664 | |
3669 | if (expect_false (loop_done)) |
3665 | if (ecb_expect_false (loop_done)) |
3670 | break; |
3666 | break; |
3671 | |
3667 | |
3672 | /* we might have forked, so reify kernel state if necessary */ |
3668 | /* we might have forked, so reify kernel state if necessary */ |
3673 | if (expect_false (postfork)) |
3669 | if (ecb_expect_false (postfork)) |
3674 | loop_fork (EV_A); |
3670 | loop_fork (EV_A); |
3675 | |
3671 | |
3676 | /* update fd-related kernel structures */ |
3672 | /* update fd-related kernel structures */ |
3677 | fd_reify (EV_A); |
3673 | fd_reify (EV_A); |
3678 | |
3674 | |
… | |
… | |
3690 | /* from now on, we want a pipe-wake-up */ |
3686 | /* from now on, we want a pipe-wake-up */ |
3691 | pipe_write_wanted = 1; |
3687 | pipe_write_wanted = 1; |
3692 | |
3688 | |
3693 | ECB_MEMORY_FENCE; /* make sure pipe_write_wanted is visible before we check for potential skips */ |
3689 | ECB_MEMORY_FENCE; /* make sure pipe_write_wanted is visible before we check for potential skips */ |
3694 | |
3690 | |
3695 | if (expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped))) |
3691 | if (ecb_expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped))) |
3696 | { |
3692 | { |
3697 | waittime = MAX_BLOCKTIME; |
3693 | waittime = MAX_BLOCKTIME; |
3698 | |
3694 | |
3699 | if (timercnt) |
3695 | if (timercnt) |
3700 | { |
3696 | { |
… | |
… | |
3709 | if (waittime > to) waittime = to; |
3705 | if (waittime > to) waittime = to; |
3710 | } |
3706 | } |
3711 | #endif |
3707 | #endif |
3712 | |
3708 | |
3713 | /* don't let timeouts decrease the waittime below timeout_blocktime */ |
3709 | /* don't let timeouts decrease the waittime below timeout_blocktime */ |
3714 | if (expect_false (waittime < timeout_blocktime)) |
3710 | if (ecb_expect_false (waittime < timeout_blocktime)) |
3715 | waittime = timeout_blocktime; |
3711 | waittime = timeout_blocktime; |
3716 | |
3712 | |
3717 | /* at this point, we NEED to wait, so we have to ensure */ |
3713 | /* at this point, we NEED to wait, so we have to ensure */ |
3718 | /* to pass a minimum nonzero value to the backend */ |
3714 | /* to pass a minimum nonzero value to the backend */ |
3719 | if (expect_false (waittime < backend_mintime)) |
3715 | if (ecb_expect_false (waittime < backend_mintime)) |
3720 | waittime = backend_mintime; |
3716 | waittime = backend_mintime; |
3721 | |
3717 | |
3722 | /* extra check because io_blocktime is commonly 0 */ |
3718 | /* extra check because io_blocktime is commonly 0 */ |
3723 | if (expect_false (io_blocktime)) |
3719 | if (ecb_expect_false (io_blocktime)) |
3724 | { |
3720 | { |
3725 | sleeptime = io_blocktime - (mn_now - prev_mn_now); |
3721 | sleeptime = io_blocktime - (mn_now - prev_mn_now); |
3726 | |
3722 | |
3727 | if (sleeptime > waittime - backend_mintime) |
3723 | if (sleeptime > waittime - backend_mintime) |
3728 | sleeptime = waittime - backend_mintime; |
3724 | sleeptime = waittime - backend_mintime; |
3729 | |
3725 | |
3730 | if (expect_true (sleeptime > 0.)) |
3726 | if (ecb_expect_true (sleeptime > 0.)) |
3731 | { |
3727 | { |
3732 | ev_sleep (sleeptime); |
3728 | ev_sleep (sleeptime); |
3733 | waittime -= sleeptime; |
3729 | waittime -= sleeptime; |
3734 | } |
3730 | } |
3735 | } |
3731 | } |
… | |
… | |
3766 | idle_reify (EV_A); |
3762 | idle_reify (EV_A); |
3767 | #endif |
3763 | #endif |
3768 | |
3764 | |
3769 | #if EV_CHECK_ENABLE |
3765 | #if EV_CHECK_ENABLE |
3770 | /* queue check watchers, to be executed first */ |
3766 | /* queue check watchers, to be executed first */ |
3771 | if (expect_false (checkcnt)) |
3767 | if (ecb_expect_false (checkcnt)) |
3772 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
3768 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
3773 | #endif |
3769 | #endif |
3774 | |
3770 | |
3775 | EV_INVOKE_PENDING; |
3771 | EV_INVOKE_PENDING; |
3776 | } |
3772 | } |
3777 | while (expect_true ( |
3773 | while (ecb_expect_true ( |
3778 | activecnt |
3774 | activecnt |
3779 | && !loop_done |
3775 | && !loop_done |
3780 | && !(flags & (EVRUN_ONCE | EVRUN_NOWAIT)) |
3776 | && !(flags & (EVRUN_ONCE | EVRUN_NOWAIT)) |
3781 | )); |
3777 | )); |
3782 | |
3778 | |
… | |
… | |
3846 | inline_size void |
3842 | inline_size void |
3847 | wlist_del (WL *head, WL elem) |
3843 | wlist_del (WL *head, WL elem) |
3848 | { |
3844 | { |
3849 | while (*head) |
3845 | while (*head) |
3850 | { |
3846 | { |
3851 | if (expect_true (*head == elem)) |
3847 | if (ecb_expect_true (*head == elem)) |
3852 | { |
3848 | { |
3853 | *head = elem->next; |
3849 | *head = elem->next; |
3854 | break; |
3850 | break; |
3855 | } |
3851 | } |
3856 | |
3852 | |
… | |
… | |
3873 | ev_clear_pending (EV_P_ void *w) EV_NOEXCEPT |
3869 | ev_clear_pending (EV_P_ void *w) EV_NOEXCEPT |
3874 | { |
3870 | { |
3875 | W w_ = (W)w; |
3871 | W w_ = (W)w; |
3876 | int pending = w_->pending; |
3872 | int pending = w_->pending; |
3877 | |
3873 | |
3878 | if (expect_true (pending)) |
3874 | if (ecb_expect_true (pending)) |
3879 | { |
3875 | { |
3880 | ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; |
3876 | ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; |
3881 | p->w = (W)&pending_w; |
3877 | p->w = (W)&pending_w; |
3882 | w_->pending = 0; |
3878 | w_->pending = 0; |
3883 | return p->events; |
3879 | return p->events; |
… | |
… | |
3910 | w->active = 0; |
3906 | w->active = 0; |
3911 | } |
3907 | } |
3912 | |
3908 | |
3913 | /*****************************************************************************/ |
3909 | /*****************************************************************************/ |
3914 | |
3910 | |
3915 | noinline |
3911 | ecb_noinline |
3916 | void |
3912 | void |
3917 | ev_io_start (EV_P_ ev_io *w) EV_NOEXCEPT |
3913 | ev_io_start (EV_P_ ev_io *w) EV_NOEXCEPT |
3918 | { |
3914 | { |
3919 | int fd = w->fd; |
3915 | int fd = w->fd; |
3920 | |
3916 | |
3921 | if (expect_false (ev_is_active (w))) |
3917 | if (ecb_expect_false (ev_is_active (w))) |
3922 | return; |
3918 | return; |
3923 | |
3919 | |
3924 | assert (("libev: ev_io_start called with negative fd", fd >= 0)); |
3920 | assert (("libev: ev_io_start called with negative fd", fd >= 0)); |
3925 | assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE)))); |
3921 | assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_READ | EV_WRITE)))); |
3926 | |
3922 | |
… | |
… | |
3940 | w->events &= ~EV__IOFDSET; |
3936 | w->events &= ~EV__IOFDSET; |
3941 | |
3937 | |
3942 | EV_FREQUENT_CHECK; |
3938 | EV_FREQUENT_CHECK; |
3943 | } |
3939 | } |
3944 | |
3940 | |
3945 | noinline |
3941 | ecb_noinline |
3946 | void |
3942 | void |
3947 | ev_io_stop (EV_P_ ev_io *w) EV_NOEXCEPT |
3943 | ev_io_stop (EV_P_ ev_io *w) EV_NOEXCEPT |
3948 | { |
3944 | { |
3949 | clear_pending (EV_A_ (W)w); |
3945 | clear_pending (EV_A_ (W)w); |
3950 | if (expect_false (!ev_is_active (w))) |
3946 | if (ecb_expect_false (!ev_is_active (w))) |
3951 | return; |
3947 | return; |
3952 | |
3948 | |
3953 | assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); |
3949 | assert (("libev: ev_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)); |
3954 | |
3950 | |
3955 | #if EV_VERIFY >= 2 |
3951 | #if EV_VERIFY >= 2 |
… | |
… | |
3963 | fd_change (EV_A_ w->fd, EV_ANFD_REIFY); |
3959 | fd_change (EV_A_ w->fd, EV_ANFD_REIFY); |
3964 | |
3960 | |
3965 | EV_FREQUENT_CHECK; |
3961 | EV_FREQUENT_CHECK; |
3966 | } |
3962 | } |
3967 | |
3963 | |
3968 | noinline |
3964 | ecb_noinline |
3969 | void |
3965 | void |
3970 | ev_timer_start (EV_P_ ev_timer *w) EV_NOEXCEPT |
3966 | ev_timer_start (EV_P_ ev_timer *w) EV_NOEXCEPT |
3971 | { |
3967 | { |
3972 | if (expect_false (ev_is_active (w))) |
3968 | if (ecb_expect_false (ev_is_active (w))) |
3973 | return; |
3969 | return; |
3974 | |
3970 | |
3975 | ev_at (w) += mn_now; |
3971 | ev_at (w) += mn_now; |
3976 | |
3972 | |
3977 | assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); |
3973 | assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); |
… | |
… | |
3988 | EV_FREQUENT_CHECK; |
3984 | EV_FREQUENT_CHECK; |
3989 | |
3985 | |
3990 | /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ |
3986 | /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ |
3991 | } |
3987 | } |
3992 | |
3988 | |
3993 | noinline |
3989 | ecb_noinline |
3994 | void |
3990 | void |
3995 | ev_timer_stop (EV_P_ ev_timer *w) EV_NOEXCEPT |
3991 | ev_timer_stop (EV_P_ ev_timer *w) EV_NOEXCEPT |
3996 | { |
3992 | { |
3997 | clear_pending (EV_A_ (W)w); |
3993 | clear_pending (EV_A_ (W)w); |
3998 | if (expect_false (!ev_is_active (w))) |
3994 | if (ecb_expect_false (!ev_is_active (w))) |
3999 | return; |
3995 | return; |
4000 | |
3996 | |
4001 | EV_FREQUENT_CHECK; |
3997 | EV_FREQUENT_CHECK; |
4002 | |
3998 | |
4003 | { |
3999 | { |
… | |
… | |
4005 | |
4001 | |
4006 | assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w)); |
4002 | assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w)); |
4007 | |
4003 | |
4008 | --timercnt; |
4004 | --timercnt; |
4009 | |
4005 | |
4010 | if (expect_true (active < timercnt + HEAP0)) |
4006 | if (ecb_expect_true (active < timercnt + HEAP0)) |
4011 | { |
4007 | { |
4012 | timers [active] = timers [timercnt + HEAP0]; |
4008 | timers [active] = timers [timercnt + HEAP0]; |
4013 | adjustheap (timers, timercnt, active); |
4009 | adjustheap (timers, timercnt, active); |
4014 | } |
4010 | } |
4015 | } |
4011 | } |
… | |
… | |
4019 | ev_stop (EV_A_ (W)w); |
4015 | ev_stop (EV_A_ (W)w); |
4020 | |
4016 | |
4021 | EV_FREQUENT_CHECK; |
4017 | EV_FREQUENT_CHECK; |
4022 | } |
4018 | } |
4023 | |
4019 | |
4024 | noinline |
4020 | ecb_noinline |
4025 | void |
4021 | void |
4026 | ev_timer_again (EV_P_ ev_timer *w) EV_NOEXCEPT |
4022 | ev_timer_again (EV_P_ ev_timer *w) EV_NOEXCEPT |
4027 | { |
4023 | { |
4028 | EV_FREQUENT_CHECK; |
4024 | EV_FREQUENT_CHECK; |
4029 | |
4025 | |
… | |
… | |
4054 | { |
4050 | { |
4055 | return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); |
4051 | return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); |
4056 | } |
4052 | } |
4057 | |
4053 | |
4058 | #if EV_PERIODIC_ENABLE |
4054 | #if EV_PERIODIC_ENABLE |
4059 | noinline |
4055 | ecb_noinline |
4060 | void |
4056 | void |
4061 | ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4057 | ev_periodic_start (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4062 | { |
4058 | { |
4063 | if (expect_false (ev_is_active (w))) |
4059 | if (ecb_expect_false (ev_is_active (w))) |
4064 | return; |
4060 | return; |
4065 | |
4061 | |
4066 | if (w->reschedule_cb) |
4062 | if (w->reschedule_cb) |
4067 | ev_at (w) = w->reschedule_cb (w, ev_rt_now); |
4063 | ev_at (w) = w->reschedule_cb (w, ev_rt_now); |
4068 | else if (w->interval) |
4064 | else if (w->interval) |
… | |
… | |
4085 | EV_FREQUENT_CHECK; |
4081 | EV_FREQUENT_CHECK; |
4086 | |
4082 | |
4087 | /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ |
4083 | /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ |
4088 | } |
4084 | } |
4089 | |
4085 | |
4090 | noinline |
4086 | ecb_noinline |
4091 | void |
4087 | void |
4092 | ev_periodic_stop (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4088 | ev_periodic_stop (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4093 | { |
4089 | { |
4094 | clear_pending (EV_A_ (W)w); |
4090 | clear_pending (EV_A_ (W)w); |
4095 | if (expect_false (!ev_is_active (w))) |
4091 | if (ecb_expect_false (!ev_is_active (w))) |
4096 | return; |
4092 | return; |
4097 | |
4093 | |
4098 | EV_FREQUENT_CHECK; |
4094 | EV_FREQUENT_CHECK; |
4099 | |
4095 | |
4100 | { |
4096 | { |
… | |
… | |
4102 | |
4098 | |
4103 | assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w)); |
4099 | assert (("libev: internal periodic heap corruption", ANHE_w (periodics [active]) == (WT)w)); |
4104 | |
4100 | |
4105 | --periodiccnt; |
4101 | --periodiccnt; |
4106 | |
4102 | |
4107 | if (expect_true (active < periodiccnt + HEAP0)) |
4103 | if (ecb_expect_true (active < periodiccnt + HEAP0)) |
4108 | { |
4104 | { |
4109 | periodics [active] = periodics [periodiccnt + HEAP0]; |
4105 | periodics [active] = periodics [periodiccnt + HEAP0]; |
4110 | adjustheap (periodics, periodiccnt, active); |
4106 | adjustheap (periodics, periodiccnt, active); |
4111 | } |
4107 | } |
4112 | } |
4108 | } |
… | |
… | |
4114 | ev_stop (EV_A_ (W)w); |
4110 | ev_stop (EV_A_ (W)w); |
4115 | |
4111 | |
4116 | EV_FREQUENT_CHECK; |
4112 | EV_FREQUENT_CHECK; |
4117 | } |
4113 | } |
4118 | |
4114 | |
4119 | noinline |
4115 | ecb_noinline |
4120 | void |
4116 | void |
4121 | ev_periodic_again (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4117 | ev_periodic_again (EV_P_ ev_periodic *w) EV_NOEXCEPT |
4122 | { |
4118 | { |
4123 | /* TODO: use adjustheap and recalculation */ |
4119 | /* TODO: use adjustheap and recalculation */ |
4124 | ev_periodic_stop (EV_A_ w); |
4120 | ev_periodic_stop (EV_A_ w); |
… | |
… | |
4130 | # define SA_RESTART 0 |
4126 | # define SA_RESTART 0 |
4131 | #endif |
4127 | #endif |
4132 | |
4128 | |
4133 | #if EV_SIGNAL_ENABLE |
4129 | #if EV_SIGNAL_ENABLE |
4134 | |
4130 | |
4135 | noinline |
4131 | ecb_noinline |
4136 | void |
4132 | void |
4137 | ev_signal_start (EV_P_ ev_signal *w) EV_NOEXCEPT |
4133 | ev_signal_start (EV_P_ ev_signal *w) EV_NOEXCEPT |
4138 | { |
4134 | { |
4139 | if (expect_false (ev_is_active (w))) |
4135 | if (ecb_expect_false (ev_is_active (w))) |
4140 | return; |
4136 | return; |
4141 | |
4137 | |
4142 | assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); |
4138 | assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); |
4143 | |
4139 | |
4144 | #if EV_MULTIPLICITY |
4140 | #if EV_MULTIPLICITY |
… | |
… | |
4213 | } |
4209 | } |
4214 | |
4210 | |
4215 | EV_FREQUENT_CHECK; |
4211 | EV_FREQUENT_CHECK; |
4216 | } |
4212 | } |
4217 | |
4213 | |
4218 | noinline |
4214 | ecb_noinline |
4219 | void |
4215 | void |
4220 | ev_signal_stop (EV_P_ ev_signal *w) EV_NOEXCEPT |
4216 | ev_signal_stop (EV_P_ ev_signal *w) EV_NOEXCEPT |
4221 | { |
4217 | { |
4222 | clear_pending (EV_A_ (W)w); |
4218 | clear_pending (EV_A_ (W)w); |
4223 | if (expect_false (!ev_is_active (w))) |
4219 | if (ecb_expect_false (!ev_is_active (w))) |
4224 | return; |
4220 | return; |
4225 | |
4221 | |
4226 | EV_FREQUENT_CHECK; |
4222 | EV_FREQUENT_CHECK; |
4227 | |
4223 | |
4228 | wlist_del (&signals [w->signum - 1].head, (WL)w); |
4224 | wlist_del (&signals [w->signum - 1].head, (WL)w); |
… | |
… | |
4261 | ev_child_start (EV_P_ ev_child *w) EV_NOEXCEPT |
4257 | ev_child_start (EV_P_ ev_child *w) EV_NOEXCEPT |
4262 | { |
4258 | { |
4263 | #if EV_MULTIPLICITY |
4259 | #if EV_MULTIPLICITY |
4264 | assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
4260 | assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); |
4265 | #endif |
4261 | #endif |
4266 | if (expect_false (ev_is_active (w))) |
4262 | if (ecb_expect_false (ev_is_active (w))) |
4267 | return; |
4263 | return; |
4268 | |
4264 | |
4269 | EV_FREQUENT_CHECK; |
4265 | EV_FREQUENT_CHECK; |
4270 | |
4266 | |
4271 | ev_start (EV_A_ (W)w, 1); |
4267 | ev_start (EV_A_ (W)w, 1); |
… | |
… | |
4276 | |
4272 | |
4277 | void |
4273 | void |
4278 | ev_child_stop (EV_P_ ev_child *w) EV_NOEXCEPT |
4274 | ev_child_stop (EV_P_ ev_child *w) EV_NOEXCEPT |
4279 | { |
4275 | { |
4280 | clear_pending (EV_A_ (W)w); |
4276 | clear_pending (EV_A_ (W)w); |
4281 | if (expect_false (!ev_is_active (w))) |
4277 | if (ecb_expect_false (!ev_is_active (w))) |
4282 | return; |
4278 | return; |
4283 | |
4279 | |
4284 | EV_FREQUENT_CHECK; |
4280 | EV_FREQUENT_CHECK; |
4285 | |
4281 | |
4286 | wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); |
4282 | wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); |
… | |
… | |
4300 | |
4296 | |
4301 | #define DEF_STAT_INTERVAL 5.0074891 |
4297 | #define DEF_STAT_INTERVAL 5.0074891 |
4302 | #define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */ |
4298 | #define NFS_STAT_INTERVAL 30.1074891 /* for filesystems potentially failing inotify */ |
4303 | #define MIN_STAT_INTERVAL 0.1074891 |
4299 | #define MIN_STAT_INTERVAL 0.1074891 |
4304 | |
4300 | |
4305 | noinline static void stat_timer_cb (EV_P_ ev_timer *w_, int revents); |
4301 | ecb_noinline static void stat_timer_cb (EV_P_ ev_timer *w_, int revents); |
4306 | |
4302 | |
4307 | #if EV_USE_INOTIFY |
4303 | #if EV_USE_INOTIFY |
4308 | |
4304 | |
4309 | /* the * 2 is to allow for alignment padding, which for some reason is >> 8 */ |
4305 | /* the * 2 is to allow for alignment padding, which for some reason is >> 8 */ |
4310 | # define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX) |
4306 | # define EV_INOTIFY_BUFSIZE (sizeof (struct inotify_event) * 2 + NAME_MAX) |
4311 | |
4307 | |
4312 | noinline |
4308 | ecb_noinline |
4313 | static void |
4309 | static void |
4314 | infy_add (EV_P_ ev_stat *w) |
4310 | infy_add (EV_P_ ev_stat *w) |
4315 | { |
4311 | { |
4316 | w->wd = inotify_add_watch (fs_fd, w->path, |
4312 | w->wd = inotify_add_watch (fs_fd, w->path, |
4317 | IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY |
4313 | IN_ATTRIB | IN_DELETE_SELF | IN_MOVE_SELF | IN_MODIFY |
… | |
… | |
4382 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
4378 | if (ev_is_active (&w->timer)) ev_ref (EV_A); |
4383 | ev_timer_again (EV_A_ &w->timer); |
4379 | ev_timer_again (EV_A_ &w->timer); |
4384 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
4380 | if (ev_is_active (&w->timer)) ev_unref (EV_A); |
4385 | } |
4381 | } |
4386 | |
4382 | |
4387 | noinline |
4383 | ecb_noinline |
4388 | static void |
4384 | static void |
4389 | infy_del (EV_P_ ev_stat *w) |
4385 | infy_del (EV_P_ ev_stat *w) |
4390 | { |
4386 | { |
4391 | int slot; |
4387 | int slot; |
4392 | int wd = w->wd; |
4388 | int wd = w->wd; |
… | |
… | |
4400 | |
4396 | |
4401 | /* remove this watcher, if others are watching it, they will rearm */ |
4397 | /* remove this watcher, if others are watching it, they will rearm */ |
4402 | inotify_rm_watch (fs_fd, wd); |
4398 | inotify_rm_watch (fs_fd, wd); |
4403 | } |
4399 | } |
4404 | |
4400 | |
4405 | noinline |
4401 | ecb_noinline |
4406 | static void |
4402 | static void |
4407 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
4403 | infy_wd (EV_P_ int slot, int wd, struct inotify_event *ev) |
4408 | { |
4404 | { |
4409 | if (slot < 0) |
4405 | if (slot < 0) |
4410 | /* overflow, need to check for all hash slots */ |
4406 | /* overflow, need to check for all hash slots */ |
… | |
… | |
4556 | w->attr.st_nlink = 0; |
4552 | w->attr.st_nlink = 0; |
4557 | else if (!w->attr.st_nlink) |
4553 | else if (!w->attr.st_nlink) |
4558 | w->attr.st_nlink = 1; |
4554 | w->attr.st_nlink = 1; |
4559 | } |
4555 | } |
4560 | |
4556 | |
4561 | noinline |
4557 | ecb_noinline |
4562 | static void |
4558 | static void |
4563 | stat_timer_cb (EV_P_ ev_timer *w_, int revents) |
4559 | stat_timer_cb (EV_P_ ev_timer *w_, int revents) |
4564 | { |
4560 | { |
4565 | ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); |
4561 | ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); |
4566 | |
4562 | |
… | |
… | |
4600 | } |
4596 | } |
4601 | |
4597 | |
4602 | void |
4598 | void |
4603 | ev_stat_start (EV_P_ ev_stat *w) EV_NOEXCEPT |
4599 | ev_stat_start (EV_P_ ev_stat *w) EV_NOEXCEPT |
4604 | { |
4600 | { |
4605 | if (expect_false (ev_is_active (w))) |
4601 | if (ecb_expect_false (ev_is_active (w))) |
4606 | return; |
4602 | return; |
4607 | |
4603 | |
4608 | ev_stat_stat (EV_A_ w); |
4604 | ev_stat_stat (EV_A_ w); |
4609 | |
4605 | |
4610 | if (w->interval < MIN_STAT_INTERVAL && w->interval) |
4606 | if (w->interval < MIN_STAT_INTERVAL && w->interval) |
… | |
… | |
4632 | |
4628 | |
4633 | void |
4629 | void |
4634 | ev_stat_stop (EV_P_ ev_stat *w) EV_NOEXCEPT |
4630 | ev_stat_stop (EV_P_ ev_stat *w) EV_NOEXCEPT |
4635 | { |
4631 | { |
4636 | clear_pending (EV_A_ (W)w); |
4632 | clear_pending (EV_A_ (W)w); |
4637 | if (expect_false (!ev_is_active (w))) |
4633 | if (ecb_expect_false (!ev_is_active (w))) |
4638 | return; |
4634 | return; |
4639 | |
4635 | |
4640 | EV_FREQUENT_CHECK; |
4636 | EV_FREQUENT_CHECK; |
4641 | |
4637 | |
4642 | #if EV_USE_INOTIFY |
4638 | #if EV_USE_INOTIFY |
… | |
… | |
4657 | |
4653 | |
4658 | #if EV_IDLE_ENABLE |
4654 | #if EV_IDLE_ENABLE |
4659 | void |
4655 | void |
4660 | ev_idle_start (EV_P_ ev_idle *w) EV_NOEXCEPT |
4656 | ev_idle_start (EV_P_ ev_idle *w) EV_NOEXCEPT |
4661 | { |
4657 | { |
4662 | if (expect_false (ev_is_active (w))) |
4658 | if (ecb_expect_false (ev_is_active (w))) |
4663 | return; |
4659 | return; |
4664 | |
4660 | |
4665 | pri_adjust (EV_A_ (W)w); |
4661 | pri_adjust (EV_A_ (W)w); |
4666 | |
4662 | |
4667 | EV_FREQUENT_CHECK; |
4663 | EV_FREQUENT_CHECK; |
… | |
… | |
4681 | |
4677 | |
4682 | void |
4678 | void |
4683 | ev_idle_stop (EV_P_ ev_idle *w) EV_NOEXCEPT |
4679 | ev_idle_stop (EV_P_ ev_idle *w) EV_NOEXCEPT |
4684 | { |
4680 | { |
4685 | clear_pending (EV_A_ (W)w); |
4681 | clear_pending (EV_A_ (W)w); |
4686 | if (expect_false (!ev_is_active (w))) |
4682 | if (ecb_expect_false (!ev_is_active (w))) |
4687 | return; |
4683 | return; |
4688 | |
4684 | |
4689 | EV_FREQUENT_CHECK; |
4685 | EV_FREQUENT_CHECK; |
4690 | |
4686 | |
4691 | { |
4687 | { |
… | |
… | |
4704 | |
4700 | |
4705 | #if EV_PREPARE_ENABLE |
4701 | #if EV_PREPARE_ENABLE |
4706 | void |
4702 | void |
4707 | ev_prepare_start (EV_P_ ev_prepare *w) EV_NOEXCEPT |
4703 | ev_prepare_start (EV_P_ ev_prepare *w) EV_NOEXCEPT |
4708 | { |
4704 | { |
4709 | if (expect_false (ev_is_active (w))) |
4705 | if (ecb_expect_false (ev_is_active (w))) |
4710 | return; |
4706 | return; |
4711 | |
4707 | |
4712 | EV_FREQUENT_CHECK; |
4708 | EV_FREQUENT_CHECK; |
4713 | |
4709 | |
4714 | ev_start (EV_A_ (W)w, ++preparecnt); |
4710 | ev_start (EV_A_ (W)w, ++preparecnt); |
… | |
… | |
4720 | |
4716 | |
4721 | void |
4717 | void |
4722 | ev_prepare_stop (EV_P_ ev_prepare *w) EV_NOEXCEPT |
4718 | ev_prepare_stop (EV_P_ ev_prepare *w) EV_NOEXCEPT |
4723 | { |
4719 | { |
4724 | clear_pending (EV_A_ (W)w); |
4720 | clear_pending (EV_A_ (W)w); |
4725 | if (expect_false (!ev_is_active (w))) |
4721 | if (ecb_expect_false (!ev_is_active (w))) |
4726 | return; |
4722 | return; |
4727 | |
4723 | |
4728 | EV_FREQUENT_CHECK; |
4724 | EV_FREQUENT_CHECK; |
4729 | |
4725 | |
4730 | { |
4726 | { |
… | |
… | |
4742 | |
4738 | |
4743 | #if EV_CHECK_ENABLE |
4739 | #if EV_CHECK_ENABLE |
4744 | void |
4740 | void |
4745 | ev_check_start (EV_P_ ev_check *w) EV_NOEXCEPT |
4741 | ev_check_start (EV_P_ ev_check *w) EV_NOEXCEPT |
4746 | { |
4742 | { |
4747 | if (expect_false (ev_is_active (w))) |
4743 | if (ecb_expect_false (ev_is_active (w))) |
4748 | return; |
4744 | return; |
4749 | |
4745 | |
4750 | EV_FREQUENT_CHECK; |
4746 | EV_FREQUENT_CHECK; |
4751 | |
4747 | |
4752 | ev_start (EV_A_ (W)w, ++checkcnt); |
4748 | ev_start (EV_A_ (W)w, ++checkcnt); |
… | |
… | |
4758 | |
4754 | |
4759 | void |
4755 | void |
4760 | ev_check_stop (EV_P_ ev_check *w) EV_NOEXCEPT |
4756 | ev_check_stop (EV_P_ ev_check *w) EV_NOEXCEPT |
4761 | { |
4757 | { |
4762 | clear_pending (EV_A_ (W)w); |
4758 | clear_pending (EV_A_ (W)w); |
4763 | if (expect_false (!ev_is_active (w))) |
4759 | if (ecb_expect_false (!ev_is_active (w))) |
4764 | return; |
4760 | return; |
4765 | |
4761 | |
4766 | EV_FREQUENT_CHECK; |
4762 | EV_FREQUENT_CHECK; |
4767 | |
4763 | |
4768 | { |
4764 | { |
… | |
… | |
4777 | EV_FREQUENT_CHECK; |
4773 | EV_FREQUENT_CHECK; |
4778 | } |
4774 | } |
4779 | #endif |
4775 | #endif |
4780 | |
4776 | |
4781 | #if EV_EMBED_ENABLE |
4777 | #if EV_EMBED_ENABLE |
4782 | noinline |
4778 | ecb_noinline |
4783 | void |
4779 | void |
4784 | ev_embed_sweep (EV_P_ ev_embed *w) EV_NOEXCEPT |
4780 | ev_embed_sweep (EV_P_ ev_embed *w) EV_NOEXCEPT |
4785 | { |
4781 | { |
4786 | ev_run (w->other, EVRUN_NOWAIT); |
4782 | ev_run (w->other, EVRUN_NOWAIT); |
4787 | } |
4783 | } |
… | |
… | |
4839 | #endif |
4835 | #endif |
4840 | |
4836 | |
4841 | void |
4837 | void |
4842 | ev_embed_start (EV_P_ ev_embed *w) EV_NOEXCEPT |
4838 | ev_embed_start (EV_P_ ev_embed *w) EV_NOEXCEPT |
4843 | { |
4839 | { |
4844 | if (expect_false (ev_is_active (w))) |
4840 | if (ecb_expect_false (ev_is_active (w))) |
4845 | return; |
4841 | return; |
4846 | |
4842 | |
4847 | { |
4843 | { |
4848 | EV_P = w->other; |
4844 | EV_P = w->other; |
4849 | assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); |
4845 | assert (("libev: loop to be embedded is not embeddable", backend & ev_embeddable_backends ())); |
… | |
… | |
4871 | |
4867 | |
4872 | void |
4868 | void |
4873 | ev_embed_stop (EV_P_ ev_embed *w) EV_NOEXCEPT |
4869 | ev_embed_stop (EV_P_ ev_embed *w) EV_NOEXCEPT |
4874 | { |
4870 | { |
4875 | clear_pending (EV_A_ (W)w); |
4871 | clear_pending (EV_A_ (W)w); |
4876 | if (expect_false (!ev_is_active (w))) |
4872 | if (ecb_expect_false (!ev_is_active (w))) |
4877 | return; |
4873 | return; |
4878 | |
4874 | |
4879 | EV_FREQUENT_CHECK; |
4875 | EV_FREQUENT_CHECK; |
4880 | |
4876 | |
4881 | ev_io_stop (EV_A_ &w->io); |
4877 | ev_io_stop (EV_A_ &w->io); |
… | |
… | |
4890 | |
4886 | |
4891 | #if EV_FORK_ENABLE |
4887 | #if EV_FORK_ENABLE |
4892 | void |
4888 | void |
4893 | ev_fork_start (EV_P_ ev_fork *w) EV_NOEXCEPT |
4889 | ev_fork_start (EV_P_ ev_fork *w) EV_NOEXCEPT |
4894 | { |
4890 | { |
4895 | if (expect_false (ev_is_active (w))) |
4891 | if (ecb_expect_false (ev_is_active (w))) |
4896 | return; |
4892 | return; |
4897 | |
4893 | |
4898 | EV_FREQUENT_CHECK; |
4894 | EV_FREQUENT_CHECK; |
4899 | |
4895 | |
4900 | ev_start (EV_A_ (W)w, ++forkcnt); |
4896 | ev_start (EV_A_ (W)w, ++forkcnt); |
… | |
… | |
4906 | |
4902 | |
4907 | void |
4903 | void |
4908 | ev_fork_stop (EV_P_ ev_fork *w) EV_NOEXCEPT |
4904 | ev_fork_stop (EV_P_ ev_fork *w) EV_NOEXCEPT |
4909 | { |
4905 | { |
4910 | clear_pending (EV_A_ (W)w); |
4906 | clear_pending (EV_A_ (W)w); |
4911 | if (expect_false (!ev_is_active (w))) |
4907 | if (ecb_expect_false (!ev_is_active (w))) |
4912 | return; |
4908 | return; |
4913 | |
4909 | |
4914 | EV_FREQUENT_CHECK; |
4910 | EV_FREQUENT_CHECK; |
4915 | |
4911 | |
4916 | { |
4912 | { |
… | |
… | |
4928 | |
4924 | |
4929 | #if EV_CLEANUP_ENABLE |
4925 | #if EV_CLEANUP_ENABLE |
4930 | void |
4926 | void |
4931 | ev_cleanup_start (EV_P_ ev_cleanup *w) EV_NOEXCEPT |
4927 | ev_cleanup_start (EV_P_ ev_cleanup *w) EV_NOEXCEPT |
4932 | { |
4928 | { |
4933 | if (expect_false (ev_is_active (w))) |
4929 | if (ecb_expect_false (ev_is_active (w))) |
4934 | return; |
4930 | return; |
4935 | |
4931 | |
4936 | EV_FREQUENT_CHECK; |
4932 | EV_FREQUENT_CHECK; |
4937 | |
4933 | |
4938 | ev_start (EV_A_ (W)w, ++cleanupcnt); |
4934 | ev_start (EV_A_ (W)w, ++cleanupcnt); |
… | |
… | |
4946 | |
4942 | |
4947 | void |
4943 | void |
4948 | ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_NOEXCEPT |
4944 | ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_NOEXCEPT |
4949 | { |
4945 | { |
4950 | clear_pending (EV_A_ (W)w); |
4946 | clear_pending (EV_A_ (W)w); |
4951 | if (expect_false (!ev_is_active (w))) |
4947 | if (ecb_expect_false (!ev_is_active (w))) |
4952 | return; |
4948 | return; |
4953 | |
4949 | |
4954 | EV_FREQUENT_CHECK; |
4950 | EV_FREQUENT_CHECK; |
4955 | ev_ref (EV_A); |
4951 | ev_ref (EV_A); |
4956 | |
4952 | |
… | |
… | |
4969 | |
4965 | |
4970 | #if EV_ASYNC_ENABLE |
4966 | #if EV_ASYNC_ENABLE |
4971 | void |
4967 | void |
4972 | ev_async_start (EV_P_ ev_async *w) EV_NOEXCEPT |
4968 | ev_async_start (EV_P_ ev_async *w) EV_NOEXCEPT |
4973 | { |
4969 | { |
4974 | if (expect_false (ev_is_active (w))) |
4970 | if (ecb_expect_false (ev_is_active (w))) |
4975 | return; |
4971 | return; |
4976 | |
4972 | |
4977 | w->sent = 0; |
4973 | w->sent = 0; |
4978 | |
4974 | |
4979 | evpipe_init (EV_A); |
4975 | evpipe_init (EV_A); |
… | |
… | |
4989 | |
4985 | |
4990 | void |
4986 | void |
4991 | ev_async_stop (EV_P_ ev_async *w) EV_NOEXCEPT |
4987 | ev_async_stop (EV_P_ ev_async *w) EV_NOEXCEPT |
4992 | { |
4988 | { |
4993 | clear_pending (EV_A_ (W)w); |
4989 | clear_pending (EV_A_ (W)w); |
4994 | if (expect_false (!ev_is_active (w))) |
4990 | if (ecb_expect_false (!ev_is_active (w))) |
4995 | return; |
4991 | return; |
4996 | |
4992 | |
4997 | EV_FREQUENT_CHECK; |
4993 | EV_FREQUENT_CHECK; |
4998 | |
4994 | |
4999 | { |
4995 | { |