diff --git a/configure.ac b/configure.ac index 9b947ff4d8..b0cd88496f 100644 --- a/configure.ac +++ b/configure.ac @@ -593,18 +593,6 @@ AC_CHECK_HEADERS([pthread_np.h], [], [], [#include ]) AC_MSG_CHECKING([for libuv]) PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [], [AC_MSG_ERROR([libuv not found])]) -AX_SAVE_FLAGS([libuv]) - -CFLAGS="$CFLAGS $LIBUV_CFLAGS" -LIBS="$LIBS $LIBUV_LIBS" - -# Those functions are only provided in newer versions of libuv, we'll be emulating them -# for now -AC_CHECK_FUNCS([uv_handle_get_data uv_handle_set_data]) -AC_CHECK_FUNCS([uv_req_get_data uv_req_set_data]) -AC_CHECK_FUNCS([uv_udp_connect uv_translate_sys_error uv_sleep]) -AC_CHECK_FUNCS([uv_os_getenv uv_os_setenv]) -AX_RESTORE_FLAGS([libuv]) # libnghttp2 AC_MSG_CHECKING([for libnghttp2]) diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index 95521f9a2f..2259ebd74b 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -578,7 +578,7 @@ udp_send_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req, return (ISC_R_CANCELED); } -#ifdef HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) /* * If we used uv_udp_connect() (and not the shim version for * older versions of libuv), then the peer address has to be diff --git a/lib/isc/netmgr/uv-compat.c b/lib/isc/netmgr/uv-compat.c index 89d7ac025c..00a6a6390b 100644 --- a/lib/isc/netmgr/uv-compat.c +++ b/lib/isc/netmgr/uv-compat.c @@ -36,11 +36,11 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { #ifdef WIN32 return (uv_translate_sys_error(err)); #else /* WIN32 */ -#ifdef HAVE_UV_TRANSLATE_SYS_ERROR +#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0) return (uv_translate_sys_error(errno)); #else return (-errno); -#endif /* HAVE_UV_TRANSLATE_SYS_ERROR */ +#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */ #endif /* WIN32 */ } diff --git a/lib/isc/tests/netmgr_test.c b/lib/isc/tests/netmgr_test.c index 0a28c8c5da..507c3a8a6e 100644 --- a/lib/isc/tests/netmgr_test.c +++ b/lib/isc/tests/netmgr_test.c @@ -694,7 +694,7 @@ mock_udpconnect_uv_udp_bind(void **state __attribute__((unused))) { RESET_RETURN; } -#if HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) static void mock_udpconnect_uv_udp_connect(void **state __attribute__((unused))) { WILL_RETURN(uv_udp_connect, UV_ENOMEM); @@ -2730,7 +2730,7 @@ main(void) { nm_setup, nm_teardown), cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_bind, nm_setup, nm_teardown), -#if HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) cmocka_unit_test_setup_teardown(mock_udpconnect_uv_udp_connect, nm_setup, nm_teardown), #endif diff --git a/lib/isc/tests/uv_wrap.h b/lib/isc/tests/uv_wrap.h index 46d41d2d45..99cedeec9c 100644 --- a/lib/isc/tests/uv_wrap.h +++ b/lib/isc/tests/uv_wrap.h @@ -26,6 +26,8 @@ #define UNIT_TESTING #include +#include "../netmgr/uv-compat.h" + /* uv_udp_t */ int @@ -33,13 +35,13 @@ __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock); int __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, unsigned int flags); -#if HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) int __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr); int __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, int *namelen); -#endif /* HAVE_UV_UDP_CONNECT */ +#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */ int __wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name, int *namelen); @@ -114,7 +116,7 @@ __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, static atomic_int __state_uv_udp_connect __attribute__((unused)) = ATOMIC_VAR_INIT(0); -#if HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) int __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { if (atomic_load(&__state_uv_udp_connect) == 0) { @@ -122,12 +124,12 @@ __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { } return (atomic_load(&__state_uv_udp_connect)); } -#endif /* HAVE_UV_UDP_CONNECT */ +#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */ static atomic_int __state_uv_udp_getpeername __attribute__((unused)) = ATOMIC_VAR_INIT(0); -#if HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) int __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, int *namelen) { @@ -136,7 +138,7 @@ __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, } return (atomic_load(&__state_uv_udp_getpeername)); } -#endif /* HAVE_UV_UDP_CONNECT */ +#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */ static atomic_int __state_uv_udp_getsockname = ATOMIC_VAR_INIT(0); int @@ -274,10 +276,10 @@ __wrap_uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd) { #define uv_udp_open(...) __wrap_uv_udp_open(__VA_ARGS__) #define uv_udp_bind(...) __wrap_uv_udp_bind(__VA_ARGS__) -#if HAVE_UV_UDP_CONNECT +#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0) #define uv_udp_connect(...) __wrap_uv_udp_connect(__VA_ARGS__) #define uv_udp_getpeername(...) __wrap_uv_udp_getpeername(__VA_ARGS__) -#endif /* HAVE_UV_UDP_CONNECT */ +#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */ #define uv_udp_getsockname(...) __wrap_uv_udp_getsockname(__VA_ARGS__) #define uv_udp_send(...) __wrap_uv_udp_send(__VA_ARGS__) #define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__)