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

Comparing libev/ev.c (file contents):
Revision 1.419 by root, Thu Apr 12 04:10:15 2012 UTC vs.
Revision 1.424 by root, Tue May 1 22:01:40 2012 UTC

359#endif 359#endif
360 360
361/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ 361/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */
362/* which makes programs even slower. might work on other unices, too. */ 362/* which makes programs even slower. might work on other unices, too. */
363#if EV_USE_CLOCK_SYSCALL 363#if EV_USE_CLOCK_SYSCALL
364# include <syscall.h> 364# include <sys/syscall.h>
365# ifdef SYS_clock_gettime 365# ifdef SYS_clock_gettime
366# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) 366# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
367# undef EV_USE_MONOTONIC 367# undef EV_USE_MONOTONIC
368# define EV_USE_MONOTONIC 1 368# define EV_USE_MONOTONIC 1
369# else 369# else
1105{ 1105{
1106 write (STDERR_FILENO, msg, strlen (msg)); 1106 write (STDERR_FILENO, msg, strlen (msg));
1107} 1107}
1108#endif 1108#endif
1109 1109
1110static void (*syserr_cb)(const char *msg); 1110static void (*syserr_cb)(const char *msg) EV_THROW;
1111 1111
1112void ecb_cold 1112void ecb_cold
1113ev_set_syserr_cb (void (*cb)(const char *msg)) 1113ev_set_syserr_cb (void (*cb)(const char *msg)) EV_THROW
1114{ 1114{
1115 syserr_cb = cb; 1115 syserr_cb = cb;
1116} 1116}
1117 1117
1118static void noinline ecb_cold 1118static void noinline ecb_cold
1154 free (ptr); 1154 free (ptr);
1155 return 0; 1155 return 0;
1156#endif 1156#endif
1157} 1157}
1158 1158
1159static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; 1159static void *(*alloc)(void *ptr, long size) EV_THROW = ev_realloc_emul;
1160 1160
1161void ecb_cold 1161void ecb_cold
1162ev_set_allocator (void *(*cb)(void *ptr, long size)) 1162ev_set_allocator (void *(*cb)(void *ptr, long size)) EV_THROW
1163{ 1163{
1164 alloc = cb; 1164 alloc = cb;
1165} 1165}
1166 1166
1167inline_speed void * 1167inline_speed void *
1284 1284
1285/*****************************************************************************/ 1285/*****************************************************************************/
1286 1286
1287#ifndef EV_HAVE_EV_TIME 1287#ifndef EV_HAVE_EV_TIME
1288ev_tstamp 1288ev_tstamp
1289ev_time (void) 1289ev_time (void) EV_THROW
1290{ 1290{
1291#if EV_USE_REALTIME 1291#if EV_USE_REALTIME
1292 if (expect_true (have_realtime)) 1292 if (expect_true (have_realtime))
1293 { 1293 {
1294 struct timespec ts; 1294 struct timespec ts;
1318 return ev_time (); 1318 return ev_time ();
1319} 1319}
1320 1320
1321#if EV_MULTIPLICITY 1321#if EV_MULTIPLICITY
1322ev_tstamp 1322ev_tstamp
1323ev_now (EV_P) 1323ev_now (EV_P) EV_THROW
1324{ 1324{
1325 return ev_rt_now; 1325 return ev_rt_now;
1326} 1326}
1327#endif 1327#endif
1328 1328
1329void 1329void
1330ev_sleep (ev_tstamp delay) 1330ev_sleep (ev_tstamp delay) EV_THROW
1331{ 1331{
1332 if (delay > 0.) 1332 if (delay > 0.)
1333 { 1333 {
1334#if EV_USE_NANOSLEEP 1334#if EV_USE_NANOSLEEP
1335 struct timespec ts; 1335 struct timespec ts;
1416pendingcb (EV_P_ ev_prepare *w, int revents) 1416pendingcb (EV_P_ ev_prepare *w, int revents)
1417{ 1417{
1418} 1418}
1419 1419
1420void noinline 1420void noinline
1421ev_feed_event (EV_P_ void *w, int revents) 1421ev_feed_event (EV_P_ void *w, int revents) EV_THROW
1422{ 1422{
1423 W w_ = (W)w; 1423 W w_ = (W)w;
1424 int pri = ABSPRI (w_); 1424 int pri = ABSPRI (w_);
1425 1425
1426 if (expect_false (w_->pending)) 1426 if (expect_false (w_->pending))
1485 if (expect_true (!anfd->reify)) 1485 if (expect_true (!anfd->reify))
1486 fd_event_nocheck (EV_A_ fd, revents); 1486 fd_event_nocheck (EV_A_ fd, revents);
1487} 1487}
1488 1488
1489void 1489void
1490ev_feed_fd_event (EV_P_ int fd, int revents) 1490ev_feed_fd_event (EV_P_ int fd, int revents) EV_THROW
1491{ 1491{
1492 if (fd >= 0 && fd < anfdmax) 1492 if (fd >= 0 && fd < anfdmax)
1493 fd_event_nocheck (EV_A_ fd, revents); 1493 fd_event_nocheck (EV_A_ fd, revents);
1494} 1494}
1495 1495
1844} 1844}
1845 1845
1846inline_speed void 1846inline_speed void
1847evpipe_write (EV_P_ EV_ATOMIC_T *flag) 1847evpipe_write (EV_P_ EV_ATOMIC_T *flag)
1848{ 1848{
1849 ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */
1850
1849 if (expect_true (*flag)) 1851 if (expect_true (*flag))
1850 return; 1852 return;
1851 1853
1852 *flag = 1; 1854 *flag = 1;
1853 1855
1912 } 1914 }
1913 } 1915 }
1914 1916
1915 pipe_write_skipped = 0; 1917 pipe_write_skipped = 0;
1916 1918
1919 ECB_MEMORY_FENCE; /* push out skipped, acquire flags */
1920
1917#if EV_SIGNAL_ENABLE 1921#if EV_SIGNAL_ENABLE
1918 if (sig_pending) 1922 if (sig_pending)
1919 { 1923 {
1920 sig_pending = 0; 1924 sig_pending = 0;
1925
1926 ECB_MEMORY_FENCE_RELEASE;
1921 1927
1922 for (i = EV_NSIG - 1; i--; ) 1928 for (i = EV_NSIG - 1; i--; )
1923 if (expect_false (signals [i].pending)) 1929 if (expect_false (signals [i].pending))
1924 ev_feed_signal_event (EV_A_ i + 1); 1930 ev_feed_signal_event (EV_A_ i + 1);
1925 } 1931 }
1927 1933
1928#if EV_ASYNC_ENABLE 1934#if EV_ASYNC_ENABLE
1929 if (async_pending) 1935 if (async_pending)
1930 { 1936 {
1931 async_pending = 0; 1937 async_pending = 0;
1938
1939 ECB_MEMORY_FENCE_RELEASE;
1932 1940
1933 for (i = asynccnt; i--; ) 1941 for (i = asynccnt; i--; )
1934 if (asyncs [i]->sent) 1942 if (asyncs [i]->sent)
1935 { 1943 {
1936 asyncs [i]->sent = 0; 1944 asyncs [i]->sent = 0;
1941} 1949}
1942 1950
1943/*****************************************************************************/ 1951/*****************************************************************************/
1944 1952
1945void 1953void
1946ev_feed_signal (int signum) 1954ev_feed_signal (int signum) EV_THROW
1947{ 1955{
1948#if EV_MULTIPLICITY 1956#if EV_MULTIPLICITY
1949 EV_P = signals [signum - 1].loop; 1957 EV_P = signals [signum - 1].loop;
1950 1958
1951 if (!EV_A) 1959 if (!EV_A)
1968 1976
1969 ev_feed_signal (signum); 1977 ev_feed_signal (signum);
1970} 1978}
1971 1979
1972void noinline 1980void noinline
1973ev_feed_signal_event (EV_P_ int signum) 1981ev_feed_signal_event (EV_P_ int signum) EV_THROW
1974{ 1982{
1975 WL w; 1983 WL w;
1976 1984
1977 if (expect_false (signum <= 0 || signum > EV_NSIG)) 1985 if (expect_false (signum <= 0 || signum > EV_NSIG))
1978 return; 1986 return;
2094#if EV_USE_SELECT 2102#if EV_USE_SELECT
2095# include "ev_select.c" 2103# include "ev_select.c"
2096#endif 2104#endif
2097 2105
2098int ecb_cold 2106int ecb_cold
2099ev_version_major (void) 2107ev_version_major (void) EV_THROW
2100{ 2108{
2101 return EV_VERSION_MAJOR; 2109 return EV_VERSION_MAJOR;
2102} 2110}
2103 2111
2104int ecb_cold 2112int ecb_cold
2105ev_version_minor (void) 2113ev_version_minor (void) EV_THROW
2106{ 2114{
2107 return EV_VERSION_MINOR; 2115 return EV_VERSION_MINOR;
2108} 2116}
2109 2117
2110/* return true if we are running with elevated privileges and should ignore env variables */ 2118/* return true if we are running with elevated privileges and should ignore env variables */
2118 || getgid () != getegid (); 2126 || getgid () != getegid ();
2119#endif 2127#endif
2120} 2128}
2121 2129
2122unsigned int ecb_cold 2130unsigned int ecb_cold
2123ev_supported_backends (void) 2131ev_supported_backends (void) EV_THROW
2124{ 2132{
2125 unsigned int flags = 0; 2133 unsigned int flags = 0;
2126 2134
2127 if (EV_USE_PORT ) flags |= EVBACKEND_PORT; 2135 if (EV_USE_PORT ) flags |= EVBACKEND_PORT;
2128 if (EV_USE_KQUEUE) flags |= EVBACKEND_KQUEUE; 2136 if (EV_USE_KQUEUE) flags |= EVBACKEND_KQUEUE;
2132 2140
2133 return flags; 2141 return flags;
2134} 2142}
2135 2143
2136unsigned int ecb_cold 2144unsigned int ecb_cold
2137ev_recommended_backends (void) 2145ev_recommended_backends (void) EV_THROW
2138{ 2146{
2139 unsigned int flags = ev_supported_backends (); 2147 unsigned int flags = ev_supported_backends ();
2140 2148
2141#ifndef __NetBSD__ 2149#ifndef __NetBSD__
2142 /* kqueue is borked on everything but netbsd apparently */ 2150 /* kqueue is borked on everything but netbsd apparently */
2154 2162
2155 return flags; 2163 return flags;
2156} 2164}
2157 2165
2158unsigned int ecb_cold 2166unsigned int ecb_cold
2159ev_embeddable_backends (void) 2167ev_embeddable_backends (void) EV_THROW
2160{ 2168{
2161 int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; 2169 int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT;
2162 2170
2163 /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ 2171 /* epoll embeddability broken on all linux versions up to at least 2.6.23 */
2164 if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */ 2172 if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */
2166 2174
2167 return flags; 2175 return flags;
2168} 2176}
2169 2177
2170unsigned int 2178unsigned int
2171ev_backend (EV_P) 2179ev_backend (EV_P) EV_THROW
2172{ 2180{
2173 return backend; 2181 return backend;
2174} 2182}
2175 2183
2176#if EV_FEATURE_API 2184#if EV_FEATURE_API
2177unsigned int 2185unsigned int
2178ev_iteration (EV_P) 2186ev_iteration (EV_P) EV_THROW
2179{ 2187{
2180 return loop_count; 2188 return loop_count;
2181} 2189}
2182 2190
2183unsigned int 2191unsigned int
2184ev_depth (EV_P) 2192ev_depth (EV_P) EV_THROW
2185{ 2193{
2186 return loop_depth; 2194 return loop_depth;
2187} 2195}
2188 2196
2189void 2197void
2190ev_set_io_collect_interval (EV_P_ ev_tstamp interval) 2198ev_set_io_collect_interval (EV_P_ ev_tstamp interval) EV_THROW
2191{ 2199{
2192 io_blocktime = interval; 2200 io_blocktime = interval;
2193} 2201}
2194 2202
2195void 2203void
2196ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) 2204ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_THROW
2197{ 2205{
2198 timeout_blocktime = interval; 2206 timeout_blocktime = interval;
2199} 2207}
2200 2208
2201void 2209void
2202ev_set_userdata (EV_P_ void *data) 2210ev_set_userdata (EV_P_ void *data) EV_THROW
2203{ 2211{
2204 userdata = data; 2212 userdata = data;
2205} 2213}
2206 2214
2207void * 2215void *
2208ev_userdata (EV_P) 2216ev_userdata (EV_P) EV_THROW
2209{ 2217{
2210 return userdata; 2218 return userdata;
2211} 2219}
2212 2220
2213void 2221void
2214ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)) 2222ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)) EV_THROW
2215{ 2223{
2216 invoke_cb = invoke_pending_cb; 2224 invoke_cb = invoke_pending_cb;
2217} 2225}
2218 2226
2219void 2227void
2220ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P)) 2228ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW
2221{ 2229{
2222 release_cb = release; 2230 release_cb = release;
2223 acquire_cb = acquire; 2231 acquire_cb = acquire;
2224} 2232}
2225#endif 2233#endif
2226 2234
2227/* initialise a loop structure, must be zero-initialised */ 2235/* initialise a loop structure, must be zero-initialised */
2228static void noinline ecb_cold 2236static void noinline ecb_cold
2229loop_init (EV_P_ unsigned int flags) 2237loop_init (EV_P_ unsigned int flags) EV_THROW
2230{ 2238{
2231 if (!backend) 2239 if (!backend)
2232 { 2240 {
2233 origflags = flags; 2241 origflags = flags;
2234 2242
2487} 2495}
2488 2496
2489#if EV_MULTIPLICITY 2497#if EV_MULTIPLICITY
2490 2498
2491struct ev_loop * ecb_cold 2499struct ev_loop * ecb_cold
2492ev_loop_new (unsigned int flags) 2500ev_loop_new (unsigned int flags) EV_THROW
2493{ 2501{
2494 EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop)); 2502 EV_P = (struct ev_loop *)ev_malloc (sizeof (struct ev_loop));
2495 2503
2496 memset (EV_A, 0, sizeof (struct ev_loop)); 2504 memset (EV_A, 0, sizeof (struct ev_loop));
2497 loop_init (EV_A_ flags); 2505 loop_init (EV_A_ flags);
2541} 2549}
2542#endif 2550#endif
2543 2551
2544#if EV_FEATURE_API 2552#if EV_FEATURE_API
2545void ecb_cold 2553void ecb_cold
2546ev_verify (EV_P) 2554ev_verify (EV_P) EV_THROW
2547{ 2555{
2548#if EV_VERIFY 2556#if EV_VERIFY
2549 int i; 2557 int i;
2550 WL w; 2558 WL w;
2551 2559
2620#if EV_MULTIPLICITY 2628#if EV_MULTIPLICITY
2621struct ev_loop * ecb_cold 2629struct ev_loop * ecb_cold
2622#else 2630#else
2623int 2631int
2624#endif 2632#endif
2625ev_default_loop (unsigned int flags) 2633ev_default_loop (unsigned int flags) EV_THROW
2626{ 2634{
2627 if (!ev_default_loop_ptr) 2635 if (!ev_default_loop_ptr)
2628 { 2636 {
2629#if EV_MULTIPLICITY 2637#if EV_MULTIPLICITY
2630 EV_P = ev_default_loop_ptr = &default_loop_struct; 2638 EV_P = ev_default_loop_ptr = &default_loop_struct;
2649 2657
2650 return ev_default_loop_ptr; 2658 return ev_default_loop_ptr;
2651} 2659}
2652 2660
2653void 2661void
2654ev_loop_fork (EV_P) 2662ev_loop_fork (EV_P) EV_THROW
2655{ 2663{
2656 postfork = 1; /* must be in line with ev_default_fork */ 2664 postfork = 1; /* must be in line with ev_default_fork */
2657} 2665}
2658 2666
2659/*****************************************************************************/ 2667/*****************************************************************************/
2663{ 2671{
2664 EV_CB_INVOKE ((W)w, revents); 2672 EV_CB_INVOKE ((W)w, revents);
2665} 2673}
2666 2674
2667unsigned int 2675unsigned int
2668ev_pending_count (EV_P) 2676ev_pending_count (EV_P) EV_THROW
2669{ 2677{
2670 int pri; 2678 int pri;
2671 unsigned int count = 0; 2679 unsigned int count = 0;
2672 2680
2673 for (pri = NUMPRI; pri--; ) 2681 for (pri = NUMPRI; pri--; )
3104 3112
3105 return activecnt; 3113 return activecnt;
3106} 3114}
3107 3115
3108void 3116void
3109ev_break (EV_P_ int how) 3117ev_break (EV_P_ int how) EV_THROW
3110{ 3118{
3111 loop_done = how; 3119 loop_done = how;
3112} 3120}
3113 3121
3114void 3122void
3115ev_ref (EV_P) 3123ev_ref (EV_P) EV_THROW
3116{ 3124{
3117 ++activecnt; 3125 ++activecnt;
3118} 3126}
3119 3127
3120void 3128void
3121ev_unref (EV_P) 3129ev_unref (EV_P) EV_THROW
3122{ 3130{
3123 --activecnt; 3131 --activecnt;
3124} 3132}
3125 3133
3126void 3134void
3127ev_now_update (EV_P) 3135ev_now_update (EV_P) EV_THROW
3128{ 3136{
3129 time_update (EV_A_ 1e100); 3137 time_update (EV_A_ 1e100);
3130} 3138}
3131 3139
3132void 3140void
3133ev_suspend (EV_P) 3141ev_suspend (EV_P) EV_THROW
3134{ 3142{
3135 ev_now_update (EV_A); 3143 ev_now_update (EV_A);
3136} 3144}
3137 3145
3138void 3146void
3139ev_resume (EV_P) 3147ev_resume (EV_P) EV_THROW
3140{ 3148{
3141 ev_tstamp mn_prev = mn_now; 3149 ev_tstamp mn_prev = mn_now;
3142 3150
3143 ev_now_update (EV_A); 3151 ev_now_update (EV_A);
3144 timers_reschedule (EV_A_ mn_now - mn_prev); 3152 timers_reschedule (EV_A_ mn_now - mn_prev);
3183 w->pending = 0; 3191 w->pending = 0;
3184 } 3192 }
3185} 3193}
3186 3194
3187int 3195int
3188ev_clear_pending (EV_P_ void *w) 3196ev_clear_pending (EV_P_ void *w) EV_THROW
3189{ 3197{
3190 W w_ = (W)w; 3198 W w_ = (W)w;
3191 int pending = w_->pending; 3199 int pending = w_->pending;
3192 3200
3193 if (expect_true (pending)) 3201 if (expect_true (pending))
3226} 3234}
3227 3235
3228/*****************************************************************************/ 3236/*****************************************************************************/
3229 3237
3230void noinline 3238void noinline
3231ev_io_start (EV_P_ ev_io *w) 3239ev_io_start (EV_P_ ev_io *w) EV_THROW
3232{ 3240{
3233 int fd = w->fd; 3241 int fd = w->fd;
3234 3242
3235 if (expect_false (ev_is_active (w))) 3243 if (expect_false (ev_is_active (w)))
3236 return; 3244 return;
3249 3257
3250 EV_FREQUENT_CHECK; 3258 EV_FREQUENT_CHECK;
3251} 3259}
3252 3260
3253void noinline 3261void noinline
3254ev_io_stop (EV_P_ ev_io *w) 3262ev_io_stop (EV_P_ ev_io *w) EV_THROW
3255{ 3263{
3256 clear_pending (EV_A_ (W)w); 3264 clear_pending (EV_A_ (W)w);
3257 if (expect_false (!ev_is_active (w))) 3265 if (expect_false (!ev_is_active (w)))
3258 return; 3266 return;
3259 3267
3268 3276
3269 EV_FREQUENT_CHECK; 3277 EV_FREQUENT_CHECK;
3270} 3278}
3271 3279
3272void noinline 3280void noinline
3273ev_timer_start (EV_P_ ev_timer *w) 3281ev_timer_start (EV_P_ ev_timer *w) EV_THROW
3274{ 3282{
3275 if (expect_false (ev_is_active (w))) 3283 if (expect_false (ev_is_active (w)))
3276 return; 3284 return;
3277 3285
3278 ev_at (w) += mn_now; 3286 ev_at (w) += mn_now;
3292 3300
3293 /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/ 3301 /*assert (("libev: internal timer heap corruption", timers [ev_active (w)] == (WT)w));*/
3294} 3302}
3295 3303
3296void noinline 3304void noinline
3297ev_timer_stop (EV_P_ ev_timer *w) 3305ev_timer_stop (EV_P_ ev_timer *w) EV_THROW
3298{ 3306{
3299 clear_pending (EV_A_ (W)w); 3307 clear_pending (EV_A_ (W)w);
3300 if (expect_false (!ev_is_active (w))) 3308 if (expect_false (!ev_is_active (w)))
3301 return; 3309 return;
3302 3310
3322 3330
3323 EV_FREQUENT_CHECK; 3331 EV_FREQUENT_CHECK;
3324} 3332}
3325 3333
3326void noinline 3334void noinline
3327ev_timer_again (EV_P_ ev_timer *w) 3335ev_timer_again (EV_P_ ev_timer *w) EV_THROW
3328{ 3336{
3329 EV_FREQUENT_CHECK; 3337 EV_FREQUENT_CHECK;
3330 3338
3331 clear_pending (EV_A_ (W)w); 3339 clear_pending (EV_A_ (W)w);
3332 3340
3349 3357
3350 EV_FREQUENT_CHECK; 3358 EV_FREQUENT_CHECK;
3351} 3359}
3352 3360
3353ev_tstamp 3361ev_tstamp
3354ev_timer_remaining (EV_P_ ev_timer *w) 3362ev_timer_remaining (EV_P_ ev_timer *w) EV_THROW
3355{ 3363{
3356 return ev_at (w) - (ev_is_active (w) ? mn_now : 0.); 3364 return ev_at (w) - (ev_is_active (w) ? mn_now : 0.);
3357} 3365}
3358 3366
3359#if EV_PERIODIC_ENABLE 3367#if EV_PERIODIC_ENABLE
3360void noinline 3368void noinline
3361ev_periodic_start (EV_P_ ev_periodic *w) 3369ev_periodic_start (EV_P_ ev_periodic *w) EV_THROW
3362{ 3370{
3363 if (expect_false (ev_is_active (w))) 3371 if (expect_false (ev_is_active (w)))
3364 return; 3372 return;
3365 3373
3366 if (w->reschedule_cb) 3374 if (w->reschedule_cb)
3386 3394
3387 /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/ 3395 /*assert (("libev: internal periodic heap corruption", ANHE_w (periodics [ev_active (w)]) == (WT)w));*/
3388} 3396}
3389 3397
3390void noinline 3398void noinline
3391ev_periodic_stop (EV_P_ ev_periodic *w) 3399ev_periodic_stop (EV_P_ ev_periodic *w) EV_THROW
3392{ 3400{
3393 clear_pending (EV_A_ (W)w); 3401 clear_pending (EV_A_ (W)w);
3394 if (expect_false (!ev_is_active (w))) 3402 if (expect_false (!ev_is_active (w)))
3395 return; 3403 return;
3396 3404
3414 3422
3415 EV_FREQUENT_CHECK; 3423 EV_FREQUENT_CHECK;
3416} 3424}
3417 3425
3418void noinline 3426void noinline
3419ev_periodic_again (EV_P_ ev_periodic *w) 3427ev_periodic_again (EV_P_ ev_periodic *w) EV_THROW
3420{ 3428{
3421 /* TODO: use adjustheap and recalculation */ 3429 /* TODO: use adjustheap and recalculation */
3422 ev_periodic_stop (EV_A_ w); 3430 ev_periodic_stop (EV_A_ w);
3423 ev_periodic_start (EV_A_ w); 3431 ev_periodic_start (EV_A_ w);
3424} 3432}
3429#endif 3437#endif
3430 3438
3431#if EV_SIGNAL_ENABLE 3439#if EV_SIGNAL_ENABLE
3432 3440
3433void noinline 3441void noinline
3434ev_signal_start (EV_P_ ev_signal *w) 3442ev_signal_start (EV_P_ ev_signal *w) EV_THROW
3435{ 3443{
3436 if (expect_false (ev_is_active (w))) 3444 if (expect_false (ev_is_active (w)))
3437 return; 3445 return;
3438 3446
3439 assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG)); 3447 assert (("libev: ev_signal_start called with illegal signal number", w->signum > 0 && w->signum < EV_NSIG));
3510 3518
3511 EV_FREQUENT_CHECK; 3519 EV_FREQUENT_CHECK;
3512} 3520}
3513 3521
3514void noinline 3522void noinline
3515ev_signal_stop (EV_P_ ev_signal *w) 3523ev_signal_stop (EV_P_ ev_signal *w) EV_THROW
3516{ 3524{
3517 clear_pending (EV_A_ (W)w); 3525 clear_pending (EV_A_ (W)w);
3518 if (expect_false (!ev_is_active (w))) 3526 if (expect_false (!ev_is_active (w)))
3519 return; 3527 return;
3520 3528
3551#endif 3559#endif
3552 3560
3553#if EV_CHILD_ENABLE 3561#if EV_CHILD_ENABLE
3554 3562
3555void 3563void
3556ev_child_start (EV_P_ ev_child *w) 3564ev_child_start (EV_P_ ev_child *w) EV_THROW
3557{ 3565{
3558#if EV_MULTIPLICITY 3566#if EV_MULTIPLICITY
3559 assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr)); 3567 assert (("libev: child watchers are only supported in the default loop", loop == ev_default_loop_ptr));
3560#endif 3568#endif
3561 if (expect_false (ev_is_active (w))) 3569 if (expect_false (ev_is_active (w)))
3568 3576
3569 EV_FREQUENT_CHECK; 3577 EV_FREQUENT_CHECK;
3570} 3578}
3571 3579
3572void 3580void
3573ev_child_stop (EV_P_ ev_child *w) 3581ev_child_stop (EV_P_ ev_child *w) EV_THROW
3574{ 3582{
3575 clear_pending (EV_A_ (W)w); 3583 clear_pending (EV_A_ (W)w);
3576 if (expect_false (!ev_is_active (w))) 3584 if (expect_false (!ev_is_active (w)))
3577 return; 3585 return;
3578 3586
3830#else 3838#else
3831# define EV_LSTAT(p,b) lstat (p, b) 3839# define EV_LSTAT(p,b) lstat (p, b)
3832#endif 3840#endif
3833 3841
3834void 3842void
3835ev_stat_stat (EV_P_ ev_stat *w) 3843ev_stat_stat (EV_P_ ev_stat *w) EV_THROW
3836{ 3844{
3837 if (lstat (w->path, &w->attr) < 0) 3845 if (lstat (w->path, &w->attr) < 0)
3838 w->attr.st_nlink = 0; 3846 w->attr.st_nlink = 0;
3839 else if (!w->attr.st_nlink) 3847 else if (!w->attr.st_nlink)
3840 w->attr.st_nlink = 1; 3848 w->attr.st_nlink = 1;
3879 ev_feed_event (EV_A_ w, EV_STAT); 3887 ev_feed_event (EV_A_ w, EV_STAT);
3880 } 3888 }
3881} 3889}
3882 3890
3883void 3891void
3884ev_stat_start (EV_P_ ev_stat *w) 3892ev_stat_start (EV_P_ ev_stat *w) EV_THROW
3885{ 3893{
3886 if (expect_false (ev_is_active (w))) 3894 if (expect_false (ev_is_active (w)))
3887 return; 3895 return;
3888 3896
3889 ev_stat_stat (EV_A_ w); 3897 ev_stat_stat (EV_A_ w);
3910 3918
3911 EV_FREQUENT_CHECK; 3919 EV_FREQUENT_CHECK;
3912} 3920}
3913 3921
3914void 3922void
3915ev_stat_stop (EV_P_ ev_stat *w) 3923ev_stat_stop (EV_P_ ev_stat *w) EV_THROW
3916{ 3924{
3917 clear_pending (EV_A_ (W)w); 3925 clear_pending (EV_A_ (W)w);
3918 if (expect_false (!ev_is_active (w))) 3926 if (expect_false (!ev_is_active (w)))
3919 return; 3927 return;
3920 3928
3936} 3944}
3937#endif 3945#endif
3938 3946
3939#if EV_IDLE_ENABLE 3947#if EV_IDLE_ENABLE
3940void 3948void
3941ev_idle_start (EV_P_ ev_idle *w) 3949ev_idle_start (EV_P_ ev_idle *w) EV_THROW
3942{ 3950{
3943 if (expect_false (ev_is_active (w))) 3951 if (expect_false (ev_is_active (w)))
3944 return; 3952 return;
3945 3953
3946 pri_adjust (EV_A_ (W)w); 3954 pri_adjust (EV_A_ (W)w);
3959 3967
3960 EV_FREQUENT_CHECK; 3968 EV_FREQUENT_CHECK;
3961} 3969}
3962 3970
3963void 3971void
3964ev_idle_stop (EV_P_ ev_idle *w) 3972ev_idle_stop (EV_P_ ev_idle *w) EV_THROW
3965{ 3973{
3966 clear_pending (EV_A_ (W)w); 3974 clear_pending (EV_A_ (W)w);
3967 if (expect_false (!ev_is_active (w))) 3975 if (expect_false (!ev_is_active (w)))
3968 return; 3976 return;
3969 3977
3983} 3991}
3984#endif 3992#endif
3985 3993
3986#if EV_PREPARE_ENABLE 3994#if EV_PREPARE_ENABLE
3987void 3995void
3988ev_prepare_start (EV_P_ ev_prepare *w) 3996ev_prepare_start (EV_P_ ev_prepare *w) EV_THROW
3989{ 3997{
3990 if (expect_false (ev_is_active (w))) 3998 if (expect_false (ev_is_active (w)))
3991 return; 3999 return;
3992 4000
3993 EV_FREQUENT_CHECK; 4001 EV_FREQUENT_CHECK;
3998 4006
3999 EV_FREQUENT_CHECK; 4007 EV_FREQUENT_CHECK;
4000} 4008}
4001 4009
4002void 4010void
4003ev_prepare_stop (EV_P_ ev_prepare *w) 4011ev_prepare_stop (EV_P_ ev_prepare *w) EV_THROW
4004{ 4012{
4005 clear_pending (EV_A_ (W)w); 4013 clear_pending (EV_A_ (W)w);
4006 if (expect_false (!ev_is_active (w))) 4014 if (expect_false (!ev_is_active (w)))
4007 return; 4015 return;
4008 4016
4021} 4029}
4022#endif 4030#endif
4023 4031
4024#if EV_CHECK_ENABLE 4032#if EV_CHECK_ENABLE
4025void 4033void
4026ev_check_start (EV_P_ ev_check *w) 4034ev_check_start (EV_P_ ev_check *w) EV_THROW
4027{ 4035{
4028 if (expect_false (ev_is_active (w))) 4036 if (expect_false (ev_is_active (w)))
4029 return; 4037 return;
4030 4038
4031 EV_FREQUENT_CHECK; 4039 EV_FREQUENT_CHECK;
4036 4044
4037 EV_FREQUENT_CHECK; 4045 EV_FREQUENT_CHECK;
4038} 4046}
4039 4047
4040void 4048void
4041ev_check_stop (EV_P_ ev_check *w) 4049ev_check_stop (EV_P_ ev_check *w) EV_THROW
4042{ 4050{
4043 clear_pending (EV_A_ (W)w); 4051 clear_pending (EV_A_ (W)w);
4044 if (expect_false (!ev_is_active (w))) 4052 if (expect_false (!ev_is_active (w)))
4045 return; 4053 return;
4046 4054
4059} 4067}
4060#endif 4068#endif
4061 4069
4062#if EV_EMBED_ENABLE 4070#if EV_EMBED_ENABLE
4063void noinline 4071void noinline
4064ev_embed_sweep (EV_P_ ev_embed *w) 4072ev_embed_sweep (EV_P_ ev_embed *w) EV_THROW
4065{ 4073{
4066 ev_run (w->other, EVRUN_NOWAIT); 4074 ev_run (w->other, EVRUN_NOWAIT);
4067} 4075}
4068 4076
4069static void 4077static void
4117 ev_idle_stop (EV_A_ idle); 4125 ev_idle_stop (EV_A_ idle);
4118} 4126}
4119#endif 4127#endif
4120 4128
4121void 4129void
4122ev_embed_start (EV_P_ ev_embed *w) 4130ev_embed_start (EV_P_ ev_embed *w) EV_THROW
4123{ 4131{
4124 if (expect_false (ev_is_active (w))) 4132 if (expect_false (ev_is_active (w)))
4125 return; 4133 return;
4126 4134
4127 { 4135 {
4148 4156
4149 EV_FREQUENT_CHECK; 4157 EV_FREQUENT_CHECK;
4150} 4158}
4151 4159
4152void 4160void
4153ev_embed_stop (EV_P_ ev_embed *w) 4161ev_embed_stop (EV_P_ ev_embed *w) EV_THROW
4154{ 4162{
4155 clear_pending (EV_A_ (W)w); 4163 clear_pending (EV_A_ (W)w);
4156 if (expect_false (!ev_is_active (w))) 4164 if (expect_false (!ev_is_active (w)))
4157 return; 4165 return;
4158 4166
4168} 4176}
4169#endif 4177#endif
4170 4178
4171#if EV_FORK_ENABLE 4179#if EV_FORK_ENABLE
4172void 4180void
4173ev_fork_start (EV_P_ ev_fork *w) 4181ev_fork_start (EV_P_ ev_fork *w) EV_THROW
4174{ 4182{
4175 if (expect_false (ev_is_active (w))) 4183 if (expect_false (ev_is_active (w)))
4176 return; 4184 return;
4177 4185
4178 EV_FREQUENT_CHECK; 4186 EV_FREQUENT_CHECK;
4183 4191
4184 EV_FREQUENT_CHECK; 4192 EV_FREQUENT_CHECK;
4185} 4193}
4186 4194
4187void 4195void
4188ev_fork_stop (EV_P_ ev_fork *w) 4196ev_fork_stop (EV_P_ ev_fork *w) EV_THROW
4189{ 4197{
4190 clear_pending (EV_A_ (W)w); 4198 clear_pending (EV_A_ (W)w);
4191 if (expect_false (!ev_is_active (w))) 4199 if (expect_false (!ev_is_active (w)))
4192 return; 4200 return;
4193 4201
4206} 4214}
4207#endif 4215#endif
4208 4216
4209#if EV_CLEANUP_ENABLE 4217#if EV_CLEANUP_ENABLE
4210void 4218void
4211ev_cleanup_start (EV_P_ ev_cleanup *w) 4219ev_cleanup_start (EV_P_ ev_cleanup *w) EV_THROW
4212{ 4220{
4213 if (expect_false (ev_is_active (w))) 4221 if (expect_false (ev_is_active (w)))
4214 return; 4222 return;
4215 4223
4216 EV_FREQUENT_CHECK; 4224 EV_FREQUENT_CHECK;
4223 ev_unref (EV_A); 4231 ev_unref (EV_A);
4224 EV_FREQUENT_CHECK; 4232 EV_FREQUENT_CHECK;
4225} 4233}
4226 4234
4227void 4235void
4228ev_cleanup_stop (EV_P_ ev_cleanup *w) 4236ev_cleanup_stop (EV_P_ ev_cleanup *w) EV_THROW
4229{ 4237{
4230 clear_pending (EV_A_ (W)w); 4238 clear_pending (EV_A_ (W)w);
4231 if (expect_false (!ev_is_active (w))) 4239 if (expect_false (!ev_is_active (w)))
4232 return; 4240 return;
4233 4241
4247} 4255}
4248#endif 4256#endif
4249 4257
4250#if EV_ASYNC_ENABLE 4258#if EV_ASYNC_ENABLE
4251void 4259void
4252ev_async_start (EV_P_ ev_async *w) 4260ev_async_start (EV_P_ ev_async *w) EV_THROW
4253{ 4261{
4254 if (expect_false (ev_is_active (w))) 4262 if (expect_false (ev_is_active (w)))
4255 return; 4263 return;
4256 4264
4257 w->sent = 0; 4265 w->sent = 0;
4266 4274
4267 EV_FREQUENT_CHECK; 4275 EV_FREQUENT_CHECK;
4268} 4276}
4269 4277
4270void 4278void
4271ev_async_stop (EV_P_ ev_async *w) 4279ev_async_stop (EV_P_ ev_async *w) EV_THROW
4272{ 4280{
4273 clear_pending (EV_A_ (W)w); 4281 clear_pending (EV_A_ (W)w);
4274 if (expect_false (!ev_is_active (w))) 4282 if (expect_false (!ev_is_active (w)))
4275 return; 4283 return;
4276 4284
4287 4295
4288 EV_FREQUENT_CHECK; 4296 EV_FREQUENT_CHECK;
4289} 4297}
4290 4298
4291void 4299void
4292ev_async_send (EV_P_ ev_async *w) 4300ev_async_send (EV_P_ ev_async *w) EV_THROW
4293{ 4301{
4294 w->sent = 1; 4302 w->sent = 1;
4295 evpipe_write (EV_A_ &async_pending); 4303 evpipe_write (EV_A_ &async_pending);
4296} 4304}
4297#endif 4305#endif
4334 4342
4335 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io)); 4343 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io));
4336} 4344}
4337 4345
4338void 4346void
4339ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) 4347ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) EV_THROW
4340{ 4348{
4341 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); 4349 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
4342 4350
4343 if (expect_false (!once)) 4351 if (expect_false (!once))
4344 { 4352 {
4366 4374
4367/*****************************************************************************/ 4375/*****************************************************************************/
4368 4376
4369#if EV_WALK_ENABLE 4377#if EV_WALK_ENABLE
4370void ecb_cold 4378void ecb_cold
4371ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) 4379ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)) EV_THROW
4372{ 4380{
4373 int i, j; 4381 int i, j;
4374 ev_watcher_list *wl, *wn; 4382 ev_watcher_list *wl, *wn;
4375 4383
4376 if (types & (EV_IO | EV_EMBED)) 4384 if (types & (EV_IO | EV_EMBED))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines