Re: va_copy is not available on all systems.
From: Michael Poole <hidden>
Date: 2016-06-15 22:43:30
Johannes Sixt writes:
This is just too ugly to be included... die_nicely() uses the variable argument list twice. The recent fix for this in 7e5dcea8311 uses va_copy. However, on older systems this function is not available. This fix assumes that those systems that do have the function actually implement it as macro, and we use it to remove the entire nicely() functionality. Since va_copy() must be provided by the compiler, we don't have a reasonable chance to provide a working definition in git_compat_util.h.
Some older (pre-C99) versions of gcc name it __va_copy() instead. Is there any guarantee that va_copy() will be a macro on systems that provide it? If neither va_copy() nor __va_copy() are available, memcpy(&(DEST), &(SRC), sizeof(DEST)) should work for any va_list type. It's what I use on one project: #ifdef HAVE_VA_COPY #define VA_COPY(DEST, SRC) va_copy(DEST, SRC) #elif HAVE___VA_COPY #define VA_COPY(DEST, SRC) __va_copy(DEST, SRC) #else #define VA_COPY(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof(DEST)) #endif with appropriate autoconf tests, basically two copies of this: dnl How to copy one va_list to another? AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, [AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])], [ac_cv_c_va_copy="yes"], [ac_cv_c_va_copy="no"] )]) if test "$ac_cv_c_va_copy" = "yes" ; then AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy]) fi I'm not sure how to translate the tests to git's coding style most easily. Michael Poole