2
dnl Copyright (C) 2006, 2008-2009 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],
12
STDARG_H=''; AC_SUBST([STDARG_H])
13
NEXT_STDARG_H='<stdarg.h>'; AC_SUBST([NEXT_STDARG_H])
14
AC_MSG_CHECKING([for va_copy])
15
AC_CACHE_VAL([gl_cv_func_va_copy], [
16
AC_TRY_COMPILE([#include <stdarg.h>], [
18
void (*func) (va_list, va_list) = va_copy;
21
[gl_cv_func_va_copy=yes], [gl_cv_func_va_copy=no])])
22
AC_MSG_RESULT([$gl_cv_func_va_copy])
23
if test $gl_cv_func_va_copy = no; then
24
dnl Provide a substitute.
25
dnl Usually a simple definition in <config.h> is enough. Not so on AIX 5
26
dnl with some versions of the /usr/vac/bin/cc compiler. It has an <stdarg.h>
27
dnl which does '#undef va_copy', leading to a missing va_copy symbol. For
28
dnl this platform, we use an <stdarg.h> substitute. But we cannot use this
29
dnl approach on other platforms, because <stdarg.h> often defines only
30
dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do
31
dnl not work in this situation.
32
AC_EGREP_CPP([vaccine],
33
[#if defined _AIX && !defined __GNUC__
36
], [gl_aixcc=yes], [gl_aixcc=no])
37
if test $gl_aixcc = yes; then
38
dnl Provide a substitute <stdarg.h> file.
40
gl_CHECK_NEXT_HEADERS([stdarg.h])
41
dnl Fallback for the case when <stdarg.h> contains only macro definitions.
42
if test "$gl_cv_next_stdarg_h" = '""'; then
43
gl_cv_next_stdarg_h='"///usr/include/stdarg.h"'
44
NEXT_STDARG_H="$gl_cv_next_stdarg_h"
47
dnl Provide a substitute in <config.h>, either __va_copy or as a simple
49
gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [
50
AC_TRY_COMPILE([#include <stdarg.h>], [
55
[gl_cv_func___va_copy=yes], [gl_cv_func___va_copy=no])])
56
if test $gl_cv_func___va_copy = yes; then
57
AC_DEFINE([va_copy], [__va_copy],
58
[Define as a macro for copying va_list variables.])
60
AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */
61
#define gl_va_copy(a,b) ((a) = (b))])
62
AC_DEFINE([va_copy], [gl_va_copy],
63
[Define as a macro for copying va_list variables.])