… | |
… | |
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 (); |
… | |
… | |
1170 | if (!(flags & EVFLAG_NOENV) |
1185 | if (!(flags & EVFLAG_NOENV) |
1171 | && !enable_secure () |
1186 | && !enable_secure () |
1172 | && getenv ("LIBEV_FLAGS")) |
1187 | && getenv ("LIBEV_FLAGS")) |
1173 | flags = atoi (getenv ("LIBEV_FLAGS")); |
1188 | flags = atoi (getenv ("LIBEV_FLAGS")); |
1174 | |
1189 | |
1175 | if (!(flags & 0x0000ffffUL)) |
1190 | if (!(flags & 0x0000ffffU)) |
1176 | flags |= ev_recommended_backends (); |
1191 | flags |= ev_recommended_backends (); |
1177 | |
1192 | |
1178 | #if EV_USE_PORT |
1193 | #if EV_USE_PORT |
1179 | if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); |
1194 | if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); |
1180 | #endif |
1195 | #endif |