Commit | Line | Data |
---|---|---|
49114fd4 LC |
1 | # stdarg.m4 serial 5 |
2 | dnl Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc. | |
4f02b98d LC |
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], [ | |
9157d901 LC |
16 | AC_COMPILE_IFELSE( |
17 | [AC_LANG_PROGRAM( | |
18 | [[#include <stdarg.h>]], | |
19 | [[ | |
4f02b98d LC |
20 | #ifndef va_copy |
21 | void (*func) (va_list, va_list) = va_copy; | |
22 | #endif | |
9157d901 LC |
23 | ]])], |
24 | [gl_cv_func_va_copy=yes], | |
25 | [gl_cv_func_va_copy=no])]) | |
4f02b98d LC |
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__ | |
38 | AIX vaccine | |
39 | #endif | |
40 | ], [gl_aixcc=yes], [gl_aixcc=no]) | |
41 | if test $gl_aixcc = yes; then | |
42 | dnl Provide a substitute <stdarg.h> file. | |
43 | STDARG_H=stdarg.h | |
49114fd4 | 44 | gl_NEXT_HEADERS([stdarg.h]) |
4f02b98d LC |
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" | |
49 | fi | |
50 | else | |
51 | dnl Provide a substitute in <config.h>, either __va_copy or as a simple | |
52 | dnl assignment. | |
53 | gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [ | |
9157d901 LC |
54 | AC_COMPILE_IFELSE( |
55 | [AC_LANG_PROGRAM( | |
56 | [[#include <stdarg.h>]], | |
57 | [[ | |
4f02b98d LC |
58 | #ifndef __va_copy |
59 | error, bail out | |
60 | #endif | |
9157d901 LC |
61 | ]])], |
62 | [gl_cv_func___va_copy=yes], | |
63 | [gl_cv_func___va_copy=no])]) | |
4f02b98d LC |
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.]) | |
67 | else | |
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.]) | |
72 | fi | |
73 | fi | |
74 | fi | |
75 | ]) |