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

Comparing libev/ev.c (file contents):
Revision 1.330 by root, Tue Mar 9 08:46:17 2010 UTC vs.
Revision 1.331 by root, Tue Mar 9 08:55:03 2010 UTC

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
531static void noinline
532ev_printerr (const char *msg)
533{
534 write (STDERR_FILENO, msg, strlen (msg));
535}
536#endif
537
529static void (*syserr_cb)(const char *msg); 538static void (*syserr_cb)(const char *msg);
530 539
531void 540void
532ev_set_syserr_cb (void (*cb)(const char *msg)) 541ev_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 }
586 ptr = alloc (ptr, size); 596 ptr = alloc (ptr, size);
587 597
588 if (!ptr && size) 598 if (!ptr && size)
589 { 599 {
590#if EV_AVOID_STDIO 600#if EV_AVOID_STDIO
591 write (STDERR_FILENO, "libev: memory allocation failed, aborting.", 601 ev_printerr ("libev: memory allocation failed, aborting.\n");
592 sizeof ("libev: memory allocation failed, aborting.") - 1);
593#else 602#else
594 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); 603 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size);
595#endif 604#endif
596 abort (); 605 abort ();
597 } 606 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines