mirror of
https://github.com/strophe/libstrophe.git
synced 2026-07-17 19:36:22 +00:00
Make it right to check/implement va_copy
This commit is contained in:
committed by
Steffen Jaeckel
parent
8ea15cf656
commit
1a8be1d617
34
configure.ac
34
configure.ac
@@ -88,7 +88,39 @@ AX_VALGRIND_CHECK
|
||||
|
||||
AC_SEARCH_LIBS([socket], [network socket])
|
||||
AC_CHECK_FUNCS([snprintf vsnprintf], [], [have_snprintf=no])
|
||||
AC_CHECK_DECLS([va_copy], [], [], [#include <stdarg.h>])
|
||||
|
||||
dnl Checking for va_copy availability
|
||||
AC_MSG_CHECKING([for va_copy])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
|
||||
va_list ap1,ap2;]], [[va_copy(ap1,ap2);]])],
|
||||
have_va_copy=yes,
|
||||
have_va_copy=no)
|
||||
AC_MSG_RESULT($have_va_copy)
|
||||
if test x"$have_va_copy" = x"yes"; then
|
||||
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
|
||||
else
|
||||
AC_MSG_CHECKING([for __va_copy])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
|
||||
va_list ap1,ap2;]], [[__va_copy(ap1,ap2);]])],
|
||||
have___va_copy=yes,
|
||||
have___va_copy=no)
|
||||
AC_MSG_RESULT($have___va_copy)
|
||||
if test x"$have___va_copy" = x"yes"; then
|
||||
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$have_va_copy$have___va_copy" = x"nono"; then
|
||||
dnl Checking whether va_list is an array type
|
||||
AC_MSG_CHECKING([whether va_list is an array type])
|
||||
AC_TRY_COMPILE2([
|
||||
#include <stdarg.h>
|
||||
void a(va_list * ap) {}],[
|
||||
va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1],[
|
||||
AC_MSG_RESULT(no)],[
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE([VA_LIST_IS_ARRAY], [1],[Define if va_list is an array type])])
|
||||
fi
|
||||
|
||||
if test "x$enable_tls" != xno -a "x$with_gnutls" == xyes; then
|
||||
PKG_CHECK_MODULES([gnutls], [gnutls],
|
||||
|
||||
28
m4/ac_try_compile2.m4
Normal file
28
m4/ac_try_compile2.m4
Normal file
@@ -0,0 +1,28 @@
|
||||
dnl Like AC_TRY_EVAL but also errors out if the compiler generates
|
||||
dnl _any_ output. Some compilers might issue warnings which we want
|
||||
dnl to catch.
|
||||
AC_DEFUN([AC_TRY_EVAL2],
|
||||
[{ (eval echo configure:__oline__: \"[$]$1\") 1>&AS_MESSAGE_LOG_FD; dnl
|
||||
(eval [$]$1) 2>&AS_MESSAGE_LOG_FD; _out=`eval [$]$1 2>&1` && test "x$_out" = x; }])
|
||||
|
||||
dnl Like AC_TRY_COMPILE but calls AC_TRY_EVAL2 instead of AC_TRY_EVAL
|
||||
AC_DEFUN([AC_TRY_COMPILE2],
|
||||
[cat > conftest.$ac_ext <<EOF
|
||||
[#]line __oline__ "configure"
|
||||
#include "confdefs.h"
|
||||
[$1]
|
||||
int main(void) {
|
||||
[$2]
|
||||
; return 0; }
|
||||
EOF
|
||||
if AC_TRY_EVAL2(ac_compile); then
|
||||
ifelse([$3], , :, [rm -rf conftest*
|
||||
$3])
|
||||
else
|
||||
echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
|
||||
cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
|
||||
ifelse([$4], , , [ rm -rf conftest*
|
||||
$4
|
||||
])dnl
|
||||
fi
|
||||
rm -f conftest*])
|
||||
20
src/ctx.c
20
src/ctx.c
@@ -50,10 +50,22 @@
|
||||
#include "resolver.h"
|
||||
#include "util.h"
|
||||
|
||||
/* 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)))
|
||||
#ifndef va_copy
|
||||
#ifdef HAVE_VA_COPY
|
||||
#define va_copy(dest, src) va_copy(dest, src)
|
||||
#else
|
||||
#ifdef HAVE___VA_COPY
|
||||
#define va_copy(dest, src) __va_copy(dest, src)
|
||||
#else
|
||||
#ifndef VA_LIST_IS_ARRAY
|
||||
#define va_copy(dest, src) (dest) = (src)
|
||||
#else
|
||||
#include <string.h>
|
||||
#define va_copy(dest, src) \
|
||||
memcpy((char *)(dest), (char *)(src), sizeof(va_list))
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** Initialize the Strophe library.
|
||||
|
||||
Reference in New Issue
Block a user