2 dnl Copyright (C) 2006, 2008-2018 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
8 dnl Provide a working va_copy in combination with <stdarg.h>.
10 AC_DEFUN([gl_STDARG_H],
13 NEXT_STDARG_H='<stdarg.h>'
14 AC_MSG_CHECKING([for va_copy])
15 AC_CACHE_VAL([gl_cv_func_va_copy], [
18 [[#include <stdarg.h>]],
21 void (*func) (va_list, va_list) = va_copy;
24 [gl_cv_func_va_copy=yes],
25 [gl_cv_func_va_copy=no])])
26 AC_MSG_RESULT([$gl_cv_func_va_copy])
27 if test $gl_cv_func_va_copy = no; then
28 dnl Provide a substitute.
29 dnl Usually a simple definition in <config.h> is enough. Not so on AIX 5
30 dnl with some versions of the /usr/vac/bin/cc compiler. It has an <stdarg.h>
31 dnl which does '#undef va_copy', leading to a missing va_copy symbol. For
32 dnl this platform, we use an <stdarg.h> substitute. But we cannot use this
33 dnl approach on other platforms, because <stdarg.h> often defines only
34 dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do
35 dnl not work in this situation.
36 AC_EGREP_CPP([vaccine],
37 [#if defined _AIX && !defined __GNUC__
40 ], [gl_aixcc=yes], [gl_aixcc=no])
41 if test $gl_aixcc = yes; then
42 dnl Provide a substitute <stdarg.h> file.
44 gl_NEXT_HEADERS([stdarg.h])
45 dnl Fallback for the case when <stdarg.h> contains only macro definitions.
46 if test "$gl_cv_next_stdarg_h" = '""'; then
47 gl_cv_next_stdarg_h='"///usr/include/stdarg.h"'
48 NEXT_STDARG_H="$gl_cv_next_stdarg_h"
51 dnl Provide a substitute in <config.h>, either __va_copy or as a simple
53 gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [
56 [[#include <stdarg.h>]],
62 [gl_cv_func___va_copy=yes],
63 [gl_cv_func___va_copy=no])])
64 if test $gl_cv_func___va_copy = yes; then
65 AC_DEFINE([va_copy], [__va_copy],
66 [Define as a macro for copying va_list variables.])
68 AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */
69 #define gl_va_copy(a,b) ((a) = (b))])
70 AC_DEFINE([va_copy], [gl_va_copy],
71 [Define as a macro for copying va_list variables.])
76 AM_CONDITIONAL([GL_GENERATE_STDARG_H], [test -n "$STDARG_H"])
77 AC_SUBST([NEXT_STDARG_H])