| 1 |
# stdarg.m4 |
| 2 |
# serial 8 |
| 3 |
dnl Copyright (C) 2006, 2008-2026 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
dnl From Bruno Haible. |
| 10 |
dnl Provide a working va_copy in combination with <stdarg.h>. |
| 11 |
|
| 12 |
AC_DEFUN([gl_STDARG_H], |
| 13 |
[ |
| 14 |
GL_GENERATE_STDARG_H=false |
| 15 |
NEXT_STDARG_H='<stdarg.h>' |
| 16 |
AC_CACHE_CHECK([for va_copy], |
| 17 |
[gl_cv_func_va_copy], |
| 18 |
[AC_COMPILE_IFELSE( |
| 19 |
[AC_LANG_PROGRAM( |
| 20 |
[[#include <stdarg.h>]], |
| 21 |
[[ |
| 22 |
#ifndef va_copy |
| 23 |
void (*func) (va_list, va_list) = va_copy; |
| 24 |
#endif |
| 25 |
]])], |
| 26 |
[gl_cv_func_va_copy=yes], |
| 27 |
[gl_cv_func_va_copy=no]) |
| 28 |
]) |
| 29 |
if test $gl_cv_func_va_copy = no; then |
| 30 |
dnl Provide a substitute. |
| 31 |
dnl Usually a simple definition in <config.h> is enough. Not so on AIX 5 |
| 32 |
dnl with some versions of the /usr/vac/bin/cc compiler. It has an <stdarg.h> |
| 33 |
dnl which does '#undef va_copy', leading to a missing va_copy symbol. For |
| 34 |
dnl this platform, we use an <stdarg.h> substitute. But we cannot use this |
| 35 |
dnl approach on other platforms, because <stdarg.h> often defines only |
| 36 |
dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do |
| 37 |
dnl not work in this situation. |
| 38 |
AC_EGREP_CPP([vaccine], |
| 39 |
[#if defined _AIX && !defined __GNUC__ |
| 40 |
AIX vaccine |
| 41 |
#endif |
| 42 |
], [gl_aixcc=yes], [gl_aixcc=no]) |
| 43 |
if test $gl_aixcc = yes; then |
| 44 |
dnl Provide a substitute <stdarg.h> file. |
| 45 |
GL_GENERATE_STDARG_H=true |
| 46 |
gl_NEXT_HEADERS([stdarg.h]) |
| 47 |
dnl Fallback for the case when <stdarg.h> contains only macro definitions. |
| 48 |
if test "$gl_cv_next_stdarg_h" = '""'; then |
| 49 |
gl_cv_next_stdarg_h='"///usr/include/stdarg.h"' |
| 50 |
NEXT_STDARG_H="$gl_cv_next_stdarg_h" |
| 51 |
fi |
| 52 |
else |
| 53 |
dnl Provide a substitute in <config.h>, either __va_copy or as a simple |
| 54 |
dnl assignment. |
| 55 |
gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [ |
| 56 |
AC_COMPILE_IFELSE( |
| 57 |
[AC_LANG_PROGRAM( |
| 58 |
[[#include <stdarg.h>]], |
| 59 |
[[ |
| 60 |
#ifndef __va_copy |
| 61 |
error, bail out |
| 62 |
#endif |
| 63 |
]])], |
| 64 |
[gl_cv_func___va_copy=yes], |
| 65 |
[gl_cv_func___va_copy=no])]) |
| 66 |
if test $gl_cv_func___va_copy = yes; then |
| 67 |
AC_DEFINE([va_copy], [__va_copy], |
| 68 |
[Define as a macro for copying va_list variables.]) |
| 69 |
else |
| 70 |
AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */ |
| 71 |
#define gl_va_copy(a,b) ((a) = (b))]) |
| 72 |
AC_DEFINE([va_copy], [gl_va_copy], |
| 73 |
[Define as a macro for copying va_list variables.]) |
| 74 |
fi |
| 75 |
fi |
| 76 |
fi |
| 77 |
AC_SUBST([NEXT_STDARG_H]) |
| 78 |
]) |