X-Git-Url: https://git.llucax.com/software/libev.git/blobdiff_plain/678c8c54d0ce967d8f1db3e575aed61879279975..305af5e87583383e4059c39dfa146621c5ec8be9:/event.c diff --git a/event.c b/event.c index 75cd06b..6e26a48 100644 --- a/event.c +++ b/event.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "event.h" @@ -49,7 +50,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 +83,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;