diff options
author | root <root> | 2010-03-09 08:46:16 +0000 |
---|---|---|
committer | root <root> | 2010-03-09 08:46:16 +0000 |
commit | 2d932586ceeb88f6691b08c80b741a3bffa04b3c (patch) | |
tree | 85edb6ac78f08123f7aa254076b11329b8609b12 /ev.c | |
parent | ca720a782c7de23c2738672ceb40f9056f7ccc6c (diff) |
ev_avoid_stdio
Diffstat (limited to 'ev.c')
-rw-r--r-- | ev.c | 60 |
1 files changed, 47 insertions, 13 deletions
@@ -544,7 +544,15 @@ ev_syserr (const char *msg) syserr_cb (msg); else { +#if EV_AVOID_STDIO + write (STDERR_FILENO, msg, strlen (msg)); + write (STDERR_FILENO, ": ", 2); + msg = strerror (errno); + write (STDERR_FILENO, msg, strlen (msg)); + write (STDERR_FILENO, "\n", 1); +#else perror (msg); +#endif abort (); } } @@ -579,7 +587,12 @@ ev_realloc (void *ptr, long size) if (!ptr && size) { +#if EV_AVOID_STDIO + write (STDERR_FILENO, "libev: memory allocation failed, aborting.", + sizeof ("libev: memory allocation failed, aborting.") - 1); +#else fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); +#endif abort (); } @@ -2994,24 +3007,45 @@ infy_cb (EV_P_ ev_io *w, int revents) } } -inline_size void -check_2625 (EV_P) +inline_size unsigned int +ev_linux_version (void) { - /* kernels < 2.6.25 are borked - * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html - */ struct utsname buf; - int major, minor, micro; + unsigned int v; + int i; + char *p = buf.release; if (uname (&buf)) - return; + return 0; - if (sscanf (buf.release, "%d.%d.%d", &major, &minor, µ) != 3) - return; + for (i = 3+1; --i; ) + { + unsigned int c = 0; - if (major < 2 - || (major == 2 && minor < 6) - || (major == 2 && minor == 6 && micro < 25)) + for (;;) + { + if (*p >= '0' && *p <= '9') + c = c * 10 + *p++ - '0'; + else + { + p += *p == '.'; + break; + } + } + + v = (v << 8) | c; + } + + return v; +} + +inline_size void +ev_check_2625 (EV_P) +{ + /* kernels < 2.6.25 are borked + * http://www.ussg.indiana.edu/hypermail/linux/kernel/0711.3/1208.html + */ + if (ev_linux_version () < 0x020619) return; fs_2625 = 1; @@ -3036,7 +3070,7 @@ infy_init (EV_P) fs_fd = -1; - check_2625 (EV_A); + ev_check_2625 (EV_A); fs_fd = infy_newfd (); |