stdarg.m4 2.8 KB

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