]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add uv_os_getenv() and uv_os_setenv() compatibility shims
authorOndřej Surý <ondrej@sury.org>
Thu, 27 May 2021 10:34:06 +0000 (12:34 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 31 May 2021 12:52:05 +0000 (14:52 +0200)
The uv_os_getenv() and uv_os_setenv() functions were introduced in the
libuv >= 1.12.0.  Add simple compatibility shims for older versions.

config.h.win32
configure.ac
lib/isc/netmgr/uv-compat.h

index abb3ba2957730f1dc2e3a3872ada55d4873e5d75..6ebb165b5c57fe04dc319b329d4db825d4330835 100644 (file)
@@ -384,6 +384,12 @@ typedef __int64 off_t;
 /* 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
 
index dc458b41725971a0953100d0f6c2833748e4f2fb..9b947ff4d8622f5725d906399e3085ba7488520e 100644 (file)
@@ -603,6 +603,7 @@ LIBS="$LIBS $LIBUV_LIBS"
 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
index 9d9b437294f2f47c5c38e152727321b027c55fb2..2020689c71953e16982c074d1ea8f07873313f89 100644 (file)
@@ -55,6 +55,36 @@ uv_req_set_data(uv_req_t *req, void *data) {
 #define isc_uv_udp_connect uv_udp_connect
 #else
 
+#ifndef HAVE_UV_OS_GETENV
+#include <stdlib.h>
+#include <string.h>
+
+static inline int
+uv_os_getenv(const char *name, char *buffer, size_t *size) {
+       size_t len;
+       char *buf = getenv(name);
+
+       if (buf == NULL) {
+               return (UV_ENOENT);
+       }
+
+       len = strlen(buf) + 1;
+       if (len > *size) {
+               *size = len;
+               return (UV_ENOBUFS);
+       }
+
+       *size = len;
+       memmove(buffer, buf, len);
+
+       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);
 /*%<