diff --git a/doc/Changelog b/doc/Changelog index 2118b81ad..992ad5cdc 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 14 March 2016: Wouter - Fix warnings in ifdef corner case, older or unknown libevent. + - Fix compile for ub_event code with older libev. 11 March 2016: Wouter - Remove warning about unused parameter in event_pluggable.c. diff --git a/util/ub_event.c b/util/ub_event.c index 5ddeefb84..af2a18ea0 100644 --- a/util/ub_event.c +++ b/util/ub_event.c @@ -128,6 +128,10 @@ static void (*NATIVE_BITS_CB(void (*cb)(int, short, void*)))(int, short, void*) # define NATIVE_BITS_CB(c) (c) #endif +#ifndef EVFLAG_AUTO +#define EVFLAG_AUTO 0 +#endif + #define AS_EVENT_BASE(x) \ (((union {struct ub_event_base* a; struct event_base* b;})x).b) #define AS_UB_EVENT_BASE(x) \ @@ -142,7 +146,7 @@ const char* ub_event_get_version() return event_get_version(); } -#if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP) +#if (defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && defined(EVBACKEND_SELECT) static const char* ub_ev_backend2str(int b) { switch(b) { @@ -178,7 +182,11 @@ ub_get_event_sys(struct ub_event_base* base, const char** n, const char** s, *n = "libev"; if (!b) b = (struct event_base*)ev_default_loop(EVFLAG_AUTO); +# ifdef EVBACKEND_SELECT *m = ub_ev_backend2str(ev_backend((struct ev_loop*)b)); +# else + *m = "not obtainable"; +# endif # elif defined(HAVE_EVENT_BASE_GET_METHOD) *n = "libevent"; if (!b) diff --git a/util/ub_event_pluggable.c b/util/ub_event_pluggable.c index ccc7d64d5..5c517555e 100644 --- a/util/ub_event_pluggable.c +++ b/util/ub_event_pluggable.c @@ -130,6 +130,10 @@ static void (*NATIVE_BITS_CB(void (*cb)(int, short, void*)))(int, short, void*) # define NATIVE_BITS_CB(c) (c) #endif +#ifndef EVFLAG_AUTO +#define EVFLAG_AUTO 0 +#endif + struct my_event_base { struct ub_event_base super; struct event_base* base; @@ -416,7 +420,7 @@ ub_libevent_get_event_base(struct ub_event_base* base) return NULL; } -#if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP) +#if (defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && defined(EVBACKEND_SELECT) static const char* ub_ev_backend2str_pluggable(int b) { switch(b) { @@ -456,7 +460,11 @@ ub_get_event_sys(struct ub_event_base* ub_base, const char** n, const char** s, *s = event_get_version(); # if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP) *n = "pluggable-libev"; +# ifdef EVBACKEND_SELECT *m = ub_ev_backend2str_pluggable(ev_backend((struct ev_loop*)b)); +# else + *m = "not obtainable"; +# endif # elif defined(HAVE_EVENT_BASE_GET_METHOD) *n = "pluggable-libevent"; *m = event_base_get_method(b);