Hi,
We could not build GnuTLS-2.2.2 on AIX-5.1 in 64 bit mode because
va_copy requires -qlanglvl=extc99, however, with that flag compilation
failed (and many warnings were issued).
The warnings were like:
1506-784 (W) Decimal integer constant "18446744073709551615" is out of range
for any use of ULONG_MAX.
Finally it errored out in minilzo when it saw this:
#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
# error "your limits.h macros are broken"
#endif
I could not find an xlc flag that I could add to -qlanglvl=extc99 to
make these warnings and errors go away.
Removing -qlanglvl=extc99 resulted in undefined symbols for va_copy.
Turns out that even though config.h correctly has '#define va_copy
gl_va_copy', xlc's stddef.h #undefs va_copy and does not define it to
the builtin.
xlc's stdarg.h also does not have any include guards, so you can not
#include <stdarg.h> then #define va_copy, as the next time stdarg.h
gets included it will get undefined all over again.
This patch allows us to build GnuTLS on AIX 5.1 without any -qlanglvl
flags.
Thanks,
Peter
2008-??-?? Peter O'Gorman <[EMAIL PROTECTED]>
* modules/stdarg: Use a replacement header for va_copy.
* lib/stdarg.in.h: This is it.
* m4/stdarg.m4: Use the replacement header if va_copy and
__va_copy are not available.
diff --git a/m4/stdarg.m4 b/m4/stdarg.m4
index e8e680a..36af1ad 100644
--- a/m4/stdarg.m4
+++ b/m4/stdarg.m4
@@ -9,6 +9,10 @@ dnl Provide a working va_copy in combination with <stdarg.h>.
AC_DEFUN([gl_STDARG_H],
[
+ HAVE_VA_COPY=1
+ STDARG_H=
+ AC_SUBST([STDARG_H])
+ AC_SUBST([HAVE_VA_COPY])
AC_MSG_CHECKING([for va_copy])
AC_CACHE_VAL([gl_cv_func_va_copy], [
AC_TRY_COMPILE([#include <stdarg.h>], [
@@ -31,10 +35,9 @@ error, bail out
AC_DEFINE([va_copy], [__va_copy],
[Define as a macro for copying va_list variables.])
else
- 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
+ HAVE_VA_COPY=0
+ gl_CHECK_NEXT_HEADERS([stdarg.h])
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 <stdarg.h> 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 <stdarg.h> when the system
+# doesn't have one that works with the given compiler.
+stdarg.h: stdarg.in.h
+ rm -f [EMAIL PROTECTED] $@
+ { 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; \
+ } > [EMAIL PROTECTED]
+ mv [EMAIL PROTECTED] $@
+
+MOSTLYCLEANFILES += stdarg.h stdarg.h-t
Include:
#include <stdarg.h>
--- /dev/null Tue Feb 26 22:22:00 2008
+++ lib/stdarg.in.h Tue Feb 26 21:16:02 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 2, 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. */
[EMAIL PROTECTED]@ @NEXT_STDARG_H@
+
+#ifndef _GL_STDARG_H
+#define _GL_STDARG_H
+
+#if ! @HAVE_VA_COPY@
+#define va_copy(a,b) ((a) = (b))
+#endif
+
+#endif /* _GL_STDARG_H */
+#endif /* _GL_STDARG_H */