X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/678c8c54d0ce967d8f1db3e575aed61879279975..f4f2094b6a36eac7778c5091ee4160a2f403e808:/event.c diff --git a/event.c b/event.c index 75cd06b..04bd373 100644 --- a/event.c +++ b/event.c @@ -32,7 +32,9 @@ #include #include #include +#include +#include "ev.h" #include "event.h" #if EV_MULTIPLICITY @@ -49,7 +51,7 @@ struct event_base int dummy; }; -static struct event_base x_base, *x_cur; +static struct event_base *x_cur; static void tv_set (struct timeval *tv, ev_tstamp at) @@ -82,9 +84,14 @@ const char *event_get_method (void) void *event_init (void) { #if EV_MULTIPLICITY - x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); + if (x_cur) + x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); + else + x_cur = ev_default_loop (EVMETHOD_AUTO); #else - x_cur = &x_base; + assert (("multiple event bases not supported when not compiled with EV_MULTIPLICITY", !x_cur)); + + x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO); #endif return x_cur;