From beaea73fa0ffbd5f2fbc839e9c9135f9bc0b3280 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 16 Nov 2007 14:06:40 -0500 Subject: [PATCH] ENH: add a try compile for va_copy --- Utilities/cmxmlrpc/CMakeLists.txt | 2 ++ Utilities/cmxmlrpc/xmlrpc_config.h.in | 2 ++ Utilities/cmxmlrpc/xmlrpc_data.c | 10 +++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Utilities/cmxmlrpc/CMakeLists.txt b/Utilities/cmxmlrpc/CMakeLists.txt index a29e0bd58..e3f42c839 100644 --- a/Utilities/cmxmlrpc/CMakeLists.txt +++ b/Utilities/cmxmlrpc/CMakeLists.txt @@ -44,6 +44,8 @@ INCLUDE (TryCompileFromSource) SET(HEADER_INCLUDES "${CURRENT_INCLUDES}") TRY_COMPILE_FROM_SOURCE("va_list list1, list2; list1 = list2" VA_LIST_ISNOT_ARRAY_DEFINE) +TRY_COMPILE_FROM_SOURCE("va_list list1, list2; va_copy(list1, list2);" + HAS_VA_COPY) SET(VA_LIST_IS_ARRAY_DEFINE 0) IF(NOT VA_LIST_ISNOT_ARRAY_DEFINE) SET(VA_LIST_IS_ARRAY_DEFINE 1) diff --git a/Utilities/cmxmlrpc/xmlrpc_config.h.in b/Utilities/cmxmlrpc/xmlrpc_config.h.in index d940e4dcc..9683c1e69 100644 --- a/Utilities/cmxmlrpc/xmlrpc_config.h.in +++ b/Utilities/cmxmlrpc/xmlrpc_config.h.in @@ -22,6 +22,8 @@ #define VA_LIST_IS_ARRAY @VA_LIST_IS_ARRAY_DEFINE@ +#cmakedefine HAS_VA_COPY @HAS_VA_COPY@ + #define HAVE_LIBWWW_SSL @HAVE_LIBWWW_SSL_DEFINE@ #define ATTR_UNUSED @ATTR_UNUSED@ diff --git a/Utilities/cmxmlrpc/xmlrpc_data.c b/Utilities/cmxmlrpc/xmlrpc_data.c index 0d3c3cad6..456d8e487 100644 --- a/Utilities/cmxmlrpc/xmlrpc_data.c +++ b/Utilities/cmxmlrpc/xmlrpc_data.c @@ -24,10 +24,14 @@ typedef double va_double; ** tricky fashions. We don't why Python does this, but since we're ** abusing our va_list objects in a similar fashion, we'll copy them ** too. */ -#if VA_LIST_IS_ARRAY -#define VA_LIST_COPY(dest,src) memcpy((dest), (src), sizeof(va_list)) +#ifdef HAS_VA_COPY +# define VA_LIST_COPY(dest,src) va_copy((dest), (src)) #else -#define VA_LIST_COPY(dest,src) ((dest) = (src)) +# if VA_LIST_IS_ARRAY +# define VA_LIST_COPY(dest,src) memcpy((dest), (src), sizeof(va_list)) +# else +# define VA_LIST_COPY(dest,src) ((dest) = (src)) +# endif #endif