diff --git a/configure.ac b/configure.ac index c62cbf5c3..fc06d04a3 100644 --- a/configure.ac +++ b/configure.ac @@ -178,11 +178,15 @@ AC_ARG_WITH([couchbasemock], AC_CHECK_HEADERS_ONCE([mach/mach_time.h sys/socket.h sys/time.h netinet/in.h inttypes.h netdb.h unistd.h ws2tcpip.h winsock2.h event.h stdint.h - sys/uio.h sys/types.h fcntl.h dlfcn.h]) + sys/uio.h sys/types.h fcntl.h dlfcn.h + ev.h libev/ev.h]) AS_IF([test "x$ac_cv_header_stdint_h" != "xyes"], [AC_MSG_ERROR(Failed to locate stdint.h)]) +AS_IF([test "x$ac_cv_header_libev_ev_h" = "xyes"], + [AC_DEFINE([HAVE_LIBEV_EV_H], [1], [Have non-standard place for libev header])]) + dnl Allow to build library without event library dependency, which is useful dnl if the application already have one. AC_ARG_ENABLE([plugins], @@ -217,7 +221,11 @@ AC_CACHE_CHECK([for libev3], [ac_cv_have_libev3], LIBS=-lev AC_TRY_LINK([ #include + #ifdef HAVE_LIBEV_EV_H + #include + #else #include + #endif ],[ struct ev_loop *loop = ev_loop_new(EVFLAG_AUTO|EVFLAG_NOENV); ev_loop(loop, 0); @@ -238,7 +246,11 @@ AC_CACHE_CHECK([for libev4], [ac_cv_have_libev4], LIBS=-lev AC_TRY_LINK([ #include + #ifdef HAVE_LIBEV_EV_H + #include + #else #include + #endif ],[ struct ev_loop *loop = ev_loop_new(EVFLAG_AUTO|EVFLAG_NOENV); ev_run(loop, 0); diff --git a/plugins/io/libev/libev_io_opts.h b/plugins/io/libev/libev_io_opts.h index cb6f437e4..331c517ea 100644 --- a/plugins/io/libev/libev_io_opts.h +++ b/plugins/io/libev/libev_io_opts.h @@ -27,7 +27,6 @@ #define LIBCOUCHBASE_LIBEV_IO_OPTS_H 1 #include -#include #ifdef __cplusplus extern "C" { @@ -37,13 +36,14 @@ extern "C" { * Create an instance of an event handler that utilize libev for * event notification. * - * @param loop the event loop to hook use (please note that you shouldn't - * reference the event loop from multiple threads) + * @param loop the event loop (struct ev_loop *) to hook use (please + * note that you shouldn't reference the event loop from + * multiple threads) * @param io a pointer to a newly created and initialized event handler * @return status of the operation */ LIBCOUCHBASE_API - lcb_error_t lcb_create_libev_io_opts(lcb_io_opt_t *io, struct ev_loop *loop); + lcb_error_t lcb_create_libev_io_opts(lcb_io_opt_t *io, void *loop); #ifdef __cplusplus } #endif diff --git a/plugins/io/libev/plugin-libev.c b/plugins/io/libev/plugin-libev.c index 66b5b245c..51fc775ee 100644 --- a/plugins/io/libev/plugin-libev.c +++ b/plugins/io/libev/plugin-libev.c @@ -21,6 +21,11 @@ * @author Sergey Avseyev */ #include "config.h" +#ifdef HAVE_LIBEV_EV_H +#include +#else +#include +#endif #include "libev_io_opts.h" #include #include @@ -338,8 +343,9 @@ static void lcb_destroy_io_opts(struct lcb_io_opt_st *iops) } LIBCOUCHBASE_API -lcb_error_t lcb_create_libev_io_opts(lcb_io_opt_t *io, struct ev_loop *loop) +lcb_error_t lcb_create_libev_io_opts(lcb_io_opt_t *io, void *arg) { + struct ev_loop *loop = arg; struct lcb_io_opt_st *ret = calloc(1, sizeof(*ret)); struct libev_cookie *cookie = calloc(1, sizeof(*cookie)); if (ret == NULL || cookie == NULL) { diff --git a/plugins/io/libevent/libevent_io_opts.h b/plugins/io/libevent/libevent_io_opts.h index 7958edb5f..fc9d69f09 100644 --- a/plugins/io/libevent/libevent_io_opts.h +++ b/plugins/io/libevent/libevent_io_opts.h @@ -27,7 +27,6 @@ #define LIBCOUCHBASE_LIBEVENT_IO_OPTS_H 1 #include -#include #ifdef __cplusplus extern "C" { @@ -37,13 +36,14 @@ extern "C" { * Create an instance of an event handler that utilize libevent for * event notification. * - * @param base the event base to hook use (please note that you shouldn't - * reference the event base from multiple threads) + * @param base the event base (struct event_base *) to hook use (please + * note that you shouldn't reference the event base from + * multiple threads) * @param io a pointer to a newly created and initialized event handler * @return status of the operation */ LIBCOUCHBASE_API - lcb_error_t lcb_create_libevent_io_opts(lcb_io_opt_t *io, struct event_base *base); + lcb_error_t lcb_create_libevent_io_opts(lcb_io_opt_t *io, void *base); #ifdef __cplusplus } diff --git a/plugins/io/libevent/plugin-libevent.c b/plugins/io/libevent/plugin-libevent.c index 2d3d08742..f1fcbeec9 100644 --- a/plugins/io/libevent/plugin-libevent.c +++ b/plugins/io/libevent/plugin-libevent.c @@ -23,6 +23,7 @@ */ #include "config.h" +#include #include "libevent_io_opts.h" #include #include @@ -329,8 +330,9 @@ static void lcb_destroy_io_opts(struct lcb_io_opt_st *iops) } LIBCOUCHBASE_API -lcb_error_t lcb_create_libevent_io_opts(lcb_io_opt_t *io, struct event_base *base) +lcb_error_t lcb_create_libevent_io_opts(lcb_io_opt_t *io, void *arg) { + struct event_base *base = arg; struct lcb_io_opt_st *ret = calloc(1, sizeof(*ret)); struct libevent_cookie *cookie = calloc(1, sizeof(*cookie)); if (ret == NULL || cookie == NULL) {