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

Comparing libev/ev.c (file contents):
Revision 1.329 by root, Tue Feb 16 09:32:39 2010 UTC vs.
Revision 1.330 by root, Tue Mar 9 08:46:17 2010 UTC

542 542
543 if (syserr_cb) 543 if (syserr_cb)
544 syserr_cb (msg); 544 syserr_cb (msg);
545 else 545 else
546 { 546 {
547#if EV_AVOID_STDIO
548 write (STDERR_FILENO, msg, strlen (msg));
549 write (STDERR_FILENO, ": ", 2);
550 msg = strerror (errno);
551 write (STDERR_FILENO, msg, strlen (msg));
552 write (STDERR_FILENO, "\n", 1);
553#else
547 perror (msg); 554 perror (msg);
555#endif
548 abort (); 556 abort ();
549 } 557 }
550} 558}
551 559
552static void * 560static void *
577{ 585{
578 ptr = alloc (ptr, size); 586 ptr = alloc (ptr, size);
579 587
580 if (!ptr && size) 588 if (!ptr && size)
581 { 589 {
590#if EV_AVOID_STDIO
591 write (STDERR_FILENO, "libev: memory allocation failed, aborting.",
592 sizeof ("libev: memory allocation failed, aborting.") - 1);
593#else
582 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); 594 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size);
595#endif
583 abort (); 596 abort ();
584 } 597 }
585 598
586 return ptr; 599 return ptr;
587} 600}
2992 infy_wd (EV_A_ ev->wd, ev->wd, ev); 3005 infy_wd (EV_A_ ev->wd, ev->wd, ev);
2993 ofs += sizeof (struct inotify_event) + ev->len; 3006 ofs += sizeof (struct inotify_event) + ev->len;
2994 } 3007 }
2995} 3008}
2996 3009
3010inline_size unsigned int
3011ev_linux_version (void)
3012{
3013 struct utsname buf;
3014 unsigned int v;
3015 int i;
3016 char *p = buf.release;
3017
3018 if (uname (&buf))
3019 return 0;
3020
3021 for (i = 3+1; --i; )
3022 {
3023 unsigned int c = 0;
3024
3025 for (;;)
3026 {
3027 if (*p >= '0' && *p <= '9')
3028 c = c * 10 + *p++ - '0';
3029 else
3030 {
3031 p += *p == '.';
3032 break;
3033 }
3034 }
3035
3036 v = (v << 8) | c;
3037 }
3038
3039 return v;
3040}
3041
2997inline_size void 3042inline_size void
2998check_2625 (EV_P) 3043ev_check_2625 (EV_P)
2999{ 3044{
3000 /* kernels < 2.6.25 are borked 3045 /* kernels < 2.6.25 are borked
3001 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html 3046 * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html
3002 */ 3047 */
3003 struct utsname buf; 3048 if (ev_linux_version () < 0x020619)
3004 int major, minor, micro;
3005
3006 if (uname (&buf))
3007 return;
3008
3009 if (sscanf (buf.release, "%d.%d.%d", &major, &minor, &micro) != 3)
3010 return;
3011
3012 if (major < 2
3013 || (major == 2 && minor < 6)
3014 || (major == 2 && minor == 6 && micro < 25))
3015 return; 3049 return;
3016 3050
3017 fs_2625 = 1; 3051 fs_2625 = 1;
3018} 3052}
3019 3053
3034 if (fs_fd != -2) 3068 if (fs_fd != -2)
3035 return; 3069 return;
3036 3070
3037 fs_fd = -1; 3071 fs_fd = -1;
3038 3072
3039 check_2625 (EV_A); 3073 ev_check_2625 (EV_A);
3040 3074
3041 fs_fd = infy_newfd (); 3075 fs_fd = infy_newfd ();
3042 3076
3043 if (fs_fd >= 0) 3077 if (fs_fd >= 0)
3044 { 3078 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines