… | |
… | |
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 | |
|
|
365 | static void * |
|
|
366 | ev_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 | |
365 | static void *(*alloc)(void *ptr, long size); |
380 | static void *(*alloc)(void *ptr, long size) = ev_realloc_emul; |
366 | |
381 | |
367 | void |
382 | void |
368 | ev_set_allocator (void *(*cb)(void *ptr, long size)) |
383 | ev_set_allocator (void *(*cb)(void *ptr, long size)) |
369 | { |
384 | { |
370 | alloc = cb; |
385 | alloc = cb; |
371 | } |
386 | } |
372 | |
387 | |
373 | inline_speed void * |
388 | inline_speed void * |
374 | ev_realloc (void *ptr, long size) |
389 | ev_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 */ |
744 | void inline_speed |
760 | void inline_speed |
745 | upheap (WT *heap, int k) |
761 | upheap (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 */ |
765 | void inline_speed |
782 | void inline_speed |
766 | downheap (WT *heap, int N, int k) |
783 | downheap (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 |
1273 | void inline_size infy_fork (EV_P); |
1291 | void inline_size infy_fork (EV_P); |
|
|
1292 | #endif |
1274 | |
1293 | |
1275 | void inline_size |
1294 | void inline_size |
1276 | loop_fork (EV_P) |
1295 | loop_fork (EV_P) |
1277 | { |
1296 | { |
1278 | #if EV_USE_PORT |
1297 | #if EV_USE_PORT |