summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2010-03-09 08:46:16 +0000
committerroot <root>2010-03-09 08:46:16 +0000
commit2d932586ceeb88f6691b08c80b741a3bffa04b3c (patch)
tree85edb6ac78f08123f7aa254076b11329b8609b12 /ev.c
parentca720a782c7de23c2738672ceb40f9056f7ccc6c (diff)
ev_avoid_stdio
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c60
1 files changed, 47 insertions, 13 deletions
diff --git a/ev.c b/ev.c
index 2568f7b..280de7e 100644
--- a/ev.c
+++ b/ev.c
@@ -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, &micro) != 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 ();