From 4d93b6c0d63efe831d2c0f2743838fe0e92d055e Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Tue, 15 Sep 2020 23:56:17 +0300 Subject: [PATCH] Check for va_copy declaration ctx.c contains a workaround for systems without va_copy() support. Improve this workaround in the way which is described in the autoconf manual. Also check for va_copy declaration in configure time. Fixes #160. --- configure.ac | 1 + src/ctx.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index e20e322..bfae47f 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ AC_ARG_ENABLE([cares], AC_SEARCH_LIBS([socket], [network socket]) AC_CHECK_FUNCS([snprintf vsnprintf]) +AC_CHECK_DECLS([va_copy], [], [], [#include ]) if test "x$enable_tls" != xno; then PKG_CHECK_MODULES([openssl], [openssl], diff --git a/src/ctx.c b/src/ctx.c index 3491616..da2d643 100644 --- a/src/ctx.c +++ b/src/ctx.c @@ -50,9 +50,10 @@ #include "resolver.h" #include "util.h" -/* Workaround for visual studio without va_copy support. */ -#if defined(_MSC_VER) && _MSC_VER < 1800 || defined(__HAIKU__) -#define va_copy(d, s) ((d) = (s)) +/* Workaround for systems without va_copy support. */ +#if defined(_MSC_VER) && _MSC_VER < 1800 || \ + !defined(_MSC_VER) && !defined(HAVE_DECL_VA_COPY) +#define va_copy(d, s) (memcpy(&d, &s, sizeof(va_list))) #endif /** Initialize the Strophe library.