From 2cfe19205b04cc233f94f355f8e6c944405a8c6a Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Wed, 26 Jul 2017 06:12:40 +0200 Subject: [PATCH] libuv: use pkg-config --- configure.ac | 71 ++----------------------------------------- src/LibuvEventPoll.cc | 25 +++------------ 2 files changed, 7 insertions(+), 89 deletions(-) diff --git a/configure.ac b/configure.ac index 863d36fa..aa06d6fa 100644 --- a/configure.ac +++ b/configure.ac @@ -238,77 +238,10 @@ fi have_libuv=no if test "x$with_libuv" = "xyes"; then - case "$host" in - *mingw*|*msvc*) - libuv_cflags="-D_WIN32_WINNT=0x0600" - save_CPPFLAGS=$CPPFLAGS - save_LIBS=$LIBS - CPPFLAGS="$CPPFLAGS $libuv_cflags" - AC_SEARCH_LIBS([uv_poll_init_socket], [uv], [ - AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no]) - ], [have_libuv=no]) - if test "x$have_libuv" = "xyes"; then - LIBUV_CFLAGS=$libuv_cflags - LIBUV_LIBS=-luv - AC_SUBST([LIBUV_CFLAGS]) - AC_SUBST([LIBUV_LIBS]) - fi - CPPFLAGS=$save_CPPFLAGS - LIBS=$save_LIBS - ;; - - *darwin*) - libuv_ldflags="-framework Foundation -framework CoreServices -framework ApplicationServices" - save_LDFLAGS=$LDFLAGS - save_LIBS=$LIBS - LDFLAGS="$LDFLAGS $libuv_ldflags" - AC_SEARCH_LIBS([uv_poll_init_socket], [uv], [ - AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no]) - ], [have_libuv=no], [-lm]) - if test "x$have_libuv" = "xyes"; then - LIBUV_CFLAGS= - LIBUV_LIBS="$libuv_ldflags -luv -lm" - AC_SUBST([LIBUV_CFLAGS]) - AC_SUBST([LIBUV_LIBS]) - fi - LDFLAGS=$save_LDFLAGS - LIBS=$save_LIBS - ;; - - *) - dnl Yeah, sucks that luv does not bring a pkg-config or config-tool - AC_MSG_CHECKING([for libuv]) - save_LIBS=$LIBS - for combo in "" "-lrt" "-ldl -lrt" "-ldl -lrt -lpthread" "-lkvm"; do - LIBS="-luv $combo $save_LIBS -lm" - AC_LINK_IFELSE([AC_LANG_SOURCE([ -extern "C" int uv_poll_init_socket(void); -int main() { return uv_poll_init_socket(); } - ])], [ - AC_MSG_RESULT(-luv $combo -lm) - AC_CHECK_HEADER([uv.h], [have_libuv=yes], [have_libuv=no]) - ], [have_libuv=no]) - if test "x$have_libuv" = "xyes"; then - LIBUV_CFLAGS= - LIBUV_LIBS="-luv $combo -lm" - AC_SUBST([LIBUV_CFLAGS]) - AC_SUBST([LIBUV_LIBS]) - break; - fi - done - LIBS=$save_LIBS - if test "x$have_libuv" != "xyes"; then - AC_MSG_RESULT("no") - fi - ;; - esac - + PKG_CHECK_MODULES([LIBUV], [libuv >= 1.13], + [have_libuv=yes], [have_libuv=no]) if test "x$have_libuv" = "xyes"; then AC_DEFINE([HAVE_LIBUV], [1], [Define to 1 if you have libuv.]) - save_LIBS=$LIBS - LIBS="$LIBUV_LIBS $LIBS" - AC_CHECK_FUNCS([uv_last_error]) - LIBS=$save_LIBS elif test "x$with_libuv_requested" = "xyes"; then ARIA2_DEP_NOT_MET([libuv]) fi diff --git a/src/LibuvEventPoll.cc b/src/LibuvEventPoll.cc index 2b6b9896..c50284ef 100644 --- a/src/LibuvEventPoll.cc +++ b/src/LibuvEventPoll.cc @@ -65,22 +65,10 @@ template static void close_callback(uv_handle_t* handle) delete reinterpret_cast(handle); } -#if !defined(UV_VERSION_MINOR) || \ - (UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10) - -static void timer_callback(uv_timer_t* handle, int status) +static void timer_callback(uv_timer_t* handle) { uv_stop(handle->loop); } - -static void timer_callback(uv_timer_t* handle) { timer_callback(handle, 0); } - -#else // !defined(UV_VERSION_MINOR) || (UV_VERSION_MAJOR == 0 && -// UV_VERSION_MINOR <= 10) - -static void timer_callback(uv_timer_t* handle) { uv_stop(handle->loop); } - -#endif // !defined(UV_VERSION_MINOR) || UV_VERSION_MINOR <= 10 } namespace aria2 { @@ -112,7 +100,10 @@ int LibuvEventPoll::KSocketEntry::getEvents() const return events; } -LibuvEventPoll::LibuvEventPoll() { loop_ = uv_loop_new(); } +LibuvEventPoll::LibuvEventPoll() +{ + loop_ = uv_loop_new(); +} LibuvEventPoll::~LibuvEventPoll() { @@ -189,14 +180,8 @@ int LibuvEventPoll::translateEvents(EventPoll::EventType events) void LibuvEventPoll::pollCallback(KPoll* poll, int status, int events) { -#if HAVE_UV_LAST_ERROR - if (status == -1) { - uv_err_t err = uv_last_error(loop_); - switch (err.code) { -#else if (status < 0) { switch (status) { -#endif case UV_EAGAIN: case UV_EINTR: return;