]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use UV_VERSION_HEX to decide whether we need libuv shim functions
authorOndřej Surý <ondrej@sury.org>
Thu, 27 May 2021 11:38:21 +0000 (13:38 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 31 May 2021 12:52:05 +0000 (14:52 +0200)
Instead of having a configure check for every missing function that has
been added in later version of libuv, we now use UV_VERSION_HEX to
decide whether we need the shim or not.

config.h.win32
lib/isc/netmgr/uv-compat.c
lib/isc/netmgr/uv-compat.h

index 6ebb165b5c57fe04dc319b329d4db825d4330835..16aab18194aa4f915662feb57094af8c2e7d7e2d 100644 (file)
@@ -378,24 +378,6 @@ typedef __int64 off_t;
 /* Define to 1 if you have the `SSL_CTX_up_ref' function. */
 #define SSL_CTX_UP_REF 1
 
-/* Define to 1 if you have the `uv_handle_get_data' function. */
-#define HAVE_UV_HANDLE_GET_DATA 1
-
-/* Define to 1 if you have the `uv_handle_set_data' function. */
-#define HAVE_UV_HANDLE_SET_DATA 1
-
-/* Define to 1 if you have the `uv_os_getenv' function. */
-#define HAVE_UV_OS_GETENV 1
-
-/* Define to 1 if you have the `uv_os_setenv' function. */
-#define HAVE_UV_OS_SETENV 1
-
-/* Define to 1 if you have the `uv_req_get_data' function. */
-#define HAVE_UV_REQ_GET_DATA 1
-
-/* Define to 1 if you have the `uv_req_set_data' function. */
-#define HAVE_UV_REQ_SET_DATA 1
-
 /* GSSAPI Related defines */
 @HAVE_GSSAPI@
 @HAVE_GSSAPI_H@
index a0e1add2d788c804fd09ead1e8201d999b68e0e6..89d7ac025cd6474ac3569addd993312fb2af45fd 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "netmgr-int.h"
 
-#ifndef HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
 int
 isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
        int err = 0;
@@ -46,7 +46,7 @@ isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
 
        return (0);
 }
-#endif /* ifndef HAVE_UV_UDP_CONNECT */
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
 
 int
 isc_uv_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,
index 2020689c71953e16982c074d1ea8f07873313f89..c7037353f579a7b8d9d449ef3374fd0b0a486c3a 100644 (file)
  * library version.
  */
 
-#ifndef HAVE_UV_HANDLE_GET_DATA
+#define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
+
+#if UV_VERSION_HEX < UV_VERSION(1, 19, 0)
 static inline void *
 uv_handle_get_data(const uv_handle_t *handle) {
        return (handle->data);
 }
-#endif /* ifndef HAVE_UV_HANDLE_GET_DATA */
 
-#ifndef HAVE_UV_HANDLE_SET_DATA
 static inline void
 uv_handle_set_data(uv_handle_t *handle, void *data) {
        handle->data = data;
 }
-#endif /* ifndef HAVE_UV_HANDLE_SET_DATA */
 
-#ifndef HAVE_UV_REQ_GET_DATA
 static inline void *
 uv_req_get_data(const uv_req_t *req) {
        return (req->data);
 }
-#endif /* ifndef HAVE_UV_REQ_GET_DATA */
 
-#ifndef HAVE_UV_REQ_SET_DATA
 static inline void
 uv_req_set_data(uv_req_t *req, void *data) {
        req->data = data;
 }
-#endif /* ifndef HAVE_UV_REQ_SET_DATA */
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 19, 0) */
 
-#ifndef HAVE_UV_SLEEP
+#if UV_VERSION_HEX < UV_VERSION(1, 34, 0)
 #define uv_sleep(msec) usleep(msec * 1000)
-#endif
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 34, 0) */
 
-#ifdef HAVE_UV_UDP_CONNECT
+#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
+int
+isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
+/*%<
+ * Associate the UDP handle to a remote address and port, so every message sent
+ * by this handle is automatically sent to that destination.
+ *
+ * NOTE: This is just a limited shim for uv_udp_connect() as it requires the
+ * handle to be bound.
+ */
+#else /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
 #define isc_uv_udp_connect uv_udp_connect
-#else
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
 
-#ifndef HAVE_UV_OS_GETENV
+#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
 #include <stdlib.h>
 #include <string.h>
 
@@ -79,23 +85,9 @@ uv_os_getenv(const char *name, char *buffer, size_t *size) {
 
        return (0);
 }
-#endif /* HAVE_UV_OS_GETENV */
 
-#ifndef HAVE_UV_OS_SETENV
 #define uv_os_setenv(name, value) setenv(name, value, 0)
-#endif /* HAVE_UV_OS_SETENV */
-
-int
-isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
-/*%<
- * Associate the UDP handle to a remote address and port, so every message sent
- * by this handle is automatically sent to that destination.
- *
- * NOTE: This is just a limited shim for uv_udp_connect() as it requires the
- * handle to be bound.
- */
-
-#endif
+#endif /* UV_VERSION_HEX < UV_VERSION(1, 12, 0) */
 
 int
 isc_uv_udp_freebind(uv_udp_t *handle, const struct sockaddr *addr,