Re: va_copy is not available on all systems.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Johannes Sixt <J.Sixt@...>
Cc: Shawn O. Pearce <spearce@...>, Junio C Hamano <gitster@...>, <git@...>
Date: Monday, August 20, 2007 - 9:39 am

Johannes Sixt writes:


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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
va_copy is not available on all systems., Johannes Sixt, (Mon Aug 20, 9:16 am)
Re: va_copy is not available on all systems., Alex Riesen, (Mon Aug 20, 3:15 pm)
Re: va_copy is not available on all systems., Shawn O. Pearce, (Mon Aug 20, 11:38 pm)
Re: va_copy is not available on all systems., Alex Riesen, (Tue Aug 21, 2:37 pm)
Re: va_copy is not available on all systems., Junio C Hamano, (Tue Aug 21, 12:53 am)
Re: va_copy is not available on all systems., Michael Poole, (Mon Aug 20, 9:39 am)