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

Comparing libev/ev.c (file contents):
Revision 1.73 by root, Tue Nov 6 16:27:10 2007 UTC vs.
Revision 1.80 by root, Fri Nov 9 15:30:59 2007 UTC

215 int events; 215 int events;
216} ANPENDING; 216} ANPENDING;
217 217
218#if EV_MULTIPLICITY 218#if EV_MULTIPLICITY
219 219
220struct ev_loop 220 struct ev_loop
221{ 221 {
222# define VAR(name,decl) decl; 222 #define VAR(name,decl) decl;
223# include "ev_vars.h" 223 #include "ev_vars.h"
224};
225# undef VAR 224 #undef VAR
225 };
226# include "ev_wrap.h" 226 #include "ev_wrap.h"
227
228 struct ev_loop default_loop_struct;
229 static struct ev_loop *default_loop;
227 230
228#else 231#else
229 232
230# define VAR(name,decl) static decl; 233 #define VAR(name,decl) static decl;
231# include "ev_vars.h" 234 #include "ev_vars.h"
232# undef VAR 235 #undef VAR
236
237 static int default_loop;
233 238
234#endif 239#endif
235 240
236/*****************************************************************************/ 241/*****************************************************************************/
237 242
268ev_now (EV_P) 273ev_now (EV_P)
269{ 274{
270 return rt_now; 275 return rt_now;
271} 276}
272 277
273#define array_roundsize(base,n) ((n) | 4 & ~3) 278#define array_roundsize(type,n) ((n) | 4 & ~3)
274 279
275#define array_needsize(base,cur,cnt,init) \ 280#define array_needsize(type,base,cur,cnt,init) \
276 if (expect_false ((cnt) > cur)) \ 281 if (expect_false ((cnt) > cur)) \
277 { \ 282 { \
278 int newcnt = cur; \ 283 int newcnt = cur; \
279 do \ 284 do \
280 { \ 285 { \
281 newcnt = array_roundsize (base, newcnt << 1); \ 286 newcnt = array_roundsize (type, newcnt << 1); \
282 } \ 287 } \
283 while ((cnt) > newcnt); \ 288 while ((cnt) > newcnt); \
284 \ 289 \
285 base = ev_realloc (base, sizeof (*base) * (newcnt)); \ 290 base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\
286 init (base + cur, newcnt - cur); \ 291 init (base + cur, newcnt - cur); \
287 cur = newcnt; \ 292 cur = newcnt; \
288 } 293 }
289 294
290#define array_slim(stem) \ 295#define array_slim(type,stem) \
291 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ 296 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \
292 { \ 297 { \
293 stem ## max = array_roundsize (stem ## cnt >> 1); \ 298 stem ## max = array_roundsize (stem ## cnt >> 1); \
294 base = ev_realloc (base, sizeof (*base) * (stem ## max)); \ 299 base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\
295 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ 300 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
296 } 301 }
297 302
298/* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */ 303/* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */
299/* bringing us everlasting joy in form of stupid extra macros that are not required in C */ 304/* bringing us everlasting joy in form of stupid extra macros that are not required in C */
316 321
317 ++base; 322 ++base;
318 } 323 }
319} 324}
320 325
321static void 326void
322event (EV_P_ W w, int events) 327ev_feed_event (EV_P_ void *w, int revents)
323{ 328{
329 W w_ = (W)w;
330
324 if (w->pending) 331 if (w_->pending)
325 { 332 {
326 pendings [ABSPRI (w)][w->pending - 1].events |= events; 333 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
327 return; 334 return;
328 } 335 }
329 336
330 w->pending = ++pendingcnt [ABSPRI (w)]; 337 w_->pending = ++pendingcnt [ABSPRI (w_)];
331 array_needsize (pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); 338 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], (void));
332 pendings [ABSPRI (w)][w->pending - 1].w = w; 339 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
333 pendings [ABSPRI (w)][w->pending - 1].events = events; 340 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
334} 341}
335 342
336static void 343static void
337queue_events (EV_P_ W *events, int eventcnt, int type) 344queue_events (EV_P_ W *events, int eventcnt, int type)
338{ 345{
339 int i; 346 int i;
340 347
341 for (i = 0; i < eventcnt; ++i) 348 for (i = 0; i < eventcnt; ++i)
342 event (EV_A_ events [i], type); 349 ev_feed_event (EV_A_ events [i], type);
343} 350}
344 351
345static void 352inline void
346fd_event (EV_P_ int fd, int events) 353fd_event (EV_P_ int fd, int revents)
347{ 354{
348 ANFD *anfd = anfds + fd; 355 ANFD *anfd = anfds + fd;
349 struct ev_io *w; 356 struct ev_io *w;
350 357
351 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next) 358 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next)
352 { 359 {
353 int ev = w->events & events; 360 int ev = w->events & revents;
354 361
355 if (ev) 362 if (ev)
356 event (EV_A_ (W)w, ev); 363 ev_feed_event (EV_A_ (W)w, ev);
357 } 364 }
365}
366
367void
368ev_feed_fd_event (EV_P_ int fd, int revents)
369{
370 fd_event (EV_A_ fd, revents);
358} 371}
359 372
360/*****************************************************************************/ 373/*****************************************************************************/
361 374
362static void 375static void
391 return; 404 return;
392 405
393 anfds [fd].reify = 1; 406 anfds [fd].reify = 1;
394 407
395 ++fdchangecnt; 408 ++fdchangecnt;
396 array_needsize (fdchanges, fdchangemax, fdchangecnt, (void)); 409 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void));
397 fdchanges [fdchangecnt - 1] = fd; 410 fdchanges [fdchangecnt - 1] = fd;
398} 411}
399 412
400static void 413static void
401fd_kill (EV_P_ int fd) 414fd_kill (EV_P_ int fd)
403 struct ev_io *w; 416 struct ev_io *w;
404 417
405 while ((w = (struct ev_io *)anfds [fd].head)) 418 while ((w = (struct ev_io *)anfds [fd].head))
406 { 419 {
407 ev_io_stop (EV_A_ w); 420 ev_io_stop (EV_A_ w);
408 event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); 421 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
409 } 422 }
410} 423}
411 424
412static int 425static int
413fd_valid (int fd) 426fd_valid (int fd)
541 554
542 if (!gotsig) 555 if (!gotsig)
543 { 556 {
544 int old_errno = errno; 557 int old_errno = errno;
545 gotsig = 1; 558 gotsig = 1;
559#ifdef WIN32
560 send (sigpipe [1], &signum, 1, MSG_DONTWAIT);
561#else
546 write (sigpipe [1], &signum, 1); 562 write (sigpipe [1], &signum, 1);
563#endif
547 errno = old_errno; 564 errno = old_errno;
548 } 565 }
549} 566}
550 567
568void
569ev_feed_signal_event (EV_P_ int signum)
570{
571 WL w;
572
573#if EV_MULTIPLICITY
574 assert (("feeding signal events is only supported in the default loop", loop == default_loop));
575#endif
576
577 --signum;
578
579 if (signum < 0 || signum >= signalmax)
580 return;
581
582 signals [signum].gotsig = 0;
583
584 for (w = signals [signum].head; w; w = w->next)
585 ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
586}
587
551static void 588static void
552sigcb (EV_P_ struct ev_io *iow, int revents) 589sigcb (EV_P_ struct ev_io *iow, int revents)
553{ 590{
554 WL w;
555 int signum; 591 int signum;
556 592
593#ifdef WIN32
594 recv (sigpipe [0], &revents, 1, MSG_DONTWAIT);
595#else
557 read (sigpipe [0], &revents, 1); 596 read (sigpipe [0], &revents, 1);
597#endif
558 gotsig = 0; 598 gotsig = 0;
559 599
560 for (signum = signalmax; signum--; ) 600 for (signum = signalmax; signum--; )
561 if (signals [signum].gotsig) 601 if (signals [signum].gotsig)
562 { 602 ev_feed_signal_event (EV_A_ signum + 1);
563 signals [signum].gotsig = 0;
564
565 for (w = signals [signum].head; w; w = w->next)
566 event (EV_A_ (W)w, EV_SIGNAL);
567 }
568} 603}
569 604
570static void 605static void
571siginit (EV_P) 606siginit (EV_P)
572{ 607{
605 if (w->pid == pid || !w->pid) 640 if (w->pid == pid || !w->pid)
606 { 641 {
607 ev_priority (w) = ev_priority (sw); /* need to do it *now* */ 642 ev_priority (w) = ev_priority (sw); /* need to do it *now* */
608 w->rpid = pid; 643 w->rpid = pid;
609 w->rstatus = status; 644 w->rstatus = status;
610 event (EV_A_ (W)w, EV_CHILD); 645 ev_feed_event (EV_A_ (W)w, EV_CHILD);
611 } 646 }
612} 647}
613 648
614static void 649static void
615childcb (EV_P_ struct ev_signal *sw, int revents) 650childcb (EV_P_ struct ev_signal *sw, int revents)
617 int pid, status; 652 int pid, status;
618 653
619 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) 654 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)))
620 { 655 {
621 /* make sure we are called again until all childs have been reaped */ 656 /* make sure we are called again until all childs have been reaped */
622 event (EV_A_ (W)sw, EV_SIGNAL); 657 ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
623 658
624 child_reap (EV_A_ sw, pid, pid, status); 659 child_reap (EV_A_ sw, pid, pid, status);
625 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */ 660 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */
626 } 661 }
627} 662}
812} 847}
813 848
814#endif 849#endif
815 850
816#if EV_MULTIPLICITY 851#if EV_MULTIPLICITY
817struct ev_loop default_loop_struct;
818static struct ev_loop *default_loop;
819
820struct ev_loop * 852struct ev_loop *
821#else 853#else
822static int default_loop;
823
824int 854int
825#endif 855#endif
826ev_default_loop (int methods) 856ev_default_loop (int methods)
827{ 857{
828 if (sigpipe [0] == sigpipe [1]) 858 if (sigpipe [0] == sigpipe [1])
888 if (method) 918 if (method)
889 postfork = 1; 919 postfork = 1;
890} 920}
891 921
892/*****************************************************************************/ 922/*****************************************************************************/
923
924static int
925any_pending (EV_P)
926{
927 int pri;
928
929 for (pri = NUMPRI; pri--; )
930 if (pendingcnt [pri])
931 return 1;
932
933 return 0;
934}
893 935
894static void 936static void
895call_pending (EV_P) 937call_pending (EV_P)
896{ 938{
897 int pri; 939 int pri;
926 downheap ((WT *)timers, timercnt, 0); 968 downheap ((WT *)timers, timercnt, 0);
927 } 969 }
928 else 970 else
929 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 971 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
930 972
931 event (EV_A_ (W)w, EV_TIMEOUT); 973 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
932 } 974 }
933} 975}
934 976
935static void 977static void
936periodics_reify (EV_P) 978periodics_reify (EV_P)
940 struct ev_periodic *w = periodics [0]; 982 struct ev_periodic *w = periodics [0];
941 983
942 assert (("inactive timer on periodic heap detected", ev_is_active (w))); 984 assert (("inactive timer on periodic heap detected", ev_is_active (w)));
943 985
944 /* first reschedule or stop timer */ 986 /* first reschedule or stop timer */
987 if (w->reschedule_cb)
988 {
989 ev_tstamp at = ((WT)w)->at = w->reschedule_cb (w, rt_now + 0.0001);
990
991 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > rt_now));
992 downheap ((WT *)periodics, periodiccnt, 0);
993 }
945 if (w->interval) 994 else if (w->interval)
946 { 995 {
947 ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval; 996 ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval;
948 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now)); 997 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now));
949 downheap ((WT *)periodics, periodiccnt, 0); 998 downheap ((WT *)periodics, periodiccnt, 0);
950 } 999 }
951 else 1000 else
952 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 1001 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
953 1002
954 event (EV_A_ (W)w, EV_PERIODIC); 1003 ev_feed_event (EV_A_ (W)w, EV_PERIODIC);
955 } 1004 }
956} 1005}
957 1006
958static void 1007static void
959periodics_reschedule (EV_P) 1008periodics_reschedule (EV_P)
963 /* adjust periodics after time jump */ 1012 /* adjust periodics after time jump */
964 for (i = 0; i < periodiccnt; ++i) 1013 for (i = 0; i < periodiccnt; ++i)
965 { 1014 {
966 struct ev_periodic *w = periodics [i]; 1015 struct ev_periodic *w = periodics [i];
967 1016
1017 if (w->reschedule_cb)
1018 ((WT)w)->at = w->reschedule_cb (w, rt_now);
968 if (w->interval) 1019 else if (w->interval)
969 {
970 ev_tstamp diff = ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; 1020 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval;
971
972 if (fabs (diff) >= 1e-4)
973 {
974 ev_periodic_stop (EV_A_ w);
975 ev_periodic_start (EV_A_ w);
976
977 i = 0; /* restart loop, inefficient, but time jumps should be rare */
978 }
979 }
980 } 1021 }
1022
1023 /* now rebuild the heap */
1024 for (i = periodiccnt >> 1; i--; )
1025 downheap ((WT *)periodics, periodiccnt, i);
981} 1026}
982 1027
983inline int 1028inline int
984time_update_monotonic (EV_P) 1029time_update_monotonic (EV_P)
985{ 1030{
1081 /* update fd-related kernel structures */ 1126 /* update fd-related kernel structures */
1082 fd_reify (EV_A); 1127 fd_reify (EV_A);
1083 1128
1084 /* calculate blocking time */ 1129 /* calculate blocking time */
1085 1130
1086 /* we only need this for !monotonic clockor timers, but as we basically 1131 /* we only need this for !monotonic clock or timers, but as we basically
1087 always have timers, we just calculate it always */ 1132 always have timers, we just calculate it always */
1088#if EV_USE_MONOTONIC 1133#if EV_USE_MONOTONIC
1089 if (expect_true (have_monotonic)) 1134 if (expect_true (have_monotonic))
1090 time_update_monotonic (EV_A); 1135 time_update_monotonic (EV_A);
1091 else 1136 else
1124 /* queue pending timers and reschedule them */ 1169 /* queue pending timers and reschedule them */
1125 timers_reify (EV_A); /* relative timers called last */ 1170 timers_reify (EV_A); /* relative timers called last */
1126 periodics_reify (EV_A); /* absolute timers called first */ 1171 periodics_reify (EV_A); /* absolute timers called first */
1127 1172
1128 /* queue idle watchers unless io or timers are pending */ 1173 /* queue idle watchers unless io or timers are pending */
1129 if (!pendingcnt) 1174 if (idlecnt && !any_pending (EV_A))
1130 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); 1175 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE);
1131 1176
1132 /* queue check watchers, to be executed first */ 1177 /* queue check watchers, to be executed first */
1133 if (checkcnt) 1178 if (checkcnt)
1134 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 1179 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
1209 return; 1254 return;
1210 1255
1211 assert (("ev_io_start called with negative fd", fd >= 0)); 1256 assert (("ev_io_start called with negative fd", fd >= 0));
1212 1257
1213 ev_start (EV_A_ (W)w, 1); 1258 ev_start (EV_A_ (W)w, 1);
1214 array_needsize (anfds, anfdmax, fd + 1, anfds_init); 1259 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
1215 wlist_add ((WL *)&anfds[fd].head, (WL)w); 1260 wlist_add ((WL *)&anfds[fd].head, (WL)w);
1216 1261
1217 fd_change (EV_A_ fd); 1262 fd_change (EV_A_ fd);
1218} 1263}
1219 1264
1239 ((WT)w)->at += mn_now; 1284 ((WT)w)->at += mn_now;
1240 1285
1241 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); 1286 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
1242 1287
1243 ev_start (EV_A_ (W)w, ++timercnt); 1288 ev_start (EV_A_ (W)w, ++timercnt);
1244 array_needsize (timers, timermax, timercnt, (void)); 1289 array_needsize (struct ev_timer *, timers, timermax, timercnt, (void));
1245 timers [timercnt - 1] = w; 1290 timers [timercnt - 1] = w;
1246 upheap ((WT *)timers, timercnt - 1); 1291 upheap ((WT *)timers, timercnt - 1);
1247 1292
1248 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1293 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1249} 1294}
1289ev_periodic_start (EV_P_ struct ev_periodic *w) 1334ev_periodic_start (EV_P_ struct ev_periodic *w)
1290{ 1335{
1291 if (ev_is_active (w)) 1336 if (ev_is_active (w))
1292 return; 1337 return;
1293 1338
1339 if (w->reschedule_cb)
1340 ((WT)w)->at = w->reschedule_cb (w, rt_now);
1341 else if (w->interval)
1342 {
1294 assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); 1343 assert (("ev_periodic_start called with negative interval value", w->interval >= 0.));
1295
1296 /* this formula differs from the one in periodic_reify because we do not always round up */ 1344 /* this formula differs from the one in periodic_reify because we do not always round up */
1297 if (w->interval)
1298 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; 1345 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval;
1346 }
1299 1347
1300 ev_start (EV_A_ (W)w, ++periodiccnt); 1348 ev_start (EV_A_ (W)w, ++periodiccnt);
1301 array_needsize (periodics, periodicmax, periodiccnt, (void)); 1349 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void));
1302 periodics [periodiccnt - 1] = w; 1350 periodics [periodiccnt - 1] = w;
1303 upheap ((WT *)periodics, periodiccnt - 1); 1351 upheap ((WT *)periodics, periodiccnt - 1);
1304 1352
1305 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1353 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1306} 1354}
1322 1370
1323 ev_stop (EV_A_ (W)w); 1371 ev_stop (EV_A_ (W)w);
1324} 1372}
1325 1373
1326void 1374void
1375ev_periodic_again (EV_P_ struct ev_periodic *w)
1376{
1377 ev_periodic_stop (EV_A_ w);
1378 ev_periodic_start (EV_A_ w);
1379}
1380
1381void
1327ev_idle_start (EV_P_ struct ev_idle *w) 1382ev_idle_start (EV_P_ struct ev_idle *w)
1328{ 1383{
1329 if (ev_is_active (w)) 1384 if (ev_is_active (w))
1330 return; 1385 return;
1331 1386
1332 ev_start (EV_A_ (W)w, ++idlecnt); 1387 ev_start (EV_A_ (W)w, ++idlecnt);
1333 array_needsize (idles, idlemax, idlecnt, (void)); 1388 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void));
1334 idles [idlecnt - 1] = w; 1389 idles [idlecnt - 1] = w;
1335} 1390}
1336 1391
1337void 1392void
1338ev_idle_stop (EV_P_ struct ev_idle *w) 1393ev_idle_stop (EV_P_ struct ev_idle *w)
1350{ 1405{
1351 if (ev_is_active (w)) 1406 if (ev_is_active (w))
1352 return; 1407 return;
1353 1408
1354 ev_start (EV_A_ (W)w, ++preparecnt); 1409 ev_start (EV_A_ (W)w, ++preparecnt);
1355 array_needsize (prepares, preparemax, preparecnt, (void)); 1410 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void));
1356 prepares [preparecnt - 1] = w; 1411 prepares [preparecnt - 1] = w;
1357} 1412}
1358 1413
1359void 1414void
1360ev_prepare_stop (EV_P_ struct ev_prepare *w) 1415ev_prepare_stop (EV_P_ struct ev_prepare *w)
1372{ 1427{
1373 if (ev_is_active (w)) 1428 if (ev_is_active (w))
1374 return; 1429 return;
1375 1430
1376 ev_start (EV_A_ (W)w, ++checkcnt); 1431 ev_start (EV_A_ (W)w, ++checkcnt);
1377 array_needsize (checks, checkmax, checkcnt, (void)); 1432 array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void));
1378 checks [checkcnt - 1] = w; 1433 checks [checkcnt - 1] = w;
1379} 1434}
1380 1435
1381void 1436void
1382ev_check_stop (EV_P_ struct ev_check *w) 1437ev_check_stop (EV_P_ struct ev_check *w)
1403 return; 1458 return;
1404 1459
1405 assert (("ev_signal_start called with illegal signal number", w->signum > 0)); 1460 assert (("ev_signal_start called with illegal signal number", w->signum > 0));
1406 1461
1407 ev_start (EV_A_ (W)w, 1); 1462 ev_start (EV_A_ (W)w, 1);
1408 array_needsize (signals, signalmax, w->signum, signals_init); 1463 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
1409 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1464 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
1410 1465
1411 if (!((WL)w)->next) 1466 if (!((WL)w)->next)
1412 { 1467 {
1413#if WIN32 1468#if WIN32
1496} 1551}
1497 1552
1498void 1553void
1499ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) 1554ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
1500{ 1555{
1501 struct ev_once *once = ev_malloc (sizeof (struct ev_once)); 1556 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
1502 1557
1503 if (!once) 1558 if (!once)
1504 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); 1559 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg);
1505 else 1560 else
1506 { 1561 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines