diff --git a/doc/posix-functions/va_copy.texi b/doc/posix-functions/va_copy.texi index c5a012b..a2ce0e3 100644 --- a/doc/posix-functions/va_copy.texi +++ b/doc/posix-functions/va_copy.texi @@ -10,6 +10,13 @@ Portability problems fixed by Gnulib: @itemize @item This macro is missing on some platforms. address@hidden +On some platforms va_copy is available as __va_copy and so needs to be +defined as such. address@hidden +On AIX systems with xlc, the @code{-qlanglvl=extc99} or address@hidden is normally required for va_copy to be +defined. This module makes it available even without that flag. @end itemize Portability problems not fixed by Gnulib: diff --git a/m4/stdarg.m4 b/m4/stdarg.m4 index e8e680a..db69478 100644 --- a/m4/stdarg.m4 +++ b/m4/stdarg.m4 @@ -9,6 +9,8 @@ dnl Provide a working va_copy in combination with . AC_DEFUN([gl_STDARG_H], [ + STDARG_H= + AC_SUBST([STDARG_H]) AC_MSG_CHECKING([for va_copy]) AC_CACHE_VAL([gl_cv_func_va_copy], [ AC_TRY_COMPILE([#include ], [ @@ -31,10 +33,25 @@ error, bail out AC_DEFINE([va_copy], [__va_copy], [Define as a macro for copying va_list variables.]) else + AC_LANG_PUSH(C) + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([#if defined _AIX && ! defined __GNUC__ +choke me +#endif],[]),[ AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */ #define gl_va_copy(a,b) ((a) = (b))]) AC_DEFINE([va_copy], [gl_va_copy], [Define as a macro for copying va_list variables.]) +],[ + STDARG_H=stdarg.h + gl_CHECK_NEXT_HEADERS([stdarg.h]) + # Above will not work on systems that do not have #include_next + # because stdarg.h has only macros. Fix this below. + if test "x$gl_cv_next_stdarg_h" = "x\"\""; then + gl_cv_next_stdarg_h=\"///usr/include/stdarg.h\" + NEXT_STDARG_H="$gl_cv_next_stdarg_h" + fi +]) + AC_LANG_POP(C) fi fi ]) diff --git a/modules/stdarg b/modules/stdarg index 48febb2..e386f3e 100644 --- a/modules/stdarg +++ b/modules/stdarg @@ -3,8 +3,10 @@ An that conforms to C99. Files: m4/stdarg.m4 +lib/stdarg.in.h Depends-on: +include_next configure.ac-early: dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode @@ -17,6 +19,21 @@ configure.ac: gl_STDARG_H Makefile.am: +BUILT_SOURCES += $(STDARG_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +stdarg.h: stdarg.in.h + rm -f address@hidden $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ + -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \ + -e 's/@''HAVE_VA_COPY''@/$(HAVE_VA_COPY)/g' \ + < $(srcdir)/stdarg.in.h; \ + } > address@hidden + mv address@hidden $@ + +MOSTLYCLEANFILES += stdarg.h stdarg.h-t Include: #include --- /dev/null Wed Feb 27 07:11:00 2008 +++ a/lib/stdarg.in.h Tue Feb 26 21:18:57 2008 @@ -0,0 +1,31 @@ +/* + Copyright (C) 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _GL_STDARG_H + +/* The include_next requires a split double-inclusion guard. */ address@hidden@ @NEXT_STDARG_H@ + +#ifndef _GL_STDARG_H +#define _GL_STDARG_H + +#ifndef va_copy +#define va_copy(a,b) ((a) = (b)) +#endif + +#endif /* _GL_STDARG_H */ +#endif /* _GL_STDARG_H */