Lines Matching +full:local +full:- +full:timers
7 * Redistribution and use in source and binary forms, with or without modifica-
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
222 /* this block tries to deduce configuration from header-defined symbols and defaults */
416 /* hp-ux has it in sys/time.h, which we unconditionally include above */
466 char pad[128 - sizeof (uint32_t)];
488 #define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } whi…
489 #define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } whi…
491 /* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */
494 * libecb - http://software.schmorp.de/pkg/libecb
496 * Copyright (©) 2009-2015 Marc Alexander Lehmann <libecb@schmorp.de>
500 * Redistribution and use in source and binary forms, with or without modifica-
511 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
513 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
517 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
587 * we try to detect these and simply assume they are not gcc - if they have
636 /* ECB_NO_THREADS - ecb is not used by multiple threads, ever */
637 /* ECB_NO_SMP - ecb might be used in multiple threads, but only on a single cpu */
647 /* http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/compiler_re…
659 … #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
674 /* should not need any, unless running old code on newer cpu - arm doesn't support that */
757 /* Why that is, we don't know - either the C11 memory model is quite useless */
761 /* Update, gcc-4.8 generates mfence for all c++ fences, but nothing */
834 … _Generic ((1 ? (struct ecb_is_constant_struct *)0 : (void *)((expr) - (expr)), ecb_is_cons…
885 …/* http://www-01.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/language_r…
890 /* http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx */
977 x -= (x >> 1) & 0x55555555; in ecb_popcount32()
1023 ecb_function_ ecb_const ecb_bool ecb_is_pot32 (uint32_t x) { return !(x & (x - 1)); } in ecb_is_pot32()
1025 ecb_function_ ecb_const ecb_bool ecb_is_pot64 (uint64_t x) { return !(x & (x - 1)); } in ecb_is_pot64()
1075 ecb_inline ecb_const uint8_t ecb_rotl8 (uint8_t x, unsigned int count) { return (x >> ( 8 - coun… in ecb_rotl8()
1076 ecb_inline ecb_const uint8_t ecb_rotr8 (uint8_t x, unsigned int count) { return (x << ( 8 - coun… in ecb_rotr8()
1077 ecb_inline ecb_const uint16_t ecb_rotl16 (uint16_t x, unsigned int count) { return (x >> (16 - coun… in ecb_rotl16()
1078 ecb_inline ecb_const uint16_t ecb_rotr16 (uint16_t x, unsigned int count) { return (x << (16 - coun… in ecb_rotr16()
1079 ecb_inline ecb_const uint32_t ecb_rotl32 (uint32_t x, unsigned int count) { return (x >> (32 - coun… in ecb_rotl32()
1080 ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - coun… in ecb_rotr32()
1081 ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - coun… in ecb_rotl64()
1082 ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - coun… in ecb_rotr64()
1167 #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n)))
1174 return val < 0 ? - ((-val + div - 1) / div) : (val ) / div; in ecb_div_rd()
1179 return val < 0 ? - ((-val ) / div) : (val + div - 1) / div; in ecb_div_ru()
1182 …#define ecb_div_rd(val,div) ((val) < 0 ? - ((-(val) + (div) - 1) / (div)) : ((val) ) / …
1183 …#define ecb_div_ru(val,div) ((val) < 0 ? - ((-(val) ) / (div)) : ((val) + (div) - 1) / …
1187 …/* does not work for local types (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.ht…
1201 unsigned int s = (x & 0x8000) << (31 - 15); in ecb_binary16_to_binary32()
1207 e = 255 - (127 - 15); in ecb_binary16_to_binary32()
1212 e = 0 - (127 - 15); in ecb_binary16_to_binary32()
1216 unsigned int s = 10 - ecb_ld32 (m); in ecb_binary16_to_binary32()
1219 e -= s - 1; in ecb_binary16_to_binary32()
1224 e += 127 - 15; in ecb_binary16_to_binary32()
1226 return s | (e << 23) | (m << (23 - 10)); in ecb_binary16_to_binary32()
1234 unsigned int e = ((x >> 23) & 0x000000ff) - (127 - 15); /* the desired exponent */ in ecb_binary32_to_binary16()
1242 /* mantissa round-to-even */ in ecb_binary32_to_binary16()
1243 m += 0x00000fff + ((m >> (23 - 10)) & 1); in ecb_binary32_to_binary16()
1252 return s | (e << 10) | (m >> (23 - 10)); in ecb_binary32_to_binary16()
1269 if (e < (14 - 24)) /* might not be sharp, but is good enough */ in ecb_binary32_to_binary16()
1274 /* very tricky - we need to round to the nearest e (+10) bit value */ in ecb_binary32_to_binary16()
1276 unsigned int bits = 14 - e; in ecb_binary32_to_binary16()
1277 unsigned int half = (1 << (bits - 1)) - 1; in ecb_binary32_to_binary16()
1296 /* basically, everything uses "ieee pure-endian" floating point numbers */
1354 /* slow emulation, works for anything but -0 */ in ecb_float_to_binary32()
1360 if (x < -3.40282346638528860e+38f) return 0xff800000U; in ecb_float_to_binary32()
1368 m = -m; in ecb_float_to_binary32()
1370 if (e <= -126) in ecb_float_to_binary32()
1373 m >>= (-125 - e); in ecb_float_to_binary32()
1374 e = -126; in ecb_float_to_binary32()
1405 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */ in ecb_binary32_to_float()
1406 r = ecb_ldexpf (x * (0.5f / 0x800000U), e - 126); in ecb_binary32_to_float()
1408 r = neg ? -r : r; in ecb_binary32_to_float()
1424 /* slow emulation, works for anything but -0 */ in ecb_double_to_binary64()
1430 if (x < -1.79769313486231470e+308) return 0xfff0000000000000U; in ecb_double_to_binary64()
1438 m = -m; in ecb_double_to_binary64()
1440 if (e <= -1022) in ecb_double_to_binary64()
1443 m >>= (-1021 - e); in ecb_double_to_binary64()
1444 e = -1022; in ecb_double_to_binary64()
1475 /* we distrust ldexp a bit and do the 2**-53 scaling by an extra multiply */ in ecb_binary64_to_double()
1476 r = ldexp (x * (0.5 / 0x10000000000000U), e - 1022); in ecb_binary64_to_double()
1478 r = neg ? -r : r; in ecb_binary64_to_double()
1508 * single-cpu/core, or if you use libev in a project that doesn't use libev
1542 #define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
1547 # define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
1550 #define EMPTY /* required for microsofts broken pseudo-c compiler */
1557 #define ev_active(w) ((W)(w))->active
1558 #define ev_at(w) ((WT)(w))->at
1561 /* sig_atomic_t is used to avoid per-thread variables or locking but still */
1611 if (v == v - 1.) in ev_floor()
1615 return f + ev_floor (v - f); in ev_floor()
1621 ev_tstamp f = -ev_floor (-v); in ev_floor()
1623 return f - (f == v ? 0 : 1); in ev_floor()
1650 for (i = 3+1; --i; ) in ev_linux_version()
1657 c = c * 10 + *p++ - '0'; in ev_linux_version()
1718 * implement realloc (x, 0) (as required by both ansi c-89 and in ev_realloc_emul()
1792 /* hash table entry per inotify-id */
1807 #define ANHE_w(he) (he).w /* access watcher, read-write */
1808 #define ANHE_at(he) (he).at /* access cached at, read-only */
1809 #define ANHE_at_cache(he) (he).at = (he).w->at /* update at from watcher */
1815 #define ANHE_at(he) (he)->at
1824 #define ev_rt_now ((loop)->ev_rt_now)
1868 return ts.tv_sec + ts.tv_nsec * 1e-9; in ev_time()
1874 return tv.tv_sec + tv.tv_usec * 1e-6; in ev_time()
1886 return ts.tv_sec + ts.tv_nsec * 1e-9; in get_clock()
1930 /* hopefully by rounding to a nice-to-malloc size */
1940 /* if size is large, round to MALLOC_ROUND - 4 * longs to accommodate malloc overhead */ in array_nextsize()
1941 if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) in array_nextsize()
1944 ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); in array_nextsize()
1945 ncur = ncur - sizeof (void *) * 4; in array_nextsize()
1968 init ((base) + (ocur_), (cur) - ocur_); \
1998 if (expect_false (w_->pending)) in ev_feed_event()
1999 pendings [pri][w_->pending - 1].events |= revents; in ev_feed_event()
2002 w_->pending = ++pendingcnt [pri]; in ev_feed_event()
2003 array_needsize (ANPENDING, pendings [pri], pendingmax [pri], w_->pending, EMPTY2); in ev_feed_event()
2004 pendings [pri][w_->pending - 1].w = w_; in ev_feed_event()
2005 pendings [pri][w_->pending - 1].events = revents; in ev_feed_event()
2008 pendingpri = NUMPRI - 1; in ev_feed_event()
2022 ev_feed_event (EV_A_ rfeeds [--rfeedcnt], revents); in feed_reverse_done()
2043 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) in fd_event_nocheck()
2045 int ev = w->events & revents; in fd_event_nocheck()
2059 if (expect_true (!anfd->reify)) in fd_event()
2070 /* make sure the external fd watch events are in-sync */
2083 if (anfd->reify & EV__IOFDSET && anfd->head) in fd_reify()
2087 if (handle != anfd->handle) in fd_reify()
2093 /* handle changed, but fd didn't - we need to do it in two steps */ in fd_reify()
2094 backend_modify (EV_A_ fd, anfd->events, 0); in fd_reify()
2095 anfd->events = 0; in fd_reify()
2096 anfd->handle = handle; in fd_reify()
2108 unsigned char o_events = anfd->events; in fd_reify()
2109 unsigned char o_reify = anfd->reify; in fd_reify()
2111 anfd->reify = 0; in fd_reify()
2115 anfd->events = 0; in fd_reify()
2117 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) in fd_reify()
2118 anfd->events |= (unsigned char)w->events; in fd_reify()
2120 if (o_events != anfd->events) in fd_reify()
2125 backend_modify (EV_A_ fd, o_events, anfd->events); in fd_reify()
2142 fdchanges [fdchangecnt - 1] = fd; in fd_change()
2164 return EV_FD_TO_WIN32_HANDLE (fd) != -1; in fd_valid()
2166 return fcntl (fd, F_GETFD) != -1; in fd_valid()
2188 for (fd = anfdmax; fd--; ) in fd_enomem()
2196 /* usually called after fork if backend needs to re-arm all fds from scratch */
2212 /* this is not fork-safe */
2229 * be in-use at any time. the first heap entry is at array [HEAP0]. DHEAP gives
2230 * the branching factor of the d-tree.
2235 * a small-code-size 2-heap one and a ~1.5kb larger 4-heap
2236 * which is more cache-efficient.
2242 #define HEAP0 (DHEAP - 1) /* index of first element in heap */
2243 #define HPARENT(k) ((((k) - HEAP0 - 1) / DHEAP) + HEAP0)
2257 ANHE *pos = heap + DHEAP * (k - HEAP0) + HEAP0 + 1; in downheap()
2260 if (expect_true (pos + DHEAP - 1 < E)) in downheap()
2283 k = minpos - heap; in downheap()
2364 /* we don't use floyds algorithm, upheap is simpler and is more cache-efficient */ in reheap()
2365 /* also, this is easy to implement and correct for both 2-heaps and 4-heaps */ in reheap()
2382 static ANSIG signals [EV_NSIG - 1];
2396 fds [0] = -1; in evpipe_init()
2524 for (i = EV_NSIG - 1; i--; ) in pipecb()
2537 for (i = asynccnt; i--; ) in pipecb()
2538 if (asyncs [i]->sent) in pipecb()
2540 asyncs [i]->sent = 0; in pipecb()
2556 EV_A = signals [signum - 1].loop; in ev_feed_signal()
2562 signals [signum - 1].pending = 1; in ev_feed_signal()
2584 --signum; in ev_feed_signal_event()
2597 for (w = signals [signum].head; w; w = w->next) in ev_feed_signal_event()
2611 /* not ISO-C, as res might be -1, but works with SuS */ in sigfdcb()
2613 ev_feed_signal_event (EV_A_ sip->ssi_signo); in sigfdcb()
2641 for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) in child_reap()
2643 if ((w->pid == pid || !w->pid) in child_reap()
2644 && (!traced || (w->flags & 1))) in child_reap()
2647 w->rpid = pid; in child_reap()
2648 w->rstatus = status; in child_reap()
2665 if (0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) in childcb()
2668 || 0 >= (pid = waitpid (-1, &status, WNOHANG | WUNTRACED))) in childcb()
2752 /* only select works correctly on that "unix-certified" platform */ in ev_recommended_backends()
2757 …L; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */ in ev_recommended_backends()
2832 /* initialise a loop structure, must be zero-initialised */
2874 rtmn_diff = ev_rt_now - mn_now; in loop_init()
2882 backend_fd = -1; in loop_init()
2889 evpipe [0] = -1; in loop_init()
2890 evpipe [1] = -1; in loop_init()
2892 fs_fd = flags & EVFLAG_NOINOTIFY ? -1 : -2; in loop_init()
2895 sigfd = flags & EVFLAG_SIGNALFD ? -2 : -1; in loop_init()
2999 for (i = NUMPRI; i--; ) in ev_loop_destroy()
3009 /* have to use the microsoft-never-gets-it-right macro */ in ev_loop_destroy()
3105 if (w->pending) in verify_watcher()
3106 …assert (("libev: pending watcher not on pending queue", pendings [ABSPRI (w)][w->pending - 1].w ==… in verify_watcher()
3127 while (cnt--) in array_verify()
3143 assert (activecnt >= -1); in ev_verify()
3154 for (w = w2 = anfds [i].head; w; w = w->next) in ev_verify()
3161 w2 = w2->next; in ev_verify()
3165 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); in ev_verify()
3170 verify_heap (EV_A_ timers, timercnt); in ev_verify()
3177 for (i = NUMPRI; i--; ) in ev_verify()
3214 for (w = (ev_child *)childs [chain & ((EV_PID_HASHSIZE) - 1)]; w; w = (ev_child *)((WL)w)->next) in ev_verify()
3215 for (signum = EV_NSIG; signum--; ) if (signals [signum].pending) in ev_verify()
3275 for (pri = NUMPRI; pri--; ) in ev_pending_count()
3288 --pendingpri; in ev_invoke_pending()
3292 ANPENDING *p = pendings [pendingpri] + --pendingcnt [pendingpri]; in ev_invoke_pending()
3294 p->w->pending = 0; in ev_invoke_pending()
3295 EV_CB_INVOKE (p->w, p->events); in ev_invoke_pending()
3302 /* make idle watchers pending. this handles the "call-idle */
3311 for (pri = NUMPRI; pri--; ) in idle_reify()
3326 /* make timers pending */
3332 if (timercnt && ANHE_at (timers [HEAP0]) < mn_now) in timers_reify()
3336 ev_timer *w = (ev_timer *)ANHE_w (timers [HEAP0]); in timers_reify()
3341 if (w->repeat) in timers_reify()
3343 ev_at (w) += w->repeat; in timers_reify()
3347 … assert (("libev: negative ev_timer repeat value found while processing timers", w->repeat > 0.)); in timers_reify()
3349 ANHE_at_cache (timers [HEAP0]); in timers_reify()
3350 downheap (timers, timercnt, HEAP0); in timers_reify()
3358 while (timercnt && ANHE_at (timers [HEAP0]) < mn_now); in timers_reify()
3369 ev_tstamp interval = w->interval > MIN_INTERVAL ? w->interval : MIN_INTERVAL; in periodic_recalc()
3370 ev_tstamp at = w->offset + interval * ev_floor ((ev_rt_now - w->offset) / interval); in periodic_recalc()
3375 ev_tstamp nat = at + w->interval; in periodic_recalc()
3405 if (w->reschedule_cb) in periodics_reify()
3407 ev_at (w) = w->reschedule_cb (w, ev_rt_now); in periodics_reify()
3414 else if (w->interval) in periodics_reify()
3444 if (w->reschedule_cb) in periodics_reschedule()
3445 ev_at (w) = w->reschedule_cb (w, ev_rt_now); in periodics_reschedule()
3446 else if (w->interval) in periodics_reschedule()
3456 /* adjust all timers by a given offset */
3464 ANHE *he = timers + i + HEAP0; in timers_reschedule()
3465 ANHE_w (*he)->at += adjust; in timers_reschedule()
3485 if (expect_true (mn_now - now_floor < MIN_TIMEJUMP * .5)) in time_update()
3499 * doesn't hurt either as we only do this on time-jumps or in time_update()
3502 for (i = 4; --i; ) in time_update()
3505 rtmn_diff = ev_rt_now - mn_now; in time_update()
3507 diff = odiff - rtmn_diff; in time_update()
3509 if (expect_true ((diff < 0. ? -diff : diff) < MIN_TIMEJUMP)) in time_update()
3518 /* timers_reschedule (EV_A_ rtmn_diff - odiff) */ in time_update()
3530 /* adjust timers. this is easy, as the offset is the same for all of them */ in time_update()
3531 timers_reschedule (EV_A_ ev_rt_now - mn_now); in time_update()
3595 /* update fd-related kernel structures */ in ev_run()
3609 /* from now on, we want a pipe-wake-up */ in ev_run()
3620 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now; in ev_run()
3627 ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now; in ev_run()
3644 sleeptime = io_blocktime - (mn_now - prev_mn_now); in ev_run()
3646 if (sleeptime > waittime - backend_mintime) in ev_run()
3647 sleeptime = waittime - backend_mintime; in ev_run()
3652 waittime -= sleeptime; in ev_run()
3678 /* queue pending timers and reschedule them */ in ev_run()
3679 timers_reify (EV_A); /* relative timers called last */ in ev_run()
3681 periodics_reify (EV_A); /* absolute timers called first */ in ev_run()
3707 --loop_depth; in ev_run()
3728 --activecnt; in ev_unref()
3749 timers_reschedule (EV_A_ mn_now - mn_prev); in ev_resume()
3757 /* singly-linked list management, used when the expected list length is short */
3762 elem->next = *head; in wlist_add()
3773 *head = elem->next; in wlist_del()
3777 head = &(*head)->next; in wlist_del()
3785 if (w->pending) in clear_pending()
3787 pendings [ABSPRI (w)][w->pending - 1].w = (W)&pending_w; in clear_pending()
3788 w->pending = 0; in clear_pending()
3796 int pending = w_->pending; in ev_clear_pending()
3800 ANPENDING *p = pendings [ABSPRI (w_)] + pending - 1; in ev_clear_pending()
3801 p->w = (W)&pending_w; in ev_clear_pending()
3802 w_->pending = 0; in ev_clear_pending()
3803 return p->events; in ev_clear_pending()
3822 w->active = active; in ev_start()
3830 w->active = 0; in ev_stop()
3838 int fd = w->fd; in ev_io_start()
3844 …assert (("libev: ev_io_start called with illegal event mask", !(w->events & ~(EV__IOFDSET | EV_REA… in ev_io_start()
3853 assert (("libev: ev_io_start called with corrupted watcher", ((WL)w)->next != (WL)w)); in ev_io_start()
3855 fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY); in ev_io_start()
3856 w->events &= ~EV__IOFDSET; in ev_io_start()
3868 …_io_stop called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax)… in ev_io_stop()
3872 wlist_del (&anfds[w->fd].head, (WL)w); in ev_io_stop()
3875 fd_change (EV_A_ w->fd, EV_ANFD_REIFY); in ev_io_stop()
3888 assert (("libev: ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); in ev_timer_start()
3893 ev_start (EV_A_ (W)w, timercnt + HEAP0 - 1); in ev_timer_start()
3894 array_needsize (ANHE, timers, timermax, ev_active (w) + 1, EMPTY2); in ev_timer_start()
3895 ANHE_w (timers [ev_active (w)]) = (WT)w; in ev_timer_start()
3896 ANHE_at_cache (timers [ev_active (w)]); in ev_timer_start()
3897 upheap (timers, ev_active (w)); in ev_timer_start()
3901 /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ in ev_timer_start()
3916 assert (("libev: internal timer heap corruption", ANHE_w (timers [active]) == (WT)w)); in ev_timer_stop()
3918 --timercnt; in ev_timer_stop()
3922 timers [active] = timers [timercnt + HEAP0]; in ev_timer_stop()
3923 adjustheap (timers, timercnt, active); in ev_timer_stop()
3927 ev_at (w) -= mn_now; in ev_timer_stop()
3943 if (w->repeat) in ev_timer_again()
3945 ev_at (w) = mn_now + w->repeat; in ev_timer_again()
3946 ANHE_at_cache (timers [ev_active (w)]); in ev_timer_again()
3947 adjustheap (timers, timercnt, ev_active (w)); in ev_timer_again()
3952 else if (w->repeat) in ev_timer_again()
3954 ev_at (w) = w->repeat; in ev_timer_again()
3964 return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); in ev_timer_remaining()
3974 if (w->reschedule_cb) in ev_periodic_start()
3975 ev_at (w) = w->reschedule_cb (w, ev_rt_now); in ev_periodic_start()
3976 else if (w->interval) in ev_periodic_start()
3978 assert (("libev: ev_periodic_start called with negative interval value", w->interval >= 0.)); in ev_periodic_start()
3982 ev_at (w) = w->offset; in ev_periodic_start()
3987 ev_start (EV_A_ (W)w, periodiccnt + HEAP0 - 1); in ev_periodic_start()
4012 --periodiccnt; in ev_periodic_stop()
4047 …assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < … in ev_signal_start()
4051 !signals [w->signum - 1].loop || signals [w->signum - 1].loop == loop)); in ev_signal_start()
4053 signals [w->signum - 1].loop = EV_A; in ev_signal_start()
4060 if (sigfd == -2) in ev_signal_start()
4062 sigfd = signalfd (-1, &sigfd_set, SFD_NONBLOCK | SFD_CLOEXEC); in ev_signal_start()
4064 sigfd = signalfd (-1, &sigfd_set, 0); /* retry without flags */ in ev_signal_start()
4082 sigaddset (&sigfd_set, w->signum); in ev_signal_start()
4090 wlist_add (&signals [w->signum - 1].head, (WL)w); in ev_signal_start()
4092 if (!((WL)w)->next) in ev_signal_start()
4100 signal (w->signum, ev_sighandler); in ev_signal_start()
4109 sigaction (w->signum, &sa, 0); in ev_signal_start()
4114 sigaddset (&sa.sa_mask, w->signum); in ev_signal_start()
4132 wlist_del (&signals [w->signum - 1].head, (WL)w); in ev_signal_stop()
4135 if (!signals [w->signum - 1].head) in ev_signal_stop()
4138 signals [w->signum - 1].loop = 0; /* unattach from signal */ in ev_signal_stop()
4146 sigaddset (&ss, w->signum); in ev_signal_stop()
4147 sigdelset (&sigfd_set, w->signum); in ev_signal_stop()
4154 signal (w->signum, SIG_DFL); in ev_signal_stop()
4176 wlist_add (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); in ev_child_start()
4190 wlist_del (&childs [w->pid & ((EV_PID_HASHSIZE) - 1)], (WL)w); in ev_child_stop()
4219 w->wd = inotify_add_watch (fs_fd, w->path, in infy_add()
4224 if (w->wd >= 0) in infy_add()
4228 /* now local changes will be tracked by inotify, but remote changes won't */ in infy_add()
4229 /* unless the filesystem is known to be local, we therefore still poll */ in infy_add()
4233 w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; in infy_add()
4234 else if (!statfs (w->path, &sfs) in infy_add()
4247 w->timer.repeat = 0.; /* filesystem is local, kernel new enough */ in infy_add()
4249 …w->timer.repeat = w->interval ? w->interval : NFS_STAT_INTERVAL; /* remote, use reduced frequency … in infy_add()
4254 w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; in infy_add()
4259 if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) in infy_add()
4262 strcpy (path, w->path); in infy_add()
4275 w->wd = inotify_add_watch (fs_fd, path, mask); in infy_add()
4277 while (w->wd < 0 && (errno == ENOENT || errno == EACCES)); in infy_add()
4281 if (w->wd >= 0) in infy_add()
4282 wlist_add (&fs_hash [w->wd & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); in infy_add()
4284 /* now re-arm timer, if required */ in infy_add()
4285 if (ev_is_active (&w->timer)) ev_ref (EV_A); in infy_add()
4286 ev_timer_again (EV_A_ &w->timer); in infy_add()
4287 if (ev_is_active (&w->timer)) ev_unref (EV_A); in infy_add()
4294 int wd = w->wd; in infy_del()
4299 w->wd = -2; in infy_del()
4300 slot = wd & ((EV_INOTIFY_HASHSIZE) - 1); in infy_del()
4318 for (w_ = fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head; w_; ) in infy_wd()
4321 w_ = w_->next; /* lets us remove this watcher and all before it */ in infy_wd()
4323 if (w->wd == wd || wd == -1) in infy_wd()
4325 if (ev->mask & (IN_IGNORED | IN_UNMOUNT | IN_DELETE_SELF)) in infy_wd()
4327 wlist_del (&fs_hash [slot & ((EV_INOTIFY_HASHSIZE) - 1)].head, (WL)w); in infy_wd()
4328 w->wd = -1; in infy_wd()
4329 infy_add (EV_A_ w); /* re-add, no matter what */ in infy_wd()
4332 stat_timer_cb (EV_A_ &w->timer, 0); in infy_wd()
4348 infy_wd (EV_A_ ev->wd, ev->wd, ev); in infy_cb()
4349 ofs += sizeof (struct inotify_event) + ev->len; in infy_cb()
4379 if (fs_fd != -2) in infy_init()
4382 fs_fd = -1; in infy_init()
4427 w_ = w_->next; /* lets us add this watcher */ in infy_fork()
4429 w->wd = -1; in infy_fork()
4432 infy_add (EV_A_ w); /* re-add, no matter what */ in infy_fork()
4435 w->timer.repeat = w->interval ? w->interval : DEF_STAT_INTERVAL; in infy_fork()
4436 if (ev_is_active (&w->timer)) ev_ref (EV_A); in infy_fork()
4437 ev_timer_again (EV_A_ &w->timer); in infy_fork()
4438 if (ev_is_active (&w->timer)) ev_unref (EV_A); in infy_fork()
4455 if (lstat (w->path, &w->attr) < 0) in ev_stat_stat()
4456 w->attr.st_nlink = 0; in ev_stat_stat()
4457 else if (!w->attr.st_nlink) in ev_stat_stat()
4458 w->attr.st_nlink = 1; in ev_stat_stat()
4464 ev_stat *w = (ev_stat *)(((char *)w_) - offsetof (ev_stat, timer)); in stat_timer_cb()
4466 ev_statdata prev = w->attr; in stat_timer_cb()
4471 prev.st_dev != w->attr.st_dev in stat_timer_cb()
4472 || prev.st_ino != w->attr.st_ino in stat_timer_cb()
4473 || prev.st_mode != w->attr.st_mode in stat_timer_cb()
4474 || prev.st_nlink != w->attr.st_nlink in stat_timer_cb()
4475 || prev.st_uid != w->attr.st_uid in stat_timer_cb()
4476 || prev.st_gid != w->attr.st_gid in stat_timer_cb()
4477 || prev.st_rdev != w->attr.st_rdev in stat_timer_cb()
4478 || prev.st_size != w->attr.st_size in stat_timer_cb()
4479 || prev.st_atime != w->attr.st_atime in stat_timer_cb()
4480 || prev.st_mtime != w->attr.st_mtime in stat_timer_cb()
4481 || prev.st_ctime != w->attr.st_ctime in stat_timer_cb()
4483 /* we only update w->prev on actual differences */ in stat_timer_cb()
4486 w->prev = prev; in stat_timer_cb()
4509 if (w->interval < MIN_STAT_INTERVAL && w->interval) in ev_stat_start()
4510 w->interval = MIN_STAT_INTERVAL; in ev_stat_start()
4512 ev_timer_init (&w->timer, stat_timer_cb, 0., w->interval ? w->interval : DEF_STAT_INTERVAL); in ev_stat_start()
4513 ev_set_priority (&w->timer, ev_priority (w)); in ev_stat_start()
4523 ev_timer_again (EV_A_ &w->timer); in ev_stat_start()
4545 if (ev_is_active (&w->timer)) in ev_stat_stop()
4548 ev_timer_stop (EV_A_ &w->timer); in ev_stat_stop()
4575 idles [ABSPRI (w)][active - 1] = w; in ev_idle_start()
4593 idles [ABSPRI (w)][active - 1] = idles [ABSPRI (w)][--idlecnt [ABSPRI (w)]]; in ev_idle_stop()
4594 ev_active (idles [ABSPRI (w)][active - 1]) = active; in ev_idle_stop()
4597 --idleall; in ev_idle_stop()
4615 prepares [preparecnt - 1] = w; in ev_prepare_start()
4632 prepares [active - 1] = prepares [--preparecnt]; in ev_prepare_stop()
4633 ev_active (prepares [active - 1]) = active; in ev_prepare_stop()
4653 checks [checkcnt - 1] = w; in ev_check_start()
4670 checks [active - 1] = checks [--checkcnt]; in ev_check_stop()
4671 ev_active (checks [active - 1]) = active; in ev_check_stop()
4684 ev_run (w->other, EVRUN_NOWAIT); in ev_embed_sweep()
4690 ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io)); in embed_io_cb()
4695 ev_run (w->other, EVRUN_NOWAIT); in embed_io_cb()
4701 ev_embed *w = (ev_embed *)(((char *)prepare) - offsetof (ev_embed, prepare)); in embed_prepare_cb()
4704 EV_P = w->other; in embed_prepare_cb()
4717 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork)); in embed_fork_cb()
4722 EV_P = w->other; in embed_fork_cb()
4746 EV_P = w->other; in ev_embed_start()
4748 ev_io_init (&w->io, embed_io_cb, backend_fd, EV_READ); in ev_embed_start()
4753 ev_set_priority (&w->io, ev_priority (w)); in ev_embed_start()
4754 ev_io_start (EV_A_ &w->io); in ev_embed_start()
4756 ev_prepare_init (&w->prepare, embed_prepare_cb); in ev_embed_start()
4757 ev_set_priority (&w->prepare, EV_MINPRI); in ev_embed_start()
4758 ev_prepare_start (EV_A_ &w->prepare); in ev_embed_start()
4760 ev_fork_init (&w->fork, embed_fork_cb); in ev_embed_start()
4761 ev_fork_start (EV_A_ &w->fork); in ev_embed_start()
4763 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ in ev_embed_start()
4779 ev_io_stop (EV_A_ &w->io); in ev_embed_stop()
4780 ev_prepare_stop (EV_A_ &w->prepare); in ev_embed_stop()
4781 ev_fork_stop (EV_A_ &w->fork); in ev_embed_stop()
4800 forks [forkcnt - 1] = w; in ev_fork_start()
4817 forks [active - 1] = forks [--forkcnt]; in ev_fork_stop()
4818 ev_active (forks [active - 1]) = active; in ev_fork_stop()
4838 cleanups [cleanupcnt - 1] = w; in ev_cleanup_start()
4858 cleanups [active - 1] = cleanups [--cleanupcnt]; in ev_cleanup_stop()
4859 ev_active (cleanups [active - 1]) = active; in ev_cleanup_stop()
4875 w->sent = 0; in ev_async_start()
4883 asyncs [asynccnt - 1] = w; in ev_async_start()
4900 asyncs [active - 1] = asyncs [--asynccnt]; in ev_async_stop()
4901 ev_active (asyncs [active - 1]) = active; in ev_async_stop()
4912 w->sent = 1; in ev_async_send()
4930 void (*cb)(int revents, void *arg) = once->cb; in once_cb()
4931 void *arg = once->arg; in once_cb()
4933 ev_io_stop (EV_A_ &once->io); in once_cb()
4934 ev_timer_stop (EV_A_ &once->to); in once_cb()
4943 struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)); in once_cb_io()
4945 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to)); in once_cb_io()
4951 struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)); in once_cb_to()
4953 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); in once_cb_to()
4967 once->cb = cb; in ev_once()
4968 once->arg = arg; in ev_once()
4970 ev_init (&once->io, once_cb_io); in ev_once()
4973 ev_io_set (&once->io, fd, events); in ev_once()
4974 ev_io_start (EV_A_ &once->io); in ev_once()
4977 ev_init (&once->to, once_cb_to); in ev_once()
4980 ev_timer_set (&once->to, timeout, 0.); in ev_once()
4981 ev_timer_start (EV_A_ &once->to); in ev_once()
4998 wn = wl->next; in ev_walk()
5004 cb (EV_A_ EV_EMBED, ((char *)wl) - offsetof (struct ev_embed, io)); in ev_walk()
5021 for (i = timercnt + HEAP0; i-- > HEAP0; ) in ev_walk()
5024 if (ev_cb ((ev_timer *)ANHE_w (timers [i])) == stat_timer_cb) in ev_walk()
5027 cb (EV_A_ EV_STAT, ((char *)ANHE_w (timers [i])) - offsetof (struct ev_stat, timer)); in ev_walk()
5032 cb (EV_A_ EV_TIMER, ANHE_w (timers [i])); in ev_walk()
5036 for (i = periodiccnt + HEAP0; i-- > HEAP0; ) in ev_walk()
5042 for (j = NUMPRI; j--; ) in ev_walk()
5043 for (i = idlecnt [j]; i--; ) in ev_walk()
5049 for (i = forkcnt; i--; ) in ev_walk()
5056 for (i = asynccnt; i--; ) in ev_walk()
5062 for (i = preparecnt; i--; ) in ev_walk()
5071 for (i = checkcnt; i--; ) in ev_walk()
5077 for (i = 0; i < EV_NSIG - 1; ++i) in ev_walk()
5080 wn = wl->next; in ev_walk()
5088 for (i = (EV_PID_HASHSIZE); i--; ) in ev_walk()
5091 wn = wl->next; in ev_walk()