[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lib/dirent.in.h fails on AIX
From: |
Eric Blake |
Subject: |
Re: lib/dirent.in.h fails on AIX |
Date: |
Wed, 20 May 2009 20:52:21 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Bruno Haible <bruno <at> clisp.org> writes:
> > I have no idea why:
> > #include <math.h>
> > behaves differently than:
> > #include "///usr/vac/include/math.h"
> > You'd figure with the #include_next <math.h> in /usr/vac/include/math.h
> > the behavior would be the same. However, the #include_next <math.h> in
> > /usr/vac/include/math.h is turned into a no-op.
>
> Thanks for this problem summary. Since #include <math.h> works, it's not
> a problem with the inclusion guards (the "#ifdef _H_MATH" or similar), but
> - as you say - a problem with #include_next itself.
>
> What's the result of
> $ grep include_next /usr/vac/include/*.h /usr/vac/include/*/*.h
> ?
>
> Probably the only solution is to use #include_next only in gnulib's math.in.h
> but not in the other header files that are overridden by gnulib. I'm applying
> this; please let us know whether it works.
>
> Bruno
>
> 2008-11-20 Bruno Haible <bruno <at> clisp.org>
>
> Attempt to work around an AIX 5.3, 6.1 compiler bug with include_next.
> * lib/math.in.h: Use INCLUDE_NEXT_AS_FIRST_DIRECTIVE instead of
> INCLUDE_NEXT.
I think I see a logic bug in this patch which explains why Jens Rehsack still
saw a failure in m4 1.4.13:
> +++ lib/math.in.h 2008-11-20 23:26:08.000000000 +0100
> @@ -22,7 +22,7 @@
> #endif
>
> /* The include_next requires a split double-inclusion guard. */
> address@hidden@ @NEXT_MATH_H@
> address@hidden@ @NEXT_MATH_H@
NEXT_MATH_H is still of the form "///usr/vac/include/math.h" here, but that's
exactly what we said was the second of two bugs in xlc's include_next
implementation - #include_next "absolute" is a no-op. Let's examine the three
classes of compilers:
> if test $gl_cv_have_include_next = yes; then
> INCLUDE_NEXT=include_next
> + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
> if test -n "$GCC"; then
> PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
> fi
For this compiler type (including gcc), #include_next always works, NEXT_MATH_H
is always <math.h>, and we are okay.
> else
> - INCLUDE_NEXT=include
> + if test $gl_cv_have_include_next = buggy; then
> + INCLUDE_NEXT=include
> + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
For this compiler (AIX's xlc), we want
@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ <math.h>
But we must also ensure that, for other headers,
@INCLUDE_NEXT@ @NEXT_header@
we are using the absolute path in @NEXT_header@ since @INCLUDE_NEXT@ is only
include.
> + else
> + INCLUDE_NEXT=include
> + INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
And for this type of compiler, we always want NEXT_MATH_H to
be "///usr/vac/include/math.h", and
@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ <math.h>
would be a bug.
So, the problem is basically that NEXT_MATH_H is usable with @INCLUDE_NEXT@
regardless of whether it expands to include or include_next, but it is NOT
usable with @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ in the case of xlc. On the
converse side, @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ <math.h> would work for gcc
and xlc, but will break for compilers that lack include_next altogether. The
solution - add another substituted variable.
By the way, m4_quote(m4_defn([foo])) is overkill - m4_defn already properly
quotes its output as a single m4 argument, so the m4_quote is a no-op (m4_quote
is only useful when collecting multiple unquoted m4 arguments into a single
string).
What do you think of this patch?
From: Eric Blake <address@hidden>
Date: Wed, 20 May 2009 14:45:07 -0600
Subject: [PATCH] Another try at making math.h work for AIX xlc.
* m4/include_next.m4: Avoid redundant m4_quote.
(gl_CHECK_NEXT_HEADERS): Also define
NEXT_header_AS_FIRST_DIRECTIVE.
* lib/math.in.h (includes): Use it.
Reported by Jens Rehsack.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 9 +++++++++
lib/math.in.h | 2 +-
m4/include_next.m4 | 31 ++++++++++++++++++++-----------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index eeab720..2f9ff72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-05-20 Eric Blake <address@hidden>
+
+ Another try at making math.h work for AIX xlc.
+ * m4/include_next.m4: Avoid redundant m4_quote.
+ (gl_CHECK_NEXT_HEADERS): Also define
+ NEXT_header_AS_FIRST_DIRECTIVE.
+ * lib/math.in.h (includes): Use it.
+ Reported by Jens Rehsack.
+
2009-05-20 Bruno Haible <address@hidden>
Make zeroptr.h work on mingw.
diff --git a/lib/math.in.h b/lib/math.in.h
index a0efefd..22f47c6 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -22,7 +22,7 @@
#endif
/* The include_next requires a split double-inclusion guard. */
address@hidden@ @NEXT_MATH_H@
address@hidden@ @NEXT_MATH_H_AS_FIRST_DIRECTIVE@
#ifndef _GL_MATH_H
#define _GL_MATH_H
diff --git a/m4/include_next.m4 b/m4/include_next.m4
index d6101fe..20b8ca1 100644
--- a/m4/include_next.m4
+++ b/m4/include_next.m4
@@ -1,4 +1,4 @@
-# include_next.m4 serial 12
+# include_next.m4 serial 13
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -71,9 +71,9 @@ EOF
AC_COMPILE_IFELSE([#include <conftest.h>],
[gl_cv_have_include_next=yes],
[CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
- AC_COMPILE_IFELSE([#include <conftest.h>],
- [gl_cv_have_include_next=buggy],
- [gl_cv_have_include_next=no])
+ AC_COMPILE_IFELSE([[#include <conftest.h>]],
+ [gl_cv_have_include_next=buggy],
+ [gl_cv_have_include_next=no])
])
CPPFLAGS="$gl_save_CPPFLAGS"
rm -rf conftestd1a conftestd1b conftestd2
@@ -123,15 +123,15 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
m4_foreach_w([gl_HEADER_NAME], [$1],
[AS_VAR_PUSHDEF([gl_next_header],
- [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
+ [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
if test $gl_cv_have_include_next = yes; then
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
else
AC_CACHE_CHECK(
- [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
- m4_quote(m4_defn([gl_next_header])),
+ [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
+ m4_defn([gl_next_header]),
[AS_VAR_PUSHDEF([gl_header_exists],
- [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
+ [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
if test AS_VAR_GET(gl_header_exists) = yes; then
AC_LANG_CONFTEST(
[AC_LANG_SOURCE(
@@ -153,8 +153,8 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
dnl so use subshell.
AS_VAR_SET([gl_next_header],
['"'`(eval "$gl_absname_cpp conftest.$ac_ext")
2>&AS_MESSAGE_LOG_FD |
- sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
- s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
+ sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
+ s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
s#^/[^/]#//&#
p
q
@@ -165,7 +165,16 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
AS_VAR_POPDEF([gl_header_exists])])
fi
AC_SUBST(
- AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
+ AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
[AS_VAR_GET([gl_next_header])])
+ if test $gl_cv_have_include_next == no; then
+ AC_SUBST(
+ AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])[_AS_FIRST_DIRECTIVE]),
+ [AS_VAR_GET([gl_next_header])])
+ else
+ AC_SUBST(
+ AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])[_AS_FIRST_DIRECTIVE]),
+ ['<'gl_HEADER_NAME'>'])
+ fi
AS_VAR_POPDEF([gl_next_header])])
])
--
1.6.2.4
- Re: lib/dirent.in.h fails on AIX,
Eric Blake <=