… | |
… | |
184 | # define WIN32_LEAN_AND_MEAN |
184 | # define WIN32_LEAN_AND_MEAN |
185 | # include <windows.h> |
185 | # include <windows.h> |
186 | # ifndef EV_SELECT_IS_WINSOCKET |
186 | # ifndef EV_SELECT_IS_WINSOCKET |
187 | # define EV_SELECT_IS_WINSOCKET 1 |
187 | # define EV_SELECT_IS_WINSOCKET 1 |
188 | # endif |
188 | # endif |
|
|
189 | # undef EV_AVOID_STDIO |
189 | #endif |
190 | #endif |
190 | |
191 | |
191 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
192 | /* this block tries to deduce configuration from header-defined symbols and defaults */ |
192 | |
193 | |
193 | /* try to deduce the maximum number of signals on this platform */ |
194 | /* try to deduce the maximum number of signals on this platform */ |
… | |
… | |
524 | # include "ev_win32.c" |
525 | # include "ev_win32.c" |
525 | #endif |
526 | #endif |
526 | |
527 | |
527 | /*****************************************************************************/ |
528 | /*****************************************************************************/ |
528 | |
529 | |
|
|
530 | #if EV_AVOID_STDIO |
|
|
531 | static void noinline |
|
|
532 | ev_printerr (const char *msg) |
|
|
533 | { |
|
|
534 | write (STDERR_FILENO, msg, strlen (msg)); |
|
|
535 | } |
|
|
536 | #endif |
|
|
537 | |
529 | static void (*syserr_cb)(const char *msg); |
538 | static void (*syserr_cb)(const char *msg); |
530 | |
539 | |
531 | void |
540 | void |
532 | ev_set_syserr_cb (void (*cb)(const char *msg)) |
541 | ev_set_syserr_cb (void (*cb)(const char *msg)) |
533 | { |
542 | { |
… | |
… | |
543 | if (syserr_cb) |
552 | if (syserr_cb) |
544 | syserr_cb (msg); |
553 | syserr_cb (msg); |
545 | else |
554 | else |
546 | { |
555 | { |
547 | #if EV_AVOID_STDIO |
556 | #if EV_AVOID_STDIO |
548 | write (STDERR_FILENO, msg, strlen (msg)); |
|
|
549 | write (STDERR_FILENO, ": ", 2); |
|
|
550 | msg = strerror (errno); |
557 | const char *err = strerror (errno); |
551 | write (STDERR_FILENO, msg, strlen (msg)); |
558 | |
552 | write (STDERR_FILENO, "\n", 1); |
559 | ev_printerr (msg); |
|
|
560 | ev_printerr (": "); |
|
|
561 | ev_printerr (err); |
|
|
562 | ev_printerr ("\n"); |
553 | #else |
563 | #else |
554 | perror (msg); |
564 | perror (msg); |
555 | #endif |
565 | #endif |
556 | abort (); |
566 | abort (); |
557 | } |
567 | } |
… | |
… | |
562 | { |
572 | { |
563 | /* some systems, notably openbsd and darwin, fail to properly |
573 | /* some systems, notably openbsd and darwin, fail to properly |
564 | * implement realloc (x, 0) (as required by both ansi c-98 and |
574 | * implement realloc (x, 0) (as required by both ansi c-98 and |
565 | * the single unix specification, so work around them here. |
575 | * the single unix specification, so work around them here. |
566 | */ |
576 | */ |
567 | |
|
|
568 | if (size) |
577 | if (size) |
569 | return realloc (ptr, size); |
578 | return realloc (ptr, size); |
570 | |
579 | |
571 | free (ptr); |
580 | free (ptr); |
572 | return 0; |
581 | return 0; |
… | |
… | |
586 | ptr = alloc (ptr, size); |
595 | ptr = alloc (ptr, size); |
587 | |
596 | |
588 | if (!ptr && size) |
597 | if (!ptr && size) |
589 | { |
598 | { |
590 | #if EV_AVOID_STDIO |
599 | #if EV_AVOID_STDIO |
591 | write (STDERR_FILENO, "libev: memory allocation failed, aborting.", |
600 | ev_printerr ("libev: memory allocation failed, aborting.\n"); |
592 | sizeof ("libev: memory allocation failed, aborting.") - 1); |
|
|
593 | #else |
601 | #else |
594 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
602 | fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); |
595 | #endif |
603 | #endif |
596 | abort (); |
604 | abort (); |
597 | } |
605 | } |