| 1 | # stdarg.m4 serial 3 |
|---|
| 2 | dnl Copyright (C) 2006, 2008-2010 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. |
|---|
| 6 | |
|---|
| 7 | dnl From Bruno Haible. |
|---|
| 8 | dnl Provide a working va_copy in combination with <stdarg.h>. |
|---|
| 9 | |
|---|
| 10 | AC_DEFUN([gl_STDARG_H], |
|---|
| 11 | [ |
|---|
| 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>], [ |
|---|
| 17 | #ifndef va_copy |
|---|
| 18 | void (*func) (va_list, va_list) = va_copy; |
|---|
| 19 | #endif |
|---|
| 20 | ], |
|---|
| 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__ |
|---|
| 34 | AIX vaccine |
|---|
| 35 | #endif |
|---|
| 36 | ], [gl_aixcc=yes], [gl_aixcc=no]) |
|---|
| 37 | if test $gl_aixcc = yes; then |
|---|
| 38 | dnl Provide a substitute <stdarg.h> file. |
|---|
| 39 | STDARG_H=stdarg.h |
|---|
| 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" |
|---|
| 45 | fi |
|---|
| 46 | else |
|---|
| 47 | dnl Provide a substitute in <config.h>, either __va_copy or as a simple |
|---|
| 48 | dnl assignment. |
|---|
| 49 | gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [ |
|---|
| 50 | AC_TRY_COMPILE([#include <stdarg.h>], [ |
|---|
| 51 | #ifndef __va_copy |
|---|
| 52 | error, bail out |
|---|
| 53 | #endif |
|---|
| 54 | ], |
|---|
| 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.]) |
|---|
| 59 | else |
|---|
| 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.]) |
|---|
| 64 | fi |
|---|
| 65 | fi |
|---|
| 66 | fi |
|---|
| 67 | ]) |
|---|