From 9fc1f85102cb57f5346c13108e577d2cb4e081cb Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 8 Jun 2023 19:33:23 +0900 Subject: [PATCH] Fix build error without libev Check libev availability, and guard the usage of libev in util.h. --- cmakeconfig.h.in | 3 +++ configure.ac | 4 ++++ src/util.h | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index 2e357d53..f4e2bb60 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -90,3 +90,6 @@ /* Define to 1 if you have `libngtcp2_crypto_openssl` library. */ #cmakedefine HAVE_LIBNGTCP2_CRYPTO_OPENSSL + +/* Define to 1 if you have `libev` library. */ +#cmakedefine HAVE_LIBEV 1 diff --git a/configure.ac b/configure.ac index 6e18aa71..218a767b 100644 --- a/configure.ac +++ b/configure.ac @@ -433,6 +433,10 @@ if test "x${request_libev}" != "xno"; then else have_libev=yes fi + + if test "x${have_libev}" = "xyes"; then + AC_DEFINE([HAVE_LIBEV], [1], [Define to 1 if you have `libev` library.]) + fi fi if test "x${request_libev}" = "xyes" && diff --git a/src/util.h b/src/util.h index 6b45922d..074a607b 100644 --- a/src/util.h +++ b/src/util.h @@ -47,7 +47,9 @@ #include #include -#include +#ifdef HAVE_LIBEV +# include +#endif // HAVE_LIBEV #include "url-parser/url_parser.h" @@ -697,6 +699,7 @@ template Rep clock_precision() { return duration.count(); } +#ifdef HAVE_LIBEV template Duration duration_from(ev_tstamp d) { return std::chrono::duration_cast(std::chrono::duration(d)); @@ -705,6 +708,7 @@ Duration duration_from(ev_tstamp d) { template ev_tstamp ev_tstamp_from(const Duration &d) { return std::chrono::duration(d).count(); } +#endif // HAVE_LIBEV int make_socket_closeonexec(int fd); int make_socket_nonblocking(int fd);