Merge pull request #1915 from nghttp2/fix-build-without-libev

Fix build error without libev
This commit is contained in:
Tatsuhiro Tsujikawa 2023-06-08 20:31:41 +09:00 committed by GitHub
commit 2c955ab76b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

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

View File

@ -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" &&

View File

@ -47,7 +47,9 @@
#include <map>
#include <random>
#include <ev.h>
#ifdef HAVE_LIBEV
# include <ev.h>
#endif // HAVE_LIBEV
#include "url-parser/url_parser.h"
@ -697,6 +699,7 @@ template <typename Clock, typename Rep> Rep clock_precision() {
return duration.count();
}
#ifdef HAVE_LIBEV
template <typename Duration = std::chrono::steady_clock::duration>
Duration duration_from(ev_tstamp d) {
return std::chrono::duration_cast<Duration>(std::chrono::duration<double>(d));
@ -705,6 +708,7 @@ Duration duration_from(ev_tstamp d) {
template <typename Duration> ev_tstamp ev_tstamp_from(const Duration &d) {
return std::chrono::duration<double>(d).count();
}
#endif // HAVE_LIBEV
int make_socket_closeonexec(int fd);
int make_socket_nonblocking(int fd);