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

Comparing libev/ev.c (file contents):
Revision 1.71 by root, Tue Nov 6 13:17:55 2007 UTC vs.
Revision 1.79 by root, Fri Nov 9 15:15:20 2007 UTC

64#include <assert.h> 64#include <assert.h>
65#include <errno.h> 65#include <errno.h>
66#include <sys/types.h> 66#include <sys/types.h>
67#include <time.h> 67#include <time.h>
68 68
69#ifndef PERL
70# include <signal.h> 69#include <signal.h>
71#endif
72 70
73#ifndef WIN32 71#ifndef WIN32
74# include <unistd.h> 72# include <unistd.h>
75# include <sys/time.h> 73# include <sys/time.h>
76# include <sys/wait.h> 74# include <sys/wait.h>
150typedef struct ev_watcher_list *WL; 148typedef struct ev_watcher_list *WL;
151typedef struct ev_watcher_time *WT; 149typedef struct ev_watcher_time *WT;
152 150
153static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ 151static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
154 152
155#if WIN32 153#include "ev_win32.c"
156/* note: the comment below could not be substantiated, but what would I care */
157/* MSDN says this is required to handle SIGFPE */
158volatile double SIGFPE_REQ = 0.0f;
159#endif
160 154
161/*****************************************************************************/ 155/*****************************************************************************/
162 156
163static void (*syserr_cb)(const char *msg); 157static void (*syserr_cb)(const char *msg);
164 158
274ev_now (EV_P) 268ev_now (EV_P)
275{ 269{
276 return rt_now; 270 return rt_now;
277} 271}
278 272
279#define array_roundsize(base,n) ((n) | 4 & ~3) 273#define array_roundsize(type,n) ((n) | 4 & ~3)
280 274
281#define array_needsize(base,cur,cnt,init) \ 275#define array_needsize(type,base,cur,cnt,init) \
282 if (expect_false ((cnt) > cur)) \ 276 if (expect_false ((cnt) > cur)) \
283 { \ 277 { \
284 int newcnt = cur; \ 278 int newcnt = cur; \
285 do \ 279 do \
286 { \ 280 { \
287 newcnt = array_roundsize (base, newcnt << 1); \ 281 newcnt = array_roundsize (type, newcnt << 1); \
288 } \ 282 } \
289 while ((cnt) > newcnt); \ 283 while ((cnt) > newcnt); \
290 \ 284 \
291 base = ev_realloc (base, sizeof (*base) * (newcnt)); \ 285 base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\
292 init (base + cur, newcnt - cur); \ 286 init (base + cur, newcnt - cur); \
293 cur = newcnt; \ 287 cur = newcnt; \
294 } 288 }
295 289
296#define array_slim(stem) \ 290#define array_slim(type,stem) \
297 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ 291 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \
298 { \ 292 { \
299 stem ## max = array_roundsize (stem ## cnt >> 1); \ 293 stem ## max = array_roundsize (stem ## cnt >> 1); \
300 base = ev_realloc (base, sizeof (*base) * (stem ## max)); \ 294 base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\
301 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ 295 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
302 } 296 }
303 297
304/* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */ 298/* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */
305/* bringing us everlasting joy in form of stupid extra macros that are not required in C */ 299/* bringing us everlasting joy in form of stupid extra macros that are not required in C */
322 316
323 ++base; 317 ++base;
324 } 318 }
325} 319}
326 320
327static void 321void
328event (EV_P_ W w, int events) 322ev_feed_event (EV_P_ void *w, int revents)
329{ 323{
324 W w_ = (W)w;
325
330 if (w->pending) 326 if (w_->pending)
331 { 327 {
332 pendings [ABSPRI (w)][w->pending - 1].events |= events; 328 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
333 return; 329 return;
334 } 330 }
335 331
336 w->pending = ++pendingcnt [ABSPRI (w)]; 332 w_->pending = ++pendingcnt [ABSPRI (w_)];
337 array_needsize (pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); 333 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], (void));
338 pendings [ABSPRI (w)][w->pending - 1].w = w; 334 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
339 pendings [ABSPRI (w)][w->pending - 1].events = events; 335 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
340} 336}
341 337
342static void 338static void
343queue_events (EV_P_ W *events, int eventcnt, int type) 339queue_events (EV_P_ W *events, int eventcnt, int type)
344{ 340{
345 int i; 341 int i;
346 342
347 for (i = 0; i < eventcnt; ++i) 343 for (i = 0; i < eventcnt; ++i)
348 event (EV_A_ events [i], type); 344 ev_feed_event (EV_A_ events [i], type);
349} 345}
350 346
351static void 347inline void
352fd_event (EV_P_ int fd, int events) 348fd_event (EV_P_ int fd, int revents)
353{ 349{
354 ANFD *anfd = anfds + fd; 350 ANFD *anfd = anfds + fd;
355 struct ev_io *w; 351 struct ev_io *w;
356 352
357 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next) 353 for (w = (struct ev_io *)anfd->head; w; w = (struct ev_io *)((WL)w)->next)
358 { 354 {
359 int ev = w->events & events; 355 int ev = w->events & revents;
360 356
361 if (ev) 357 if (ev)
362 event (EV_A_ (W)w, ev); 358 ev_feed_event (EV_A_ (W)w, ev);
363 } 359 }
360}
361
362void
363ev_feed_fd_event (EV_P_ int fd, int revents)
364{
365 fd_event (EV_A_ fd, revents);
364} 366}
365 367
366/*****************************************************************************/ 368/*****************************************************************************/
367 369
368static void 370static void
397 return; 399 return;
398 400
399 anfds [fd].reify = 1; 401 anfds [fd].reify = 1;
400 402
401 ++fdchangecnt; 403 ++fdchangecnt;
402 array_needsize (fdchanges, fdchangemax, fdchangecnt, (void)); 404 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void));
403 fdchanges [fdchangecnt - 1] = fd; 405 fdchanges [fdchangecnt - 1] = fd;
404} 406}
405 407
406static void 408static void
407fd_kill (EV_P_ int fd) 409fd_kill (EV_P_ int fd)
409 struct ev_io *w; 411 struct ev_io *w;
410 412
411 while ((w = (struct ev_io *)anfds [fd].head)) 413 while ((w = (struct ev_io *)anfds [fd].head))
412 { 414 {
413 ev_io_stop (EV_A_ w); 415 ev_io_stop (EV_A_ w);
414 event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE); 416 ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
415 } 417 }
416} 418}
417 419
418static int 420static int
419fd_valid (int fd) 421fd_valid (int fd)
547 549
548 if (!gotsig) 550 if (!gotsig)
549 { 551 {
550 int old_errno = errno; 552 int old_errno = errno;
551 gotsig = 1; 553 gotsig = 1;
554#ifdef WIN32
555 send (sigpipe [1], &signum, 1, MSG_DONTWAIT);
556#else
552 write (sigpipe [1], &signum, 1); 557 write (sigpipe [1], &signum, 1);
558#endif
553 errno = old_errno; 559 errno = old_errno;
554 } 560 }
561}
562
563void
564ev_feed_signal_event (EV_P_ int signum)
565{
566#if EV_MULTIPLICITY
567 assert (("feeding signal events is only supported in the default loop", loop == default_loop));
568#endif
569
570 --signum;
571
572 if (signum < 0 || signum >= signalmax)
573 return;
574
575 signals [signum].gotsig = 0;
576
577 for (w = signals [signum].head; w; w = w->next)
578 ev_feed_event (EV_A_ (W)w, EV_SIGNAL);
555} 579}
556 580
557static void 581static void
558sigcb (EV_P_ struct ev_io *iow, int revents) 582sigcb (EV_P_ struct ev_io *iow, int revents)
559{ 583{
560 WL w; 584 WL w;
561 int signum; 585 int signum;
562 586
587#ifdef WIN32
588 recv (sigpipe [0], &revents, 1, MSG_DONTWAIT);
589#else
563 read (sigpipe [0], &revents, 1); 590 read (sigpipe [0], &revents, 1);
591#endif
564 gotsig = 0; 592 gotsig = 0;
565 593
566 for (signum = signalmax; signum--; ) 594 for (signum = signalmax; signum--; )
567 if (signals [signum].gotsig) 595 if (signals [signum].gotsig)
568 { 596 sigevent (EV_A_ signum + 1);
569 signals [signum].gotsig = 0;
570
571 for (w = signals [signum].head; w; w = w->next)
572 event (EV_A_ (W)w, EV_SIGNAL);
573 }
574} 597}
575 598
576static void 599static void
577siginit (EV_P) 600siginit (EV_P)
578{ 601{
611 if (w->pid == pid || !w->pid) 634 if (w->pid == pid || !w->pid)
612 { 635 {
613 ev_priority (w) = ev_priority (sw); /* need to do it *now* */ 636 ev_priority (w) = ev_priority (sw); /* need to do it *now* */
614 w->rpid = pid; 637 w->rpid = pid;
615 w->rstatus = status; 638 w->rstatus = status;
616 event (EV_A_ (W)w, EV_CHILD); 639 ev_feed_event (EV_A_ (W)w, EV_CHILD);
617 } 640 }
618} 641}
619 642
620static void 643static void
621childcb (EV_P_ struct ev_signal *sw, int revents) 644childcb (EV_P_ struct ev_signal *sw, int revents)
623 int pid, status; 646 int pid, status;
624 647
625 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) 648 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)))
626 { 649 {
627 /* make sure we are called again until all childs have been reaped */ 650 /* make sure we are called again until all childs have been reaped */
628 event (EV_A_ (W)sw, EV_SIGNAL); 651 ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
629 652
630 child_reap (EV_A_ sw, pid, pid, status); 653 child_reap (EV_A_ sw, pid, pid, status);
631 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */ 654 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */
632 } 655 }
633} 656}
894 if (method) 917 if (method)
895 postfork = 1; 918 postfork = 1;
896} 919}
897 920
898/*****************************************************************************/ 921/*****************************************************************************/
922
923static int
924any_pending (EV_P)
925{
926 int pri;
927
928 for (pri = NUMPRI; pri--; )
929 if (pendingcnt [pri])
930 return 1;
931
932 return 0;
933}
899 934
900static void 935static void
901call_pending (EV_P) 936call_pending (EV_P)
902{ 937{
903 int pri; 938 int pri;
932 downheap ((WT *)timers, timercnt, 0); 967 downheap ((WT *)timers, timercnt, 0);
933 } 968 }
934 else 969 else
935 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 970 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
936 971
937 event (EV_A_ (W)w, EV_TIMEOUT); 972 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
938 } 973 }
939} 974}
940 975
941static void 976static void
942periodics_reify (EV_P) 977periodics_reify (EV_P)
946 struct ev_periodic *w = periodics [0]; 981 struct ev_periodic *w = periodics [0];
947 982
948 assert (("inactive timer on periodic heap detected", ev_is_active (w))); 983 assert (("inactive timer on periodic heap detected", ev_is_active (w)));
949 984
950 /* first reschedule or stop timer */ 985 /* first reschedule or stop timer */
986 if (w->reschedule_cb)
987 {
988 ev_tstamp at = ((WT)w)->at = w->reschedule_cb (w, rt_now + 0.0001);
989
990 assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > rt_now));
991 downheap ((WT *)periodics, periodiccnt, 0);
992 }
951 if (w->interval) 993 else if (w->interval)
952 { 994 {
953 ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval; 995 ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval;
954 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now)); 996 assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now));
955 downheap ((WT *)periodics, periodiccnt, 0); 997 downheap ((WT *)periodics, periodiccnt, 0);
956 } 998 }
957 else 999 else
958 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 1000 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
959 1001
960 event (EV_A_ (W)w, EV_PERIODIC); 1002 ev_feed_event (EV_A_ (W)w, EV_PERIODIC);
961 } 1003 }
962} 1004}
963 1005
964static void 1006static void
965periodics_reschedule (EV_P) 1007periodics_reschedule (EV_P)
969 /* adjust periodics after time jump */ 1011 /* adjust periodics after time jump */
970 for (i = 0; i < periodiccnt; ++i) 1012 for (i = 0; i < periodiccnt; ++i)
971 { 1013 {
972 struct ev_periodic *w = periodics [i]; 1014 struct ev_periodic *w = periodics [i];
973 1015
1016 if (w->reschedule_cb)
1017 ((WT)w)->at = w->reschedule_cb (w, rt_now);
974 if (w->interval) 1018 else if (w->interval)
975 {
976 ev_tstamp diff = ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; 1019 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval;
977
978 if (fabs (diff) >= 1e-4)
979 {
980 ev_periodic_stop (EV_A_ w);
981 ev_periodic_start (EV_A_ w);
982
983 i = 0; /* restart loop, inefficient, but time jumps should be rare */
984 }
985 }
986 } 1020 }
1021
1022 /* now rebuild the heap */
1023 for (i = periodiccnt >> 1; i--; )
1024 downheap ((WT *)periodics, periodiccnt, i);
987} 1025}
988 1026
989inline int 1027inline int
990time_update_monotonic (EV_P) 1028time_update_monotonic (EV_P)
991{ 1029{
1087 /* update fd-related kernel structures */ 1125 /* update fd-related kernel structures */
1088 fd_reify (EV_A); 1126 fd_reify (EV_A);
1089 1127
1090 /* calculate blocking time */ 1128 /* calculate blocking time */
1091 1129
1092 /* we only need this for !monotonic clockor timers, but as we basically 1130 /* we only need this for !monotonic clock or timers, but as we basically
1093 always have timers, we just calculate it always */ 1131 always have timers, we just calculate it always */
1094#if EV_USE_MONOTONIC 1132#if EV_USE_MONOTONIC
1095 if (expect_true (have_monotonic)) 1133 if (expect_true (have_monotonic))
1096 time_update_monotonic (EV_A); 1134 time_update_monotonic (EV_A);
1097 else 1135 else
1130 /* queue pending timers and reschedule them */ 1168 /* queue pending timers and reschedule them */
1131 timers_reify (EV_A); /* relative timers called last */ 1169 timers_reify (EV_A); /* relative timers called last */
1132 periodics_reify (EV_A); /* absolute timers called first */ 1170 periodics_reify (EV_A); /* absolute timers called first */
1133 1171
1134 /* queue idle watchers unless io or timers are pending */ 1172 /* queue idle watchers unless io or timers are pending */
1135 if (!pendingcnt) 1173 if (idlecnt && !any_pending (EV_A))
1136 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); 1174 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE);
1137 1175
1138 /* queue check watchers, to be executed first */ 1176 /* queue check watchers, to be executed first */
1139 if (checkcnt) 1177 if (checkcnt)
1140 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 1178 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
1215 return; 1253 return;
1216 1254
1217 assert (("ev_io_start called with negative fd", fd >= 0)); 1255 assert (("ev_io_start called with negative fd", fd >= 0));
1218 1256
1219 ev_start (EV_A_ (W)w, 1); 1257 ev_start (EV_A_ (W)w, 1);
1220 array_needsize (anfds, anfdmax, fd + 1, anfds_init); 1258 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
1221 wlist_add ((WL *)&anfds[fd].head, (WL)w); 1259 wlist_add ((WL *)&anfds[fd].head, (WL)w);
1222 1260
1223 fd_change (EV_A_ fd); 1261 fd_change (EV_A_ fd);
1224} 1262}
1225 1263
1245 ((WT)w)->at += mn_now; 1283 ((WT)w)->at += mn_now;
1246 1284
1247 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); 1285 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
1248 1286
1249 ev_start (EV_A_ (W)w, ++timercnt); 1287 ev_start (EV_A_ (W)w, ++timercnt);
1250 array_needsize (timers, timermax, timercnt, (void)); 1288 array_needsize (struct ev_timer *, timers, timermax, timercnt, (void));
1251 timers [timercnt - 1] = w; 1289 timers [timercnt - 1] = w;
1252 upheap ((WT *)timers, timercnt - 1); 1290 upheap ((WT *)timers, timercnt - 1);
1253 1291
1254 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1292 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1255} 1293}
1295ev_periodic_start (EV_P_ struct ev_periodic *w) 1333ev_periodic_start (EV_P_ struct ev_periodic *w)
1296{ 1334{
1297 if (ev_is_active (w)) 1335 if (ev_is_active (w))
1298 return; 1336 return;
1299 1337
1338 if (w->reschedule_cb)
1339 ((WT)w)->at = w->reschedule_cb (w, rt_now);
1340 else if (w->interval)
1341 {
1300 assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); 1342 assert (("ev_periodic_start called with negative interval value", w->interval >= 0.));
1301
1302 /* this formula differs from the one in periodic_reify because we do not always round up */ 1343 /* this formula differs from the one in periodic_reify because we do not always round up */
1303 if (w->interval)
1304 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; 1344 ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval;
1345 }
1305 1346
1306 ev_start (EV_A_ (W)w, ++periodiccnt); 1347 ev_start (EV_A_ (W)w, ++periodiccnt);
1307 array_needsize (periodics, periodicmax, periodiccnt, (void)); 1348 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void));
1308 periodics [periodiccnt - 1] = w; 1349 periodics [periodiccnt - 1] = w;
1309 upheap ((WT *)periodics, periodiccnt - 1); 1350 upheap ((WT *)periodics, periodiccnt - 1);
1310 1351
1311 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1352 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1312} 1353}
1328 1369
1329 ev_stop (EV_A_ (W)w); 1370 ev_stop (EV_A_ (W)w);
1330} 1371}
1331 1372
1332void 1373void
1374ev_periodic_again (EV_P_ struct ev_periodic *w)
1375{
1376 ev_periodic_stop (EV_A_ w);
1377 ev_periodic_start (EV_A_ w);
1378}
1379
1380void
1333ev_idle_start (EV_P_ struct ev_idle *w) 1381ev_idle_start (EV_P_ struct ev_idle *w)
1334{ 1382{
1335 if (ev_is_active (w)) 1383 if (ev_is_active (w))
1336 return; 1384 return;
1337 1385
1338 ev_start (EV_A_ (W)w, ++idlecnt); 1386 ev_start (EV_A_ (W)w, ++idlecnt);
1339 array_needsize (idles, idlemax, idlecnt, (void)); 1387 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void));
1340 idles [idlecnt - 1] = w; 1388 idles [idlecnt - 1] = w;
1341} 1389}
1342 1390
1343void 1391void
1344ev_idle_stop (EV_P_ struct ev_idle *w) 1392ev_idle_stop (EV_P_ struct ev_idle *w)
1356{ 1404{
1357 if (ev_is_active (w)) 1405 if (ev_is_active (w))
1358 return; 1406 return;
1359 1407
1360 ev_start (EV_A_ (W)w, ++preparecnt); 1408 ev_start (EV_A_ (W)w, ++preparecnt);
1361 array_needsize (prepares, preparemax, preparecnt, (void)); 1409 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void));
1362 prepares [preparecnt - 1] = w; 1410 prepares [preparecnt - 1] = w;
1363} 1411}
1364 1412
1365void 1413void
1366ev_prepare_stop (EV_P_ struct ev_prepare *w) 1414ev_prepare_stop (EV_P_ struct ev_prepare *w)
1378{ 1426{
1379 if (ev_is_active (w)) 1427 if (ev_is_active (w))
1380 return; 1428 return;
1381 1429
1382 ev_start (EV_A_ (W)w, ++checkcnt); 1430 ev_start (EV_A_ (W)w, ++checkcnt);
1383 array_needsize (checks, checkmax, checkcnt, (void)); 1431 array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void));
1384 checks [checkcnt - 1] = w; 1432 checks [checkcnt - 1] = w;
1385} 1433}
1386 1434
1387void 1435void
1388ev_check_stop (EV_P_ struct ev_check *w) 1436ev_check_stop (EV_P_ struct ev_check *w)
1409 return; 1457 return;
1410 1458
1411 assert (("ev_signal_start called with illegal signal number", w->signum > 0)); 1459 assert (("ev_signal_start called with illegal signal number", w->signum > 0));
1412 1460
1413 ev_start (EV_A_ (W)w, 1); 1461 ev_start (EV_A_ (W)w, 1);
1414 array_needsize (signals, signalmax, w->signum, signals_init); 1462 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
1415 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1463 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
1416 1464
1417 if (!((WL)w)->next) 1465 if (!((WL)w)->next)
1418 { 1466 {
1419#if WIN32 1467#if WIN32
1502} 1550}
1503 1551
1504void 1552void
1505ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) 1553ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
1506{ 1554{
1507 struct ev_once *once = ev_malloc (sizeof (struct ev_once)); 1555 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
1508 1556
1509 if (!once) 1557 if (!once)
1510 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); 1558 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg);
1511 else 1559 else
1512 { 1560 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines