ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.289 by root, Sat Jun 6 11:13:16 2009 UTC vs.
Revision 1.302 by root, Thu Jul 16 15:08:08 2009 UTC

57# endif 57# endif
58# ifndef EV_USE_MONOTONIC 58# ifndef EV_USE_MONOTONIC
59# define EV_USE_MONOTONIC 1 59# define EV_USE_MONOTONIC 1
60# endif 60# endif
61# endif 61# endif
62# elif !defined(EV_USE_CLOCK_SYSCALL)
63# define EV_USE_CLOCK_SYSCALL 0
62# endif 64# endif
63 65
64# if HAVE_CLOCK_GETTIME 66# if HAVE_CLOCK_GETTIME
65# ifndef EV_USE_MONOTONIC 67# ifndef EV_USE_MONOTONIC
66# define EV_USE_MONOTONIC 1 68# define EV_USE_MONOTONIC 1
282 284
283#ifndef EV_HEAP_CACHE_AT 285#ifndef EV_HEAP_CACHE_AT
284# define EV_HEAP_CACHE_AT !EV_MINIMAL 286# define EV_HEAP_CACHE_AT !EV_MINIMAL
285#endif 287#endif
286 288
289/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
290/* which makes programs even slower. might work on other unices, too. */
291#if EV_USE_CLOCK_SYSCALL
292# include <syscall.h>
293# ifdef SYS_clock_gettime
294# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
295# undef EV_USE_MONOTONIC
296# define EV_USE_MONOTONIC 1
297# else
298# undef EV_USE_CLOCK_SYSCALL
299# define EV_USE_CLOCK_SYSCALL 0
300# endif
301#endif
302
287/* this block fixes any misconfiguration where we know we run into trouble otherwise */ 303/* this block fixes any misconfiguration where we know we run into trouble otherwise */
288 304
289#ifndef CLOCK_MONOTONIC 305#ifndef CLOCK_MONOTONIC
290# undef EV_USE_MONOTONIC 306# undef EV_USE_MONOTONIC
291# define EV_USE_MONOTONIC 0 307# define EV_USE_MONOTONIC 0
320 336
321#if EV_SELECT_IS_WINSOCKET 337#if EV_SELECT_IS_WINSOCKET
322# include <winsock.h> 338# include <winsock.h>
323#endif 339#endif
324 340
325/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
326/* which makes programs even slower. might work on other unices, too. */
327#if EV_USE_CLOCK_SYSCALL
328# include <syscall.h>
329# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
330# undef EV_USE_MONOTONIC
331# define EV_USE_MONOTONIC 1
332#endif
333
334#if EV_USE_EVENTFD 341#if EV_USE_EVENTFD
335/* our minimum requirement is glibc 2.7 which has the stub, but not the header */ 342/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
336# include <stdint.h> 343# include <stdint.h>
337# ifdef __cplusplus 344# ifdef __cplusplus
338extern "C" { 345extern "C" {
384# define inline_speed static noinline 391# define inline_speed static noinline
385#else 392#else
386# define inline_speed static inline 393# define inline_speed static inline
387#endif 394#endif
388 395
389#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) 396#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
397
398#if EV_MINPRI == EV_MAXPRI
399# define ABSPRI(w) (((W)w), 0)
400#else
390#define ABSPRI(w) (((W)w)->priority - EV_MINPRI) 401# define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
402#endif
391 403
392#define EMPTY /* required for microsofts broken pseudo-c compiler */ 404#define EMPTY /* required for microsofts broken pseudo-c compiler */
393#define EMPTY2(a,b) /* used to suppress some warnings */ 405#define EMPTY2(a,b) /* used to suppress some warnings */
394 406
395typedef ev_watcher *W; 407typedef ev_watcher *W;
478#define ev_malloc(size) ev_realloc (0, (size)) 490#define ev_malloc(size) ev_realloc (0, (size))
479#define ev_free(ptr) ev_realloc ((ptr), 0) 491#define ev_free(ptr) ev_realloc ((ptr), 0)
480 492
481/*****************************************************************************/ 493/*****************************************************************************/
482 494
495/* set in reify when reification needed */
496#define EV_ANFD_REIFY 1
497
483/* file descriptor info structure */ 498/* file descriptor info structure */
484typedef struct 499typedef struct
485{ 500{
486 WL head; 501 WL head;
487 unsigned char events; /* the events watched for */ 502 unsigned char events; /* the events watched for */
488 unsigned char reify; /* flag set when this ANFD needs reification */ 503 unsigned char reify; /* flag set when this ANFD needs reification (EV_ANFD_REIFY, EV__IOFDSET) */
489 unsigned char emask; /* the epoll backend stores the actual kernel mask in here */ 504 unsigned char emask; /* the epoll backend stores the actual kernel mask in here */
490 unsigned char unused; 505 unsigned char unused;
491#if EV_USE_EPOLL 506#if EV_USE_EPOLL
492 unsigned int egen; /* generation counter to counter epoll bugs */ 507 unsigned int egen; /* generation counter to counter epoll bugs */
493#endif 508#endif
555 570
556 static int ev_default_loop_ptr; 571 static int ev_default_loop_ptr;
557 572
558#endif 573#endif
559 574
575#if EV_MINIMAL < 2
576# define EV_RELEASE_CB if (expect_false (release_cb)) release_cb (EV_A)
577# define EV_ACQUIRE_CB if (expect_false (acquire_cb)) acquire_cb (EV_A)
578# define EV_INVOKE_PENDING invoke_cb (EV_A)
579#else
580# define EV_RELEASE_CB (void)0
581# define EV_ACQUIRE_CB (void)0
582# define EV_INVOKE_PENDING ev_invoke_pending (EV_A)
583#endif
584
585#define EVUNLOOP_RECURSE 0x80
586
560/*****************************************************************************/ 587/*****************************************************************************/
561 588
589#ifndef EV_HAVE_EV_TIME
562ev_tstamp 590ev_tstamp
563ev_time (void) 591ev_time (void)
564{ 592{
565#if EV_USE_REALTIME 593#if EV_USE_REALTIME
566 if (expect_true (have_realtime)) 594 if (expect_true (have_realtime))
573 601
574 struct timeval tv; 602 struct timeval tv;
575 gettimeofday (&tv, 0); 603 gettimeofday (&tv, 0);
576 return tv.tv_sec + tv.tv_usec * 1e-6; 604 return tv.tv_sec + tv.tv_usec * 1e-6;
577} 605}
606#endif
578 607
579inline_size ev_tstamp 608inline_size ev_tstamp
580get_clock (void) 609get_clock (void)
581{ 610{
582#if EV_USE_MONOTONIC 611#if EV_USE_MONOTONIC
618 647
619 tv.tv_sec = (time_t)delay; 648 tv.tv_sec = (time_t)delay;
620 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); 649 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
621 650
622 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ 651 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
623 /* somehting nto guaranteed by newer posix versions, but guaranteed */ 652 /* something not guaranteed by newer posix versions, but guaranteed */
624 /* by older ones */ 653 /* by older ones */
625 select (0, 0, 0, 0, &tv); 654 select (0, 0, 0, 0, &tv);
626#endif 655#endif
627 } 656 }
628} 657}
736} 765}
737 766
738/*****************************************************************************/ 767/*****************************************************************************/
739 768
740inline_speed void 769inline_speed void
741fd_event (EV_P_ int fd, int revents) 770fd_event_nc (EV_P_ int fd, int revents)
742{ 771{
743 ANFD *anfd = anfds + fd; 772 ANFD *anfd = anfds + fd;
744 ev_io *w; 773 ev_io *w;
745 774
746 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next) 775 for (w = (ev_io *)anfd->head; w; w = (ev_io *)((WL)w)->next)
750 if (ev) 779 if (ev)
751 ev_feed_event (EV_A_ (W)w, ev); 780 ev_feed_event (EV_A_ (W)w, ev);
752 } 781 }
753} 782}
754 783
784/* do not submit kernel events for fds that have reify set */
785/* because that means they changed while we were polling for new events */
786inline_speed void
787fd_event (EV_P_ int fd, int revents)
788{
789 ANFD *anfd = anfds + fd;
790
791 if (expect_true (!anfd->reify))
792 fd_event_nc (EV_A_ fd, revents);
793}
794
755void 795void
756ev_feed_fd_event (EV_P_ int fd, int revents) 796ev_feed_fd_event (EV_P_ int fd, int revents)
757{ 797{
758 if (fd >= 0 && fd < anfdmax) 798 if (fd >= 0 && fd < anfdmax)
759 fd_event (EV_A_ fd, revents); 799 fd_event_nc (EV_A_ fd, revents);
760} 800}
761 801
762/* make sure the external fd watch events are in-sync */ 802/* make sure the external fd watch events are in-sync */
763/* with the kernel/libev internal state */ 803/* with the kernel/libev internal state */
764inline_size void 804inline_size void
879 for (fd = 0; fd < anfdmax; ++fd) 919 for (fd = 0; fd < anfdmax; ++fd)
880 if (anfds [fd].events) 920 if (anfds [fd].events)
881 { 921 {
882 anfds [fd].events = 0; 922 anfds [fd].events = 0;
883 anfds [fd].emask = 0; 923 anfds [fd].emask = 0;
884 fd_change (EV_A_ fd, EV__IOFDSET | 1); 924 fd_change (EV_A_ fd, EV__IOFDSET | EV_ANFD_REIFY);
885 } 925 }
886} 926}
887 927
888/*****************************************************************************/ 928/*****************************************************************************/
889 929
1343ev_backend (EV_P) 1383ev_backend (EV_P)
1344{ 1384{
1345 return backend; 1385 return backend;
1346} 1386}
1347 1387
1388#if EV_MINIMAL < 2
1348unsigned int 1389unsigned int
1349ev_loop_count (EV_P) 1390ev_loop_count (EV_P)
1350{ 1391{
1351 return loop_count; 1392 return loop_count;
1352} 1393}
1353 1394
1395unsigned int
1396ev_loop_depth (EV_P)
1397{
1398 return loop_depth;
1399}
1400
1354void 1401void
1355ev_set_io_collect_interval (EV_P_ ev_tstamp interval) 1402ev_set_io_collect_interval (EV_P_ ev_tstamp interval)
1356{ 1403{
1357 io_blocktime = interval; 1404 io_blocktime = interval;
1358} 1405}
1360void 1407void
1361ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) 1408ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval)
1362{ 1409{
1363 timeout_blocktime = interval; 1410 timeout_blocktime = interval;
1364} 1411}
1412
1413void
1414ev_set_userdata (EV_P_ void *data)
1415{
1416 userdata = data;
1417}
1418
1419void *
1420ev_userdata (EV_P)
1421{
1422 return userdata;
1423}
1424
1425void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P))
1426{
1427 invoke_cb = invoke_pending_cb;
1428}
1429
1430void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P))
1431{
1432 release_cb = release;
1433 acquire_cb = acquire;
1434}
1435#endif
1365 1436
1366/* initialise a loop structure, must be zero-initialised */ 1437/* initialise a loop structure, must be zero-initialised */
1367static void noinline 1438static void noinline
1368loop_init (EV_P_ unsigned int flags) 1439loop_init (EV_P_ unsigned int flags)
1369{ 1440{
1391 1462
1392 ev_rt_now = ev_time (); 1463 ev_rt_now = ev_time ();
1393 mn_now = get_clock (); 1464 mn_now = get_clock ();
1394 now_floor = mn_now; 1465 now_floor = mn_now;
1395 rtmn_diff = ev_rt_now - mn_now; 1466 rtmn_diff = ev_rt_now - mn_now;
1467#if EV_MINIMAL < 2
1468 invoke_cb = ev_invoke_pending;
1469#endif
1396 1470
1397 io_blocktime = 0.; 1471 io_blocktime = 0.;
1398 timeout_blocktime = 0.; 1472 timeout_blocktime = 0.;
1399 backend = 0; 1473 backend = 0;
1400 backend_fd = -1; 1474 backend_fd = -1;
1594void 1668void
1595ev_loop_fork (EV_P) 1669ev_loop_fork (EV_P)
1596{ 1670{
1597 postfork = 1; /* must be in line with ev_default_fork */ 1671 postfork = 1; /* must be in line with ev_default_fork */
1598} 1672}
1673#endif /* multiplicity */
1599 1674
1600#if EV_VERIFY 1675#if EV_VERIFY
1601static void noinline 1676static void noinline
1602verify_watcher (EV_P_ W w) 1677verify_watcher (EV_P_ W w)
1603{ 1678{
1631 verify_watcher (EV_A_ ws [cnt]); 1706 verify_watcher (EV_A_ ws [cnt]);
1632 } 1707 }
1633} 1708}
1634#endif 1709#endif
1635 1710
1711#if EV_MINIMAL < 2
1636void 1712void
1637ev_loop_verify (EV_P) 1713ev_loop_verify (EV_P)
1638{ 1714{
1639#if EV_VERIFY 1715#if EV_VERIFY
1640 int i; 1716 int i;
1693 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next) 1769 for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
1694 for (signum = signalmax; signum--; ) if (signals [signum].gotsig) 1770 for (signum = signalmax; signum--; ) if (signals [signum].gotsig)
1695# endif 1771# endif
1696#endif 1772#endif
1697} 1773}
1698 1774#endif
1699#endif /* multiplicity */
1700 1775
1701#if EV_MULTIPLICITY 1776#if EV_MULTIPLICITY
1702struct ev_loop * 1777struct ev_loop *
1703ev_default_loop_init (unsigned int flags) 1778ev_default_loop_init (unsigned int flags)
1704#else 1779#else
1765ev_invoke (EV_P_ void *w, int revents) 1840ev_invoke (EV_P_ void *w, int revents)
1766{ 1841{
1767 EV_CB_INVOKE ((W)w, revents); 1842 EV_CB_INVOKE ((W)w, revents);
1768} 1843}
1769 1844
1770inline_speed void 1845unsigned int
1771call_pending (EV_P) 1846ev_pending_count (EV_P)
1847{
1848 int pri;
1849 unsigned int count = 0;
1850
1851 for (pri = NUMPRI; pri--; )
1852 count += pendingcnt [pri];
1853
1854 return count;
1855}
1856
1857void noinline
1858ev_invoke_pending (EV_P)
1772{ 1859{
1773 int pri; 1860 int pri;
1774 1861
1775 for (pri = NUMPRI; pri--; ) 1862 for (pri = NUMPRI; pri--; )
1776 while (pendingcnt [pri]) 1863 while (pendingcnt [pri])
2011 2098
2012 mn_now = ev_rt_now; 2099 mn_now = ev_rt_now;
2013 } 2100 }
2014} 2101}
2015 2102
2016static int loop_done;
2017
2018void 2103void
2019ev_loop (EV_P_ int flags) 2104ev_loop (EV_P_ int flags)
2020{ 2105{
2106#if EV_MINIMAL < 2
2107 ++loop_depth;
2108#endif
2109
2110 assert (("libev: ev_loop recursion during release detected", loop_done != EVUNLOOP_RECURSE));
2111
2021 loop_done = EVUNLOOP_CANCEL; 2112 loop_done = EVUNLOOP_CANCEL;
2022 2113
2023 call_pending (EV_A); /* in case we recurse, ensure ordering stays nice and clean */ 2114 EV_INVOKE_PENDING; /* in case we recurse, ensure ordering stays nice and clean */
2024 2115
2025 do 2116 do
2026 { 2117 {
2027#if EV_VERIFY >= 2 2118#if EV_VERIFY >= 2
2028 ev_loop_verify (EV_A); 2119 ev_loop_verify (EV_A);
2041 /* we might have forked, so queue fork handlers */ 2132 /* we might have forked, so queue fork handlers */
2042 if (expect_false (postfork)) 2133 if (expect_false (postfork))
2043 if (forkcnt) 2134 if (forkcnt)
2044 { 2135 {
2045 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK); 2136 queue_events (EV_A_ (W *)forks, forkcnt, EV_FORK);
2046 call_pending (EV_A); 2137 EV_INVOKE_PENDING;
2047 } 2138 }
2048#endif 2139#endif
2049 2140
2050 /* queue prepare watchers (and execute them) */ 2141 /* queue prepare watchers (and execute them) */
2051 if (expect_false (preparecnt)) 2142 if (expect_false (preparecnt))
2052 { 2143 {
2053 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE); 2144 queue_events (EV_A_ (W *)prepares, preparecnt, EV_PREPARE);
2054 call_pending (EV_A); 2145 EV_INVOKE_PENDING;
2055 } 2146 }
2147
2148 if (expect_false (loop_done))
2149 break;
2056 2150
2057 /* we might have forked, so reify kernel state if necessary */ 2151 /* we might have forked, so reify kernel state if necessary */
2058 if (expect_false (postfork)) 2152 if (expect_false (postfork))
2059 loop_fork (EV_A); 2153 loop_fork (EV_A);
2060 2154
2066 ev_tstamp waittime = 0.; 2160 ev_tstamp waittime = 0.;
2067 ev_tstamp sleeptime = 0.; 2161 ev_tstamp sleeptime = 0.;
2068 2162
2069 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt))) 2163 if (expect_true (!(flags & EVLOOP_NONBLOCK || idleall || !activecnt)))
2070 { 2164 {
2165 /* remember old timestamp for io_blocktime calculation */
2166 ev_tstamp prev_mn_now = mn_now;
2167
2071 /* update time to cancel out callback processing overhead */ 2168 /* update time to cancel out callback processing overhead */
2072 time_update (EV_A_ 1e100); 2169 time_update (EV_A_ 1e100);
2073 2170
2074 waittime = MAX_BLOCKTIME; 2171 waittime = MAX_BLOCKTIME;
2075 2172
2085 ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge; 2182 ev_tstamp to = ANHE_at (periodics [HEAP0]) - ev_rt_now + backend_fudge;
2086 if (waittime > to) waittime = to; 2183 if (waittime > to) waittime = to;
2087 } 2184 }
2088#endif 2185#endif
2089 2186
2187 /* don't let timeouts decrease the waittime below timeout_blocktime */
2090 if (expect_false (waittime < timeout_blocktime)) 2188 if (expect_false (waittime < timeout_blocktime))
2091 waittime = timeout_blocktime; 2189 waittime = timeout_blocktime;
2092 2190
2093 sleeptime = waittime - backend_fudge; 2191 /* extra check because io_blocktime is commonly 0 */
2094
2095 if (expect_true (sleeptime > io_blocktime)) 2192 if (expect_false (io_blocktime))
2096 sleeptime = io_blocktime;
2097
2098 if (sleeptime)
2099 { 2193 {
2194 sleeptime = io_blocktime - (mn_now - prev_mn_now);
2195
2196 if (sleeptime > waittime - backend_fudge)
2197 sleeptime = waittime - backend_fudge;
2198
2199 if (expect_true (sleeptime > 0.))
2200 {
2100 ev_sleep (sleeptime); 2201 ev_sleep (sleeptime);
2101 waittime -= sleeptime; 2202 waittime -= sleeptime;
2203 }
2102 } 2204 }
2103 } 2205 }
2104 2206
2207#if EV_MINIMAL < 2
2105 ++loop_count; 2208 ++loop_count;
2209#endif
2210 assert ((loop_done = EVUNLOOP_RECURSE, 1)); /* assert for side effect */
2106 backend_poll (EV_A_ waittime); 2211 backend_poll (EV_A_ waittime);
2212 assert ((loop_done = EVUNLOOP_CANCEL, 1)); /* assert for side effect */
2107 2213
2108 /* update ev_rt_now, do magic */ 2214 /* update ev_rt_now, do magic */
2109 time_update (EV_A_ waittime + sleeptime); 2215 time_update (EV_A_ waittime + sleeptime);
2110 } 2216 }
2111 2217
2122 2228
2123 /* queue check watchers, to be executed first */ 2229 /* queue check watchers, to be executed first */
2124 if (expect_false (checkcnt)) 2230 if (expect_false (checkcnt))
2125 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 2231 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
2126 2232
2127 call_pending (EV_A); 2233 EV_INVOKE_PENDING;
2128 } 2234 }
2129 while (expect_true ( 2235 while (expect_true (
2130 activecnt 2236 activecnt
2131 && !loop_done 2237 && !loop_done
2132 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK)) 2238 && !(flags & (EVLOOP_ONESHOT | EVLOOP_NONBLOCK))
2133 )); 2239 ));
2134 2240
2135 if (loop_done == EVUNLOOP_ONE) 2241 if (loop_done == EVUNLOOP_ONE)
2136 loop_done = EVUNLOOP_CANCEL; 2242 loop_done = EVUNLOOP_CANCEL;
2243
2244#if EV_MINIMAL < 2
2245 --loop_depth;
2246#endif
2137} 2247}
2138 2248
2139void 2249void
2140ev_unloop (EV_P_ int how) 2250ev_unloop (EV_P_ int how)
2141{ 2251{
2233} 2343}
2234 2344
2235inline_size void 2345inline_size void
2236pri_adjust (EV_P_ W w) 2346pri_adjust (EV_P_ W w)
2237{ 2347{
2238 int pri = w->priority; 2348 int pri = ev_priority (w);
2239 pri = pri < EV_MINPRI ? EV_MINPRI : pri; 2349 pri = pri < EV_MINPRI ? EV_MINPRI : pri;
2240 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri; 2350 pri = pri > EV_MAXPRI ? EV_MAXPRI : pri;
2241 w->priority = pri; 2351 ev_set_priority (w, pri);
2242} 2352}
2243 2353
2244inline_speed void 2354inline_speed void
2245ev_start (EV_P_ W w, int active) 2355ev_start (EV_P_ W w, int active)
2246{ 2356{
2273 2383
2274 ev_start (EV_A_ (W)w, 1); 2384 ev_start (EV_A_ (W)w, 1);
2275 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero); 2385 array_needsize (ANFD, anfds, anfdmax, fd + 1, array_init_zero);
2276 wlist_add (&anfds[fd].head, (WL)w); 2386 wlist_add (&anfds[fd].head, (WL)w);
2277 2387
2278 fd_change (EV_A_ fd, w->events & EV__IOFDSET | 1); 2388 fd_change (EV_A_ fd, w->events & EV__IOFDSET | EV_ANFD_REIFY);
2279 w->events &= ~EV__IOFDSET; 2389 w->events &= ~EV__IOFDSET;
2280 2390
2281 EV_FREQUENT_CHECK; 2391 EV_FREQUENT_CHECK;
2282} 2392}
2283 2393
2377 } 2487 }
2378 2488
2379 EV_FREQUENT_CHECK; 2489 EV_FREQUENT_CHECK;
2380} 2490}
2381 2491
2492ev_tstamp
2493ev_timer_remaining (EV_P_ ev_timer *w)
2494{
2495 return ev_at (w) - (ev_is_active (w) ? mn_now : 0.);
2496}
2497
2382#if EV_PERIODIC_ENABLE 2498#if EV_PERIODIC_ENABLE
2383void noinline 2499void noinline
2384ev_periodic_start (EV_P_ ev_periodic *w) 2500ev_periodic_start (EV_P_ ev_periodic *w)
2385{ 2501{
2386 if (expect_false (ev_is_active (w))) 2502 if (expect_false (ev_is_active (w)))
2487 if (!((WL)w)->next) 2603 if (!((WL)w)->next)
2488 { 2604 {
2489#if _WIN32 2605#if _WIN32
2490 signal (w->signum, ev_sighandler); 2606 signal (w->signum, ev_sighandler);
2491#else 2607#else
2492 struct sigaction sa; 2608 struct sigaction sa = { };
2493 sa.sa_handler = ev_sighandler; 2609 sa.sa_handler = ev_sighandler;
2494 sigfillset (&sa.sa_mask); 2610 sigfillset (&sa.sa_mask);
2495 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ 2611 sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */
2496 sigaction (w->signum, &sa, 0); 2612 sigaction (w->signum, &sa, 0);
2497#endif 2613#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines