Use va_copy if available for VARARGS_ASSIGN

Bug #187180 r=blizzard sr=brendan
This commit is contained in:
seawood%netscape.com 2003-02-23 06:59:39 +00:00
Родитель 3b97b5e3fb
Коммит b4a4a67418
4 изменённых файлов: 81 добавлений и 28 удалений

Просмотреть файл

@ -2228,33 +2228,80 @@ esac
AC_LANG_C
dnl Does this platform require array notation to assign to a va_list?
dnl If cross-compiling, we assume va_list is "normal". If this breaks
dnl you, set ac_cv_valistisarray=true and maybe define HAVE_VA_LIST_AS_ARRAY
dnl also just to be sure.
AC_MSG_CHECKING(whether va_list assignments need array notation)
AC_CACHE_VAL(ac_cv_valistisarray,
[AC_TRY_RUN([#include <stdlib.h>
#include <stdarg.h>
void foo(int i, ...) {
va_list ap1, ap2;
va_start(ap1, i);
ap2 = ap1;
if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) { exit(1); }
va_end(ap1); va_end(ap2);
}
int main() { foo(0, 123); return(0); }],
[ac_cv_valistisarray=false],
[ac_cv_valistisarray=true],
[ac_cv_valistisarray=false])])
if test "$ac_cv_valistisarray" = true ; then
AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
dnl **********************
dnl *** va_copy checks ***
dnl **********************
dnl we currently check for all three va_copy possibilities, so we get
dnl all results in config.log for bug reports.
AC_MSG_CHECKING(for an implementation of va_copy())
AC_CACHE_VAL(ac_cv_va_copy,[
AC_TRY_RUN([
#include <stdarg.h>
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() { f (0, 42); return 0; }],
ac_cv_va_copy=yes,
ac_cv_va_copy=no,
ac_cv_va_copy=no
)
])
AC_MSG_RESULT($ac_cv_va_copy)
AC_MSG_CHECKING(for an implementation of __va_copy())
AC_CACHE_VAL(ac_cv___va_copy,[
AC_TRY_RUN([
#include <stdarg.h>
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
__va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() { f (0, 42); return 0; }],
ac_cv___va_copy=yes,
ac_cv___va_copy=no,
ac_cv___va_copy=no
)
])
AC_MSG_RESULT($ac_cv___va_copy)
AC_MSG_CHECKING(whether va_lists can be copied by value)
AC_CACHE_VAL(ac_cv_va_val_copy,[
AC_TRY_RUN([
#include <stdarg.h>
void f (int i, ...) {
va_list args1, args2;
va_start (args1, i);
args2 = args1;
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1); va_end (args2);
}
int main() { f (0, 42); return 0; }],
ac_cv_va_val_copy=yes,
ac_cv_va_val_copy=no,
ac_cv_va_val_copy=yes
)
])
if test "x$ac_cv_va_copy" = "xyes"; then
AC_DEFINE(VA_COPY, va_copy)
AC_DEFINE(HAVE_VA_COPY)
elif test "x$ac_cv___va_copy" = "xyes"; then
AC_DEFINE(VA_COPY, __va_copy)
AC_DEFINE(HAVE_VA_COPY)
fi
if test "x$ac_cv_va_val_copy" = "xno"; then
AC_DEFINE(HAVE_VA_LIST_AS_ARRAY)
fi
AC_MSG_RESULT($ac_cv_va_val_copy)
dnl Check for dll-challenged libc's.
dnl This check is apparently only needed for Linux.
case "$target" in

Просмотреть файл

@ -50,7 +50,9 @@
** Note: on some platforms va_list is defined as an array,
** and requires array notation.
*/
#ifdef HAVE_VA_LIST_AS_ARRAY
#ifdef HAVE_VA_COPY
#define VARARGS_ASSIGN(foo, bar) VA_COPY(foo,bar)
#elif defined(HAVE_VA_LIST_AS_ARRAY)
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
#else
#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)

Просмотреть файл

@ -1441,7 +1441,9 @@ XPCConvert::JSErrorToXPCException(XPCCallContext& ccx,
** Note: on some platforms va_list is defined as an array,
** and requires array notation.
*/
#ifdef HAVE_VA_LIST_AS_ARRAY
#ifdef HAVE_VA_COPY
#define VARARGS_ASSIGN(foo, bar) VA_COPY(foo,bar)
#elif defined(HAVE_VA_LIST_AS_ARRAY)
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
#else
#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)

Просмотреть файл

@ -46,7 +46,9 @@
** and requires array notation.
*/
#ifdef HAVE_VA_LIST_AS_ARRAY
#ifdef HAVE_VA_COPY
#define VARARGS_ASSIGN(foo, bar) VA_COPY(foo,bar)
#elif defined(HAVE_VA_LIST_AS_ARRAY)
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
#else
#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)