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

Comparing libev/ev.c (file contents):
Revision 1.230 by root, Fri May 2 08:13:16 2008 UTC vs.
Revision 1.232 by root, Tue May 6 15:29:58 2008 UTC

520 } 520 }
521} 521}
522 522
523/*****************************************************************************/ 523/*****************************************************************************/
524 524
525#define MALLOC_ROUND 4096 // prefer to allocate in chunks of this size, must be 2**n and >> 4 longs
526
525int inline_size 527int inline_size
526array_nextsize (int elem, int cur, int cnt) 528array_nextsize (int elem, int cur, int cnt)
527{ 529{
528 int ncur = cur + 1; 530 int ncur = cur + 1;
529 531
530 do 532 do
531 ncur <<= 1; 533 ncur <<= 1;
532 while (cnt > ncur); 534 while (cnt > ncur);
533 535
534 /* if size > 4096, round to 4096 - 4 * longs to accomodate malloc overhead */ 536 /* if size is large, round to MALLOC_ROUND - 4 * longs to accomodate malloc overhead */
535 if (elem * ncur > 4096) 537 if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4)
536 { 538 {
537 ncur *= elem; 539 ncur *= elem;
538 ncur = (ncur + elem + 4095 + sizeof (void *) * 4) & ~4095; 540 ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1);
539 ncur = ncur - sizeof (void *) * 4; 541 ncur = ncur - sizeof (void *) * 4;
540 ncur /= elem; 542 ncur /= elem;
541 } 543 }
542 544
543 return ncur; 545 return ncur;
912pipecb (EV_P_ ev_io *iow, int revents) 914pipecb (EV_P_ ev_io *iow, int revents)
913{ 915{
914#if EV_USE_EVENTFD 916#if EV_USE_EVENTFD
915 if (evfd >= 0) 917 if (evfd >= 0)
916 { 918 {
917 uint64_t counter = 1; 919 uint64_t counter;
918 read (evfd, &counter, sizeof (uint64_t)); 920 read (evfd, &counter, sizeof (uint64_t));
919 } 921 }
920 else 922 else
921#endif 923#endif
922 { 924 {
1523periodics_reschedule (EV_P) 1525periodics_reschedule (EV_P)
1524{ 1526{
1525 int i; 1527 int i;
1526 1528
1527 /* adjust periodics after time jump */ 1529 /* adjust periodics after time jump */
1528 for (i = 0; i < periodiccnt; ++i) 1530 for (i = 1; i <= periodiccnt; ++i)
1529 { 1531 {
1530 ev_periodic *w = (ev_periodic *)periodics [i]; 1532 ev_periodic *w = (ev_periodic *)periodics [i];
1531 1533
1532 if (w->reschedule_cb) 1534 if (w->reschedule_cb)
1533 ev_at (w) = w->reschedule_cb (w, ev_rt_now); 1535 ev_at (w) = w->reschedule_cb (w, ev_rt_now);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines