Commit abf7cec7 by Gavin Romig-Koch Committed by Jeff Law

fixincludes: Add a HPUX 11 fix for inttypes.h.

        * fixincludes: Add a HPUX 11 fix for inttypes.h.
        * fixinc/inclhack.def: Same.
        * fixinc/inclhack.sh, fixinc/fixincl.sh, fixinc/fixincl.x: Regenerate.

From-SVN: r30004
parent 1c784a0e
Thu Oct 14 23:57:56 1999 Gavin Romig-Koch <gavin@cygnus.com>
* fixincludes: Add a HPUX 11 fix for inttypes.h.
* fixinc/inclhack.def: Same.
* fixinc/inclhack.sh, fixinc/fixincl.sh, fixinc/fixincl.x: Regenerate.
Thu Oct 14 22:51:55 1999 Richard Henderson <rth@cygnus.com>
* alpha.h (GO_IF_LEGITIMATE_SIMPLE_ADDRESS): Accept ADDRESSOF
......
......@@ -6,7 +6,7 @@
# files which are fixed to work correctly with ANSI C and placed in a
# directory that GNU C will search.
#
# This script contains 106 fixup scripts.
# This script contains 107 fixup scripts.
#
# See README-fixinc for more information.
#
......
......@@ -698,6 +698,28 @@ fix = {
sed = "s/^extern struct sigevent;/struct sigevent;/";
};
/*
* In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
* of UINT32_C has undefined behavior according to ISO/ANSI:
* the arguments to __CONCAT__ are not macro expanded before the
* concatination happens so the trailing ')' in the first argument
* is concatinated with the 'l' in the second argument creating an
* invalid pp token. The behavior of invalid pp tokens is undefined.
* GCC does not handle these invalid tokens the way the HP compiler does.
* This problem will potentially occur anytime macros are used in the
* arguments to __CONCAT__. A general solution to this problem would be to
* insert another layer of macro between __CONCAT__ and its use
* in UINT32_C. An example of this solution can be found in the C standard.
* A more specific solution, the one used here, is to change the UINT32_C
* macro to not used macros in the arguments to __CONCAT__.
*/
fix = {
hackname = hpux11_uint32_c;
files = inttypes.h;
select = "^#define UINT32_C\\(__c\\)[ \t]*__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)";
sed = "s/^#define UINT32_C(__c)\\([ \t]*\\)__CONCAT__(__CONCAT_U__(__c),l)/#define UINT32_C(__c)\\1__CONCAT__(__c,ul)/";
};
/*
* Determine if we're on Interactive Unix 2.2 or later, in which case we
......
......@@ -2970,6 +2970,42 @@ if [ -r ${LIB}/$file ]; then
fi
fi
# In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition
# of UINT32_C has undefined behavior according to ISO/ANSI:
# the arguments to __CONCAT__ are not macro expanded before the
# concatination happens so the trailing ')' in the first argument
# is concatinated with the 'l' in the second argument creating an
# invalid pp token. The behavior of invalid pp tokens is undefined.
# GCC does not handle these invalid tokens the way the HP compiler does.
# This problem will potentially occur anytime macros are used in the
# arguments to __CONCAT__. A general solution to this problem would be to
# insert another layer of macro between __CONCAT__ and its use
# in UINT32_C. An example of this solution can be found in the C standard.
# A more specific solution, the one used here, is to change the UINT32_C
# macro to not used macros in the arguments to __CONCAT__.
file=inttypes.h
if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
chmod +w ${LIB}/$file 2>/dev/null
chmod a+r ${LIB}/$file 2>/dev/null
fi
if [ -r ${LIB}/$file ]; then
echo "Fixing use of __CONCAT__ in $file"
sed -e 's/^#define UINT32_C(__c)\([ ]*\)__CONCAT__(__CONCAT_U__(__c),l)/#define UINT32_C(__c)\1__CONCAT__(__c,ul)/' \
${LIB}/$file > ${LIB}/${file}.sed
rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
if cmp $file ${LIB}/$file >/dev/null 2>&1; then
rm -f ${LIB}/$file
else
# Find any include directives that use "file".
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${LIB}/$file | sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`; do
dir=`echo $file | sed -e s'|/[^/]*$||'`
required="$required ${INPUT} $dir/$include ${LIB}/$dir/$include"
done
fi
fi
# Some math.h files define struct exception, which conflicts with
# the class exception defined in the C++ file std/stdexcept.h. We
# redefine it to __math_exception. This is not a great fix, but I
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment