Debian Codegraph @

tools/gnulib/m4/stdarg.m4

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