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

Comparing libev/ev.c (file contents):
Revision 1.222 by root, Sun Apr 6 12:45:58 2008 UTC vs.
Revision 1.227 by root, Fri May 2 07:20:01 2008 UTC

300# define expect(expr,value) __builtin_expect ((expr),(value)) 300# define expect(expr,value) __builtin_expect ((expr),(value))
301# define noinline __attribute__ ((noinline)) 301# define noinline __attribute__ ((noinline))
302#else 302#else
303# define expect(expr,value) (expr) 303# define expect(expr,value) (expr)
304# define noinline 304# define noinline
305# if __STDC_VERSION__ < 199901L 305# if __STDC_VERSION__ < 199901L && __GNUC__ < 2
306# define inline 306# define inline
307# endif 307# endif
308#endif 308#endif
309 309
310#define expect_false(expr) expect ((expr) != 0, 0) 310#define expect_false(expr) expect ((expr) != 0, 0)
360 perror (msg); 360 perror (msg);
361 abort (); 361 abort ();
362 } 362 }
363} 363}
364 364
365static void *
366ev_realloc_emul (void *ptr, long size)
367{
368 /* some systems, notably openbsd and darwin, fail to properly
369 * implement realloc (x, 0) (as required by both ansi c-98 and
370 * the single unix specification, so work around them here.
371 */
372
373 if (size)
374 return realloc (ptr, size);
375
376 free (ptr);
377 return 0;
378}
379
365static void *(*alloc)(void *ptr, long size); 380static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
366 381
367void 382void
368ev_set_allocator (void *(*cb)(void *ptr, long size)) 383ev_set_allocator (void *(*cb)(void *ptr, long size))
369{ 384{
370 alloc = cb; 385 alloc = cb;
371} 386}
372 387
373inline_speed void * 388inline_speed void *
374ev_realloc (void *ptr, long size) 389ev_realloc (void *ptr, long size)
375{ 390{
376 ptr = alloc ? alloc (ptr, size) : realloc (ptr, size); 391 ptr = alloc (ptr, size);
377 392
378 if (!ptr && size) 393 if (!ptr && size)
379 { 394 {
380 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); 395 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size);
381 abort (); 396 abort ();
739 } 754 }
740} 755}
741 756
742/*****************************************************************************/ 757/*****************************************************************************/
743 758
759/* towards the root */
744void inline_speed 760void inline_speed
745upheap (WT *heap, int k) 761upheap (WT *heap, int k)
746{ 762{
747 WT w = heap [k]; 763 WT w = heap [k];
748 764
760 776
761 heap [k] = w; 777 heap [k] = w;
762 ((W)heap [k])->active = k + 1; 778 ((W)heap [k])->active = k + 1;
763} 779}
764 780
781/* away from the root */
765void inline_speed 782void inline_speed
766downheap (WT *heap, int N, int k) 783downheap (WT *heap, int N, int k)
767{ 784{
768 WT w = heap [k]; 785 WT w = heap [k];
769 786
1170 if (!(flags & EVFLAG_NOENV) 1187 if (!(flags & EVFLAG_NOENV)
1171 && !enable_secure () 1188 && !enable_secure ()
1172 && getenv ("LIBEV_FLAGS")) 1189 && getenv ("LIBEV_FLAGS"))
1173 flags = atoi (getenv ("LIBEV_FLAGS")); 1190 flags = atoi (getenv ("LIBEV_FLAGS"));
1174 1191
1175 if (!(flags & 0x0000ffffUL)) 1192 if (!(flags & 0x0000ffffU))
1176 flags |= ev_recommended_backends (); 1193 flags |= ev_recommended_backends ();
1177 1194
1178#if EV_USE_PORT 1195#if EV_USE_PORT
1179 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); 1196 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags);
1180#endif 1197#endif
1268#endif 1285#endif
1269 1286
1270 backend = 0; 1287 backend = 0;
1271} 1288}
1272 1289
1290#if EV_USE_INOTIFY
1273void inline_size infy_fork (EV_P); 1291void inline_size infy_fork (EV_P);
1292#endif
1274 1293
1275void inline_size 1294void inline_size
1276loop_fork (EV_P) 1295loop_fork (EV_P)
1277{ 1296{
1278#if EV_USE_PORT 1297#if EV_USE_PORT

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines