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.80 by root, Fri Nov 9 15:30:59 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
221 int events; 215 int events;
222} ANPENDING; 216} ANPENDING;
223 217
224#if EV_MULTIPLICITY 218#if EV_MULTIPLICITY
225 219
226struct ev_loop 220 struct ev_loop
227{ 221 {
228# define VAR(name,decl) decl; 222 #define VAR(name,decl) decl;
229# include "ev_vars.h" 223 #include "ev_vars.h"
230};
231# undef VAR 224 #undef VAR
225 };
232# include "ev_wrap.h" 226 #include "ev_wrap.h"
227
228 struct ev_loop default_loop_struct;
229 static struct ev_loop *default_loop;
233 230
234#else 231#else
235 232
236# define VAR(name,decl) static decl; 233 #define VAR(name,decl) static decl;
237# include "ev_vars.h" 234 #include "ev_vars.h"
238# undef VAR 235 #undef VAR
236
237 static int default_loop;
239 238
240#endif 239#endif
241 240
242/*****************************************************************************/ 241/*****************************************************************************/
243 242
274ev_now (EV_P) 273ev_now (EV_P)
275{ 274{
276 return rt_now; 275 return rt_now;
277} 276}
278 277
279#define array_roundsize(base,n) ((n) | 4 & ~3) 278#define array_roundsize(type,n) ((n) | 4 & ~3)
280 279
281#define array_needsize(base,cur,cnt,init) \ 280#define array_needsize(type,base,cur,cnt,init) \
282 if (expect_false ((cnt) > cur)) \ 281 if (expect_false ((cnt) > cur)) \
283 { \ 282 { \
284 int newcnt = cur; \ 283 int newcnt = cur; \
285 do \ 284 do \
286 { \ 285 { \
287 newcnt = array_roundsize (base, newcnt << 1); \ 286 newcnt = array_roundsize (type, newcnt << 1); \
288 } \ 287 } \
289 while ((cnt) > newcnt); \ 288 while ((cnt) > newcnt); \
290 \ 289 \
291 base = ev_realloc (base, sizeof (*base) * (newcnt)); \ 290 base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\
292 init (base + cur, newcnt - cur); \ 291 init (base + cur, newcnt - cur); \
293 cur = newcnt; \ 292 cur = newcnt; \
294 } 293 }
295 294
296#define array_slim(stem) \ 295#define array_slim(type,stem) \
297 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ 296 if (stem ## max < array_roundsize (stem ## cnt >> 2)) \
298 { \ 297 { \
299 stem ## max = array_roundsize (stem ## cnt >> 1); \ 298 stem ## max = array_roundsize (stem ## cnt >> 1); \
300 base = ev_realloc (base, sizeof (*base) * (stem ## max)); \ 299 base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\
301 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ 300 fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\
302 } 301 }
303 302
304/* 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 */
305/* 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 */
322 321
323 ++base; 322 ++base;
324 } 323 }
325} 324}
326 325
327static void 326void
328event (EV_P_ W w, int events) 327ev_feed_event (EV_P_ void *w, int revents)
329{ 328{
329 W w_ = (W)w;
330
330 if (w->pending) 331 if (w_->pending)
331 { 332 {
332 pendings [ABSPRI (w)][w->pending - 1].events |= events; 333 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
333 return; 334 return;
334 } 335 }
335 336
336 w->pending = ++pendingcnt [ABSPRI (w)]; 337 w_->pending = ++pendingcnt [ABSPRI (w_)];
337 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));
338 pendings [ABSPRI (w)][w->pending - 1].w = w; 339 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
339 pendings [ABSPRI (w)][w->pending - 1].events = events; 340 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
340} 341}
341 342
342static void 343static void
343queue_events (EV_P_ W *events, int eventcnt, int type) 344queue_events (EV_P_ W *events, int eventcnt, int type)
344{ 345{
345 int i; 346 int i;
346 347
347 for (i = 0; i < eventcnt; ++i) 348 for (i = 0; i < eventcnt; ++i)
348 event (EV_A_ events [i], type); 349 ev_feed_event (EV_A_ events [i], type);
349} 350}
350 351
351static void 352inline void
352fd_event (EV_P_ int fd, int events) 353fd_event (EV_P_ int fd, int revents)
353{ 354{
354 ANFD *anfd = anfds + fd; 355 ANFD *anfd = anfds + fd;
355 struct ev_io *w; 356 struct ev_io *w;
356 357
357 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)
358 { 359 {
359 int ev = w->events & events; 360 int ev = w->events & revents;
360 361
361 if (ev) 362 if (ev)
362 event (EV_A_ (W)w, ev); 363 ev_feed_event (EV_A_ (W)w, ev);
363 } 364 }
365}
366
367void
368ev_feed_fd_event (EV_P_ int fd, int revents)
369{
370 fd_event (EV_A_ fd, revents);
364} 371}
365 372
366/*****************************************************************************/ 373/*****************************************************************************/
367 374
368static void 375static void
397 return; 404 return;
398 405
399 anfds [fd].reify = 1; 406 anfds [fd].reify = 1;
400 407
401 ++fdchangecnt; 408 ++fdchangecnt;
402 array_needsize (fdchanges, fdchangemax, fdchangecnt, (void)); 409 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void));
403 fdchanges [fdchangecnt - 1] = fd; 410 fdchanges [fdchangecnt - 1] = fd;
404} 411}
405 412
406static void 413static void
407fd_kill (EV_P_ int fd) 414fd_kill (EV_P_ int fd)
409 struct ev_io *w; 416 struct ev_io *w;
410 417
411 while ((w = (struct ev_io *)anfds [fd].head)) 418 while ((w = (struct ev_io *)anfds [fd].head))
412 { 419 {
413 ev_io_stop (EV_A_ w); 420 ev_io_stop (EV_A_ w);
414 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);
415 } 422 }
416} 423}
417 424
418static int 425static int
419fd_valid (int fd) 426fd_valid (int fd)
547 554
548 if (!gotsig) 555 if (!gotsig)
549 { 556 {
550 int old_errno = errno; 557 int old_errno = errno;
551 gotsig = 1; 558 gotsig = 1;
559#ifdef WIN32
560 send (sigpipe [1], &signum, 1, MSG_DONTWAIT);
561#else
552 write (sigpipe [1], &signum, 1); 562 write (sigpipe [1], &signum, 1);
563#endif
553 errno = old_errno; 564 errno = old_errno;
554 } 565 }
555} 566}
556 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
557static void 588static void
558sigcb (EV_P_ struct ev_io *iow, int revents) 589sigcb (EV_P_ struct ev_io *iow, int revents)
559{ 590{
560 WL w;
561 int signum; 591 int signum;
562 592
593#ifdef WIN32
594 recv (sigpipe [0], &revents, 1, MSG_DONTWAIT);
595#else
563 read (sigpipe [0], &revents, 1); 596 read (sigpipe [0], &revents, 1);
597#endif
564 gotsig = 0; 598 gotsig = 0;
565 599
566 for (signum = signalmax; signum--; ) 600 for (signum = signalmax; signum--; )
567 if (signals [signum].gotsig) 601 if (signals [signum].gotsig)
568 { 602 ev_feed_signal_event (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} 603}
575 604
576static void 605static void
577siginit (EV_P) 606siginit (EV_P)
578{ 607{
611 if (w->pid == pid || !w->pid) 640 if (w->pid == pid || !w->pid)
612 { 641 {
613 ev_priority (w) = ev_priority (sw); /* need to do it *now* */ 642 ev_priority (w) = ev_priority (sw); /* need to do it *now* */
614 w->rpid = pid; 643 w->rpid = pid;
615 w->rstatus = status; 644 w->rstatus = status;
616 event (EV_A_ (W)w, EV_CHILD); 645 ev_feed_event (EV_A_ (W)w, EV_CHILD);
617 } 646 }
618} 647}
619 648
620static void 649static void
621childcb (EV_P_ struct ev_signal *sw, int revents) 650childcb (EV_P_ struct ev_signal *sw, int revents)
623 int pid, status; 652 int pid, status;
624 653
625 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED))) 654 if (0 < (pid = waitpid (-1, &status, WNOHANG | WUNTRACED | WCONTINUED)))
626 { 655 {
627 /* 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 */
628 event (EV_A_ (W)sw, EV_SIGNAL); 657 ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
629 658
630 child_reap (EV_A_ sw, pid, pid, status); 659 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 */ 660 child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but event catches that */
632 } 661 }
633} 662}
818} 847}
819 848
820#endif 849#endif
821 850
822#if EV_MULTIPLICITY 851#if EV_MULTIPLICITY
823struct ev_loop default_loop_struct;
824static struct ev_loop *default_loop;
825
826struct ev_loop * 852struct ev_loop *
827#else 853#else
828static int default_loop;
829
830int 854int
831#endif 855#endif
832ev_default_loop (int methods) 856ev_default_loop (int methods)
833{ 857{
834 if (sigpipe [0] == sigpipe [1]) 858 if (sigpipe [0] == sigpipe [1])
894 if (method) 918 if (method)
895 postfork = 1; 919 postfork = 1;
896} 920}
897 921
898/*****************************************************************************/ 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}
899 935
900static void 936static void
901call_pending (EV_P) 937call_pending (EV_P)
902{ 938{
903 int pri; 939 int pri;
932 downheap ((WT *)timers, timercnt, 0); 968 downheap ((WT *)timers, timercnt, 0);
933 } 969 }
934 else 970 else
935 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 971 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
936 972
937 event (EV_A_ (W)w, EV_TIMEOUT); 973 ev_feed_event (EV_A_ (W)w, EV_TIMEOUT);
938 } 974 }
939} 975}
940 976
941static void 977static void
942periodics_reify (EV_P) 978periodics_reify (EV_P)
946 struct ev_periodic *w = periodics [0]; 982 struct ev_periodic *w = periodics [0];
947 983
948 assert (("inactive timer on periodic heap detected", ev_is_active (w))); 984 assert (("inactive timer on periodic heap detected", ev_is_active (w)));
949 985
950 /* 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 }
951 if (w->interval) 994 else if (w->interval)
952 { 995 {
953 ((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;
954 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));
955 downheap ((WT *)periodics, periodiccnt, 0); 998 downheap ((WT *)periodics, periodiccnt, 0);
956 } 999 }
957 else 1000 else
958 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */ 1001 ev_periodic_stop (EV_A_ w); /* nonrepeating: stop timer */
959 1002
960 event (EV_A_ (W)w, EV_PERIODIC); 1003 ev_feed_event (EV_A_ (W)w, EV_PERIODIC);
961 } 1004 }
962} 1005}
963 1006
964static void 1007static void
965periodics_reschedule (EV_P) 1008periodics_reschedule (EV_P)
969 /* adjust periodics after time jump */ 1012 /* adjust periodics after time jump */
970 for (i = 0; i < periodiccnt; ++i) 1013 for (i = 0; i < periodiccnt; ++i)
971 { 1014 {
972 struct ev_periodic *w = periodics [i]; 1015 struct ev_periodic *w = periodics [i];
973 1016
1017 if (w->reschedule_cb)
1018 ((WT)w)->at = w->reschedule_cb (w, rt_now);
974 if (w->interval) 1019 else if (w->interval)
975 {
976 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;
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 } 1021 }
1022
1023 /* now rebuild the heap */
1024 for (i = periodiccnt >> 1; i--; )
1025 downheap ((WT *)periodics, periodiccnt, i);
987} 1026}
988 1027
989inline int 1028inline int
990time_update_monotonic (EV_P) 1029time_update_monotonic (EV_P)
991{ 1030{
1087 /* update fd-related kernel structures */ 1126 /* update fd-related kernel structures */
1088 fd_reify (EV_A); 1127 fd_reify (EV_A);
1089 1128
1090 /* calculate blocking time */ 1129 /* calculate blocking time */
1091 1130
1092 /* 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
1093 always have timers, we just calculate it always */ 1132 always have timers, we just calculate it always */
1094#if EV_USE_MONOTONIC 1133#if EV_USE_MONOTONIC
1095 if (expect_true (have_monotonic)) 1134 if (expect_true (have_monotonic))
1096 time_update_monotonic (EV_A); 1135 time_update_monotonic (EV_A);
1097 else 1136 else
1130 /* queue pending timers and reschedule them */ 1169 /* queue pending timers and reschedule them */
1131 timers_reify (EV_A); /* relative timers called last */ 1170 timers_reify (EV_A); /* relative timers called last */
1132 periodics_reify (EV_A); /* absolute timers called first */ 1171 periodics_reify (EV_A); /* absolute timers called first */
1133 1172
1134 /* queue idle watchers unless io or timers are pending */ 1173 /* queue idle watchers unless io or timers are pending */
1135 if (!pendingcnt) 1174 if (idlecnt && !any_pending (EV_A))
1136 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); 1175 queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE);
1137 1176
1138 /* queue check watchers, to be executed first */ 1177 /* queue check watchers, to be executed first */
1139 if (checkcnt) 1178 if (checkcnt)
1140 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); 1179 queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK);
1215 return; 1254 return;
1216 1255
1217 assert (("ev_io_start called with negative fd", fd >= 0)); 1256 assert (("ev_io_start called with negative fd", fd >= 0));
1218 1257
1219 ev_start (EV_A_ (W)w, 1); 1258 ev_start (EV_A_ (W)w, 1);
1220 array_needsize (anfds, anfdmax, fd + 1, anfds_init); 1259 array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init);
1221 wlist_add ((WL *)&anfds[fd].head, (WL)w); 1260 wlist_add ((WL *)&anfds[fd].head, (WL)w);
1222 1261
1223 fd_change (EV_A_ fd); 1262 fd_change (EV_A_ fd);
1224} 1263}
1225 1264
1245 ((WT)w)->at += mn_now; 1284 ((WT)w)->at += mn_now;
1246 1285
1247 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.));
1248 1287
1249 ev_start (EV_A_ (W)w, ++timercnt); 1288 ev_start (EV_A_ (W)w, ++timercnt);
1250 array_needsize (timers, timermax, timercnt, (void)); 1289 array_needsize (struct ev_timer *, timers, timermax, timercnt, (void));
1251 timers [timercnt - 1] = w; 1290 timers [timercnt - 1] = w;
1252 upheap ((WT *)timers, timercnt - 1); 1291 upheap ((WT *)timers, timercnt - 1);
1253 1292
1254 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1293 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1255} 1294}
1295ev_periodic_start (EV_P_ struct ev_periodic *w) 1334ev_periodic_start (EV_P_ struct ev_periodic *w)
1296{ 1335{
1297 if (ev_is_active (w)) 1336 if (ev_is_active (w))
1298 return; 1337 return;
1299 1338
1339 if (w->reschedule_cb)
1340 ((WT)w)->at = w->reschedule_cb (w, rt_now);
1341 else if (w->interval)
1342 {
1300 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.));
1301
1302 /* 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 */
1303 if (w->interval)
1304 ((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 }
1305 1347
1306 ev_start (EV_A_ (W)w, ++periodiccnt); 1348 ev_start (EV_A_ (W)w, ++periodiccnt);
1307 array_needsize (periodics, periodicmax, periodiccnt, (void)); 1349 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void));
1308 periodics [periodiccnt - 1] = w; 1350 periodics [periodiccnt - 1] = w;
1309 upheap ((WT *)periodics, periodiccnt - 1); 1351 upheap ((WT *)periodics, periodiccnt - 1);
1310 1352
1311 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1353 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1312} 1354}
1328 1370
1329 ev_stop (EV_A_ (W)w); 1371 ev_stop (EV_A_ (W)w);
1330} 1372}
1331 1373
1332void 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
1333ev_idle_start (EV_P_ struct ev_idle *w) 1382ev_idle_start (EV_P_ struct ev_idle *w)
1334{ 1383{
1335 if (ev_is_active (w)) 1384 if (ev_is_active (w))
1336 return; 1385 return;
1337 1386
1338 ev_start (EV_A_ (W)w, ++idlecnt); 1387 ev_start (EV_A_ (W)w, ++idlecnt);
1339 array_needsize (idles, idlemax, idlecnt, (void)); 1388 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void));
1340 idles [idlecnt - 1] = w; 1389 idles [idlecnt - 1] = w;
1341} 1390}
1342 1391
1343void 1392void
1344ev_idle_stop (EV_P_ struct ev_idle *w) 1393ev_idle_stop (EV_P_ struct ev_idle *w)
1356{ 1405{
1357 if (ev_is_active (w)) 1406 if (ev_is_active (w))
1358 return; 1407 return;
1359 1408
1360 ev_start (EV_A_ (W)w, ++preparecnt); 1409 ev_start (EV_A_ (W)w, ++preparecnt);
1361 array_needsize (prepares, preparemax, preparecnt, (void)); 1410 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void));
1362 prepares [preparecnt - 1] = w; 1411 prepares [preparecnt - 1] = w;
1363} 1412}
1364 1413
1365void 1414void
1366ev_prepare_stop (EV_P_ struct ev_prepare *w) 1415ev_prepare_stop (EV_P_ struct ev_prepare *w)
1378{ 1427{
1379 if (ev_is_active (w)) 1428 if (ev_is_active (w))
1380 return; 1429 return;
1381 1430
1382 ev_start (EV_A_ (W)w, ++checkcnt); 1431 ev_start (EV_A_ (W)w, ++checkcnt);
1383 array_needsize (checks, checkmax, checkcnt, (void)); 1432 array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void));
1384 checks [checkcnt - 1] = w; 1433 checks [checkcnt - 1] = w;
1385} 1434}
1386 1435
1387void 1436void
1388ev_check_stop (EV_P_ struct ev_check *w) 1437ev_check_stop (EV_P_ struct ev_check *w)
1409 return; 1458 return;
1410 1459
1411 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));
1412 1461
1413 ev_start (EV_A_ (W)w, 1); 1462 ev_start (EV_A_ (W)w, 1);
1414 array_needsize (signals, signalmax, w->signum, signals_init); 1463 array_needsize (ANSIG, signals, signalmax, w->signum, signals_init);
1415 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); 1464 wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w);
1416 1465
1417 if (!((WL)w)->next) 1466 if (!((WL)w)->next)
1418 { 1467 {
1419#if WIN32 1468#if WIN32
1502} 1551}
1503 1552
1504void 1553void
1505ev_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)
1506{ 1555{
1507 struct ev_once *once = ev_malloc (sizeof (struct ev_once)); 1556 struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once));
1508 1557
1509 if (!once) 1558 if (!once)
1510 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); 1559 cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg);
1511 else 1560 else
1512 { 1561 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines