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

Comparing libev/ev.c (file contents):
Revision 1.111 by root, Mon Nov 12 06:34:49 2007 UTC vs.
Revision 1.114 by root, Mon Nov 12 20:03:39 2007 UTC

167#define expect_true(expr) expect ((expr) != 0, 1) 167#define expect_true(expr) expect ((expr) != 0, 1)
168 168
169#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1) 169#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
170#define ABSPRI(w) ((w)->priority - EV_MINPRI) 170#define ABSPRI(w) ((w)->priority - EV_MINPRI)
171 171
172#define EMPTY /* required for microsofts broken pseudo-c compiler */ 172#define EMPTY0 /* required for microsofts broken pseudo-c compiler */
173#define EMPTY2(a,b) /* used to suppress some warnings */
173 174
174typedef struct ev_watcher *W; 175typedef struct ev_watcher *W;
175typedef struct ev_watcher_list *WL; 176typedef struct ev_watcher_list *WL;
176typedef struct ev_watcher_time *WT; 177typedef struct ev_watcher_time *WT;
177 178
365 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents; 366 pendings [ABSPRI (w_)][w_->pending - 1].events |= revents;
366 return; 367 return;
367 } 368 }
368 369
369 w_->pending = ++pendingcnt [ABSPRI (w_)]; 370 w_->pending = ++pendingcnt [ABSPRI (w_)];
370 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], (void)); 371 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2);
371 pendings [ABSPRI (w_)][w_->pending - 1].w = w_; 372 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
372 pendings [ABSPRI (w_)][w_->pending - 1].events = revents; 373 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
373} 374}
374 375
375static void 376static void
445 return; 446 return;
446 447
447 anfds [fd].reify = 1; 448 anfds [fd].reify = 1;
448 449
449 ++fdchangecnt; 450 ++fdchangecnt;
450 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void)); 451 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, EMPTY2);
451 fdchanges [fdchangecnt - 1] = fd; 452 fdchanges [fdchangecnt - 1] = fd;
452} 453}
453 454
454static void 455static void
455fd_kill (EV_P_ int fd) 456fd_kill (EV_P_ int fd)
770 ev_rt_now = ev_time (); 771 ev_rt_now = ev_time ();
771 mn_now = get_clock (); 772 mn_now = get_clock ();
772 now_floor = mn_now; 773 now_floor = mn_now;
773 rtmn_diff = ev_rt_now - mn_now; 774 rtmn_diff = ev_rt_now - mn_now;
774 775
775 if (!(flags & EVMETHOD_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS")) 776 if (!(flags & EVFLAG_NOENV) && !enable_secure () && getenv ("LIBEV_FLAGS"))
776 flags = atoi (getenv ("LIBEV_FLAGS")); 777 flags = atoi (getenv ("LIBEV_FLAGS"));
777 778
778 if (!(flags & 0x0000ffff)) 779 if (!(flags & 0x0000ffff))
779 flags |= 0x0000ffff; 780 flags |= 0x0000ffff;
780 781
817 818
818 for (i = NUMPRI; i--; ) 819 for (i = NUMPRI; i--; )
819 array_free (pending, [i]); 820 array_free (pending, [i]);
820 821
821 /* have to use the microsoft-never-gets-it-right macro */ 822 /* have to use the microsoft-never-gets-it-right macro */
822 array_free (fdchange, EMPTY); 823 array_free (fdchange, EMPTY0);
823 array_free (timer, EMPTY); 824 array_free (timer, EMPTY0);
824#if EV_PERIODICS 825#if EV_PERIODICS
825 array_free (periodic, EMPTY); 826 array_free (periodic, EMPTY0);
826#endif 827#endif
827 array_free (idle, EMPTY); 828 array_free (idle, EMPTY0);
828 array_free (prepare, EMPTY); 829 array_free (prepare, EMPTY0);
829 array_free (check, EMPTY); 830 array_free (check, EMPTY0);
830 831
831 method = 0; 832 method = 0;
832} 833}
833 834
834static void 835static void
1341 ((WT)w)->at += mn_now; 1342 ((WT)w)->at += mn_now;
1342 1343
1343 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); 1344 assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.));
1344 1345
1345 ev_start (EV_A_ (W)w, ++timercnt); 1346 ev_start (EV_A_ (W)w, ++timercnt);
1346 array_needsize (struct ev_timer *, timers, timermax, timercnt, (void)); 1347 array_needsize (struct ev_timer *, timers, timermax, timercnt, EMPTY2);
1347 timers [timercnt - 1] = w; 1348 timers [timercnt - 1] = w;
1348 upheap ((WT *)timers, timercnt - 1); 1349 upheap ((WT *)timers, timercnt - 1);
1349 1350
1350 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); 1351 assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w));
1351} 1352}
1382 } 1383 }
1383 else 1384 else
1384 ev_timer_stop (EV_A_ w); 1385 ev_timer_stop (EV_A_ w);
1385 } 1386 }
1386 else if (w->repeat) 1387 else if (w->repeat)
1388 {
1389 w->at = w->repeat;
1387 ev_timer_start (EV_A_ w); 1390 ev_timer_start (EV_A_ w);
1391 }
1388} 1392}
1389 1393
1390#if EV_PERIODICS 1394#if EV_PERIODICS
1391void 1395void
1392ev_periodic_start (EV_P_ struct ev_periodic *w) 1396ev_periodic_start (EV_P_ struct ev_periodic *w)
1402 /* this formula differs from the one in periodic_reify because we do not always round up */ 1406 /* this formula differs from the one in periodic_reify because we do not always round up */
1403 ((WT)w)->at += ceil ((ev_rt_now - ((WT)w)->at) / w->interval) * w->interval; 1407 ((WT)w)->at += ceil ((ev_rt_now - ((WT)w)->at) / w->interval) * w->interval;
1404 } 1408 }
1405 1409
1406 ev_start (EV_A_ (W)w, ++periodiccnt); 1410 ev_start (EV_A_ (W)w, ++periodiccnt);
1407 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void)); 1411 array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, EMPTY2);
1408 periodics [periodiccnt - 1] = w; 1412 periodics [periodiccnt - 1] = w;
1409 upheap ((WT *)periodics, periodiccnt - 1); 1413 upheap ((WT *)periodics, periodiccnt - 1);
1410 1414
1411 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); 1415 assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w));
1412} 1416}
1443{ 1447{
1444 if (ev_is_active (w)) 1448 if (ev_is_active (w))
1445 return; 1449 return;
1446 1450
1447 ev_start (EV_A_ (W)w, ++idlecnt); 1451 ev_start (EV_A_ (W)w, ++idlecnt);
1448 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void)); 1452 array_needsize (struct ev_idle *, idles, idlemax, idlecnt, EMPTY2);
1449 idles [idlecnt - 1] = w; 1453 idles [idlecnt - 1] = w;
1450} 1454}
1451 1455
1452void 1456void
1453ev_idle_stop (EV_P_ struct ev_idle *w) 1457ev_idle_stop (EV_P_ struct ev_idle *w)
1465{ 1469{
1466 if (ev_is_active (w)) 1470 if (ev_is_active (w))
1467 return; 1471 return;
1468 1472
1469 ev_start (EV_A_ (W)w, ++preparecnt); 1473 ev_start (EV_A_ (W)w, ++preparecnt);
1470 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void)); 1474 array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, EMPTY2);
1471 prepares [preparecnt - 1] = w; 1475 prepares [preparecnt - 1] = w;
1472} 1476}
1473 1477
1474void 1478void
1475ev_prepare_stop (EV_P_ struct ev_prepare *w) 1479ev_prepare_stop (EV_P_ struct ev_prepare *w)
1487{ 1491{
1488 if (ev_is_active (w)) 1492 if (ev_is_active (w))
1489 return; 1493 return;
1490 1494
1491 ev_start (EV_A_ (W)w, ++checkcnt); 1495 ev_start (EV_A_ (W)w, ++checkcnt);
1492 array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void)); 1496 array_needsize (struct ev_check *, checks, checkmax, checkcnt, EMPTY2);
1493 checks [checkcnt - 1] = w; 1497 checks [checkcnt - 1] = w;
1494} 1498}
1495 1499
1496void 1500void
1497ev_check_stop (EV_P_ struct ev_check *w) 1501ev_check_stop (EV_P_ struct ev_check *w)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines