Fix compile for ub_event code with older libev.

git-svn-id: file:///svn/unbound/trunk@3672 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2016-03-14 13:45:51 +00:00
parent c9a5913cf8
commit 197a50ea96
3 changed files with 19 additions and 2 deletions

View file

@ -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.

View file

@ -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)

View file

@ -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);