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

Comparing libev/ev.c (file contents):
Revision 1.231 by root, Mon May 5 20:47:33 2008 UTC vs.
Revision 1.233 by root, Tue May 6 23:34:16 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 {
2114 if (w->wd < 0) 2116 if (w->wd < 0)
2115 { 2117 {
2116 ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */ 2118 ev_timer_start (EV_A_ &w->timer); /* this is not race-free, so we still need to recheck periodically */
2117 2119
2118 /* monitor some parent directory for speedup hints */ 2120 /* monitor some parent directory for speedup hints */
2121 /* note that exceeding the hardcoded limit is not a correctness issue, */
2122 /* but an efficiency issue only */
2119 if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096) 2123 if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096)
2120 { 2124 {
2121 char path [4096]; 2125 char path [4096];
2122 strcpy (path, w->path); 2126 strcpy (path, w->path);
2123 2127

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines