This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, committed, hpux] Patch to fix c99 test failures
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dave at hiauly1 dot hia dot nrc dot ca
- Date: Tue, 28 Apr 2009 08:24:09 -0700 (PDT)
- Subject: [patch, committed, hpux] Patch to fix c99 test failures
- Reply-to: sje at cup dot hp dot com
I have committed the attached fixincludes and gcc patch to fix the
c99-stdint-* failures on HP-UX PA and IA64 OS's. Tested on IA64 HP-UX
11.23 and 11.31 and on PA HP-UX 11.11 and 11.23.
Steve Ellcey
sje@cup.hp.com
2009-04-28 Steve Ellcey <sje@cup.hp.com>
* inclhack.def (hpux11_uint32_c): Remove.
(hpux_long_double): Disable on hpux11.3*.
(hpux_long_double_2): New.
(hpux_c99_intptr): New.
(hpux_c99_inttypes): New.
(hpux_c99_inttypes2): New.
(hpux_stdint_least): New.
(hpux_stdint_fast): New.
(hpux_inttype_int_least8_t): New.
(hpux_inttype_int8_t): New.
* fixincl.x: Regenerate.
* tests/base/sys/_inttypes.h: New.
* tests/base/inttypes.h: Update.
* tests/base/stdlib.h: Update.
* tests/base/stdint.h: Update.
Index: inclhack.def
===================================================================
--- inclhack.def (revision 146867)
+++ inclhack.def (working copy)
@@ -1595,35 +1595,6 @@ fix = {
"extern int snprintf(char *, _hpux_size_t, char *, ...);";
};
-
-/*
- * 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\\)";
- c_fix = format;
- c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)';
- test_text =
- "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n"
- "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)";
-};
-
-
/*
* Fix hpux 11.00 broken vsnprintf declaration
*/
@@ -1707,6 +1678,8 @@ fix = {
*/
fix = {
hackname = hpux_long_double;
+ mach = "*-*-hpux10*";
+ mach = "*-*-hpux11.[012]*";
files = stdlib.h;
select = "extern[ \t]long_double[ \t]strtold";
bypass = "long_double_t";
@@ -1722,6 +1695,20 @@ fix = {
"extern long_double strtold(const char *, char **);\n";
};
+ /*
+ * We cannot use the above rule on 11.31 because it removes the strtold
+ * definition. ia64 is OK with no hack, PA needs some help.
+ */
+fix = {
+ hackname = hpux_long_double_2;
+ mach = "hppa*-*-hpux11.3*";
+ files = stdlib.h;
+ select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
+ c_fix = format;
+ c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
+
+ test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
+};
/*
* Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
@@ -1835,6 +1822,97 @@ fix = {
"}\n";
};
+fix = {
+ hackname = hpux_c99_intptr;
+ mach = "*-hp-hpux11.3*";
+ files = stdint.h;
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
+ test_text = "#define PTRDIFF_MAX INT32_MAX\n"
+ "#define PTRDIFF_MIN INT32_MIN\n"
+ "#define INTPTR_MAX INT32_MAX\n"
+ "#define INTPTR_MIN INT32_MIN\n"
+ "#define UINTPTR_MAX UINT32_MAX\n"
+ "#define SIZE_MAX UINT32_MAX\n";
+};
+
+/*
+ * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
+ */
+
+fix = {
+ hackname = hpux_c99_inttypes;
+ mach = "*-hp-hpux11.[23]*";
+ files = inttypes.h;
+ files = stdint.h;
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
+ test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
+ "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
+ "#define INT32_C(__c) __CONCAT__(__c,l)\n"
+ "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
+};
+
+fix = {
+ hackname = hpux_c99_inttypes2;
+ mach = "*-hp-hpux11.2*";
+ files = stdint.h;
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
+ sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
+ test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
+ "# define UINT8_C(__c) ((unsigned char)(__c))\n"
+ "# define INT16_C(__c) ((short)(__c))\n"
+ "# define UINT16_C(__c) ((unsigned short)(__c))\n";
+};
+
+fix = {
+ hackname = hpux_stdint_least;
+ mach = "*-hp-hpux11.2*";
+ files = stdint.h;
+ select = "^[ \t]*#[ \t]*define[ \t]*UINT_LEAST64_MAX[ \t]*ULLONG_MAX";
+ c_fix = format;
+ c_fix_arg = "#ifdef __LP64__\n# define UINT_LEAST64_MAX ULONG_MAX\n#else\n%0\n#endif\n";
+ test_text ="# define UINT_LEAST64_MAX ULLONG_MAX\n";
+};
+
+fix = {
+ hackname = hpux_stdint_fast;
+ mach = "*-hp-hpux11.2*";
+ files = stdint.h;
+ select = "^[ \t]*#[ \t]*define[ \t]*UINT_FAST64_MAX[ \t]*ULLONG_MAX";
+ c_fix = format;
+ c_fix_arg = "#ifdef __LP64__\n# define UINT_FAST64_MAX ULONG_MAX\n#else\n%0\n#endif\n";
+ test_text ="# define UINT_FAST64_MAX ULLONG_MAX\n";
+};
+
+fix = {
+ hackname = hpux_inttype_int_least8_t;
+ mach = "*-hp-hpux11.*";
+ files = sys/_inttypes.h;
+ select = "^[ \t]*typedef[ \t]*char[ \t]*int_least8_t.*";
+ c_fix = format;
+ c_fix_arg = "typedef signed char int_least8_t;";
+ test_text ="typedef char int_least8_t;\n";
+};
+
+fix = {
+ hackname = hpux_inttype_int8_t;
+ mach = "*-hp-hpux11.*";
+ files = sys/_inttypes.h;
+ select = "^[ \t]*typedef[ \t]*char[ \t]*int8_t.*";
+ c_fix = format;
+ c_fix_arg = "typedef signed char int8_t;";
+ test_text ="typedef char int8_t;\n";
+};
+
/*
* Fix glibc definition of HUGE_VAL in terms of hex floating point constant
*/
Index: tests/base/sys/_inttypes.h
===================================================================
--- tests/base/sys/_inttypes.h (revision 0)
+++ tests/base/sys/_inttypes.h (revision 0)
@@ -0,0 +1,21 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/sys/_inttypes.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( HPUX_INTTYPE_INT_LEAST8_T_CHECK )
+typedef signed char int_least8_t;
+
+#endif /* HPUX_INTTYPE_INT_LEAST8_T_CHECK */
+
+
+#if defined( HPUX_INTTYPE_INT8_T_CHECK )
+typedef signed char int8_t;
+
+#endif /* HPUX_INTTYPE_INT8_T_CHECK */
Index: tests/base/inttypes.h
===================================================================
--- tests/base/inttypes.h (revision 146867)
+++ tests/base/inttypes.h (working copy)
@@ -9,7 +9,10 @@
-#if defined( HPUX11_UINT32_C_CHECK )
-#define CONCAT_U__(__c) __CONCAT__(__c,u)
-#define UINT32_C(__c) __CONCAT__(__c,ul)
-#endif /* HPUX11_UINT32_C_CHECK */
+#if defined( HPUX_C99_INTTYPES_CHECK )
+#define UINT8_C(__c) (__c)
+#define UINT16_C(__c) (__c)
+#define INT32_C(__c) (__c)
+#define UINT32_C(__c) __CONCAT__(__c,u)
+
+#endif /* HPUX_C99_INTTYPES_CHECK */
Index: tests/base/stdlib.h
===================================================================
--- tests/base/stdlib.h (revision 146867)
+++ tests/base/stdlib.h (working copy)
@@ -20,6 +20,12 @@ extern long double strtold(const char *,
#endif /* HPUX_LONG_DOUBLE_CHECK */
+#if defined( HPUX_LONG_DOUBLE_2_CHECK )
+# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)
+
+#endif /* HPUX_LONG_DOUBLE_2_CHECK */
+
+
#if defined( INT_ABORT_FREE_AND_EXIT_CHECK )
extern void abort(int);
extern void free(void*);
Index: tests/base/stdint.h
===================================================================
--- tests/base/stdint.h (revision 146867)
+++ tests/base/stdint.h (working copy)
@@ -9,6 +9,48 @@
+#if defined( HPUX_C99_INTPTR_CHECK )
+#define PTRDIFF_MAX __PTRDIFF_MAX__
+#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
+#define INTPTR_MAX (2147483647l)
+#define INTPTR_MIN (-INTPTR_MAX - 1)
+#define UINTPTR_MAX (4294967295ul)
+#define SIZE_MAX __SIZE_MAX__
+
+#endif /* HPUX_C99_INTPTR_CHECK */
+
+
+#if defined( HPUX_C99_INTTYPES2_CHECK )
+#define INT8_C(__c) (__c)
+#define UINT8_C(c) __UINT8_C(c)
+#define INT16_C(__c) (__c)
+#define UINT16_C(c) __UINT16_C(c)
+
+#endif /* HPUX_C99_INTTYPES2_CHECK */
+
+
+#if defined( HPUX_STDINT_LEAST_CHECK )
+#ifdef __LP64__
+# define UINT_LEAST64_MAX ULONG_MAX
+#else
+# define UINT_LEAST64_MAX ULLONG_MAX
+#endif
+
+
+#endif /* HPUX_STDINT_LEAST_CHECK */
+
+
+#if defined( HPUX_STDINT_FAST_CHECK )
+#ifdef __LP64__
+# define UINT_FAST64_MAX ULONG_MAX
+#else
+# define UINT_FAST64_MAX ULLONG_MAX
+#endif
+
+
+#endif /* HPUX_STDINT_FAST_CHECK */
+
+
#if defined( IRIX_STDINT_C99_CHECK )
#if 0
#error This header file is to be used only for c99 mode compilations
2009-04-28 Steve Ellcey <sje@cup.hp.com>
* config.gcc (hppa*64*-*-hpux11*): Set use_gcc_stdint and
add hpux-stdint.h to tm_file.
(hppa[12]*-*-hpux11*): Ditto.
(ia64*-*-hpux*): Ditto.
* config/hpux-stdint.h: New.
* gcc/config/ia64/hpux.h (TARGET_OS_CPP_BUILTINS): Set
__STDC_EXT__ for all compiles.
* gcc/config/pa/pa-hpux.h: Ditto.
* gcc/config/pa/pa-hpux10.h: Ditto.
* gcc/config/pa/pa-hpux11.h: Ditto.
Index: config.gcc
===================================================================
--- config.gcc (revision 146867)
+++ config.gcc (working copy)
@@ -975,6 +975,16 @@ hppa*64*-*-hpux11*)
;;
esac
gas=yes
+ case ${target} in
+ *-*-hpux11.[01]*)
+ use_gcc_stdint=provide
+ tm_file="${tm_file} hpux-stdint.h"
+ ;;
+ *-*-hpux11.[23]*)
+ use_gcc_stdint=wrap
+ tm_file="${tm_file} hpux-stdint.h"
+ ;;
+ esac
;;
hppa[12]*-*-hpux11*)
case ${target} in
@@ -1005,6 +1015,16 @@ hppa[12]*-*-hpux11*)
esac
use_collect2=yes
gas=yes
+ case ${target} in
+ *-*-hpux11.[01]*)
+ use_gcc_stdint=provide
+ tm_file="${tm_file} hpux-stdint.h"
+ ;;
+ *-*-hpux11.[23]*)
+ use_gcc_stdint=wrap
+ tm_file="${tm_file} hpux-stdint.h"
+ ;;
+ esac
;;
i[34567]86-*-darwin*)
need_64bit_hwint=yes
@@ -1360,6 +1380,8 @@ ia64*-*-hpux*)
c_target_objs="ia64-c.o"
cxx_target_objs="ia64-c.o"
extra_options="${extra_options} ia64/ilp32.opt"
+ use_gcc_stdint=wrap
+ tm_file="${tm_file} hpux-stdint.h"
;;
iq2000*-*-elf*)
tm_file="svr4.h elfos.h newlib-stdint.h iq2000/iq2000.h"
Index: config/hpux-stdint.h
===================================================================
--- config/hpux-stdint.h (revision 0)
+++ config/hpux-stdint.h (revision 0)
@@ -0,0 +1,34 @@
+
+/* These should be correct for ia64-hp-hpux11.23. */
+
+#define SIG_ATOMIC_TYPE "unsigned int"
+
+#define INT8_TYPE "signed char"
+#define INT16_TYPE "short int"
+#define INT32_TYPE "int"
+#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
+#define UINT8_TYPE "unsigned char"
+#define UINT16_TYPE "short unsigned int"
+#define UINT32_TYPE "unsigned int"
+#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
+
+#define INT_LEAST8_TYPE "signed char"
+#define INT_LEAST16_TYPE "short int"
+#define INT_LEAST32_TYPE "int"
+#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
+#define UINT_LEAST8_TYPE "unsigned char"
+#define UINT_LEAST16_TYPE "short unsigned int"
+#define UINT_LEAST32_TYPE "unsigned int"
+#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
+
+#define INT_FAST8_TYPE "int"
+#define INT_FAST16_TYPE "int"
+#define INT_FAST32_TYPE "int"
+#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
+#define UINT_FAST8_TYPE "unsigned int"
+#define UINT_FAST16_TYPE "unsigned int"
+#define UINT_FAST32_TYPE "unsigned int"
+#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
+
+#define INTPTR_TYPE "long int"
+#define UINTPTR_TYPE "long unsigned int"
Index: config/ia64/hpux.h
===================================================================
--- config/ia64/hpux.h (revision 146867)
+++ config/ia64/hpux.h (working copy)
@@ -46,11 +46,11 @@ do { \
builtin_define("__IA64__"); \
builtin_define("_LONGLONG"); \
builtin_define("_INCLUDE_LONGLONG"); \
+ builtin_define("__STDC_EXT__"); \
builtin_define("_UINT128_T"); \
if (c_dialect_cxx () || !flag_iso) \
{ \
builtin_define("_HPUX_SOURCE"); \
- builtin_define("__STDC_EXT__"); \
builtin_define("__STDCPP__"); \
builtin_define("_INCLUDE__STDC_A1_SOURCE"); \
} \
Index: config/pa/pa-hpux.h
===================================================================
--- config/pa/pa-hpux.h (revision 146867)
+++ config/pa/pa-hpux.h (working copy)
@@ -56,11 +56,11 @@ along with GCC; see the file COPYING3.
builtin_define ("__hpux__"); \
builtin_define ("__unix"); \
builtin_define ("__unix__"); \
+ builtin_define ("__STDC_EXT__"); \
if (c_dialect_cxx ()) \
{ \
builtin_define ("_HPUX_SOURCE"); \
builtin_define ("_INCLUDE_LONGLONG"); \
- builtin_define ("__STDC_EXT__"); \
} \
else if (!flag_iso) \
{ \
@@ -76,8 +76,6 @@ along with GCC; see the file COPYING3.
builtin_define ("_PWB"); \
builtin_define ("PWB"); \
} \
- else \
- builtin_define ("__STDC_EXT__"); \
} \
if (TARGET_SIO) \
builtin_define ("_SIO"); \
Index: config/pa/pa-hpux10.h
===================================================================
--- config/pa/pa-hpux10.h (revision 146867)
+++ config/pa/pa-hpux10.h (working copy)
@@ -38,11 +38,11 @@ along with GCC; see the file COPYING3.
builtin_define ("__hpux__"); \
builtin_define ("__unix"); \
builtin_define ("__unix__"); \
+ builtin_define ("__STDC_EXT__"); \
if (c_dialect_cxx ()) \
{ \
builtin_define ("_HPUX_SOURCE"); \
builtin_define ("_INCLUDE_LONGLONG"); \
- builtin_define ("__STDC_EXT__"); \
builtin_define ("__STDCPP__"); \
} \
else if (!flag_iso) \
@@ -58,8 +58,6 @@ along with GCC; see the file COPYING3.
builtin_define ("_PWB"); \
builtin_define ("PWB"); \
} \
- else \
- builtin_define ("__STDC_EXT__"); \
} \
if (flag_pa_unix >= 1995) \
{ \
Index: config/pa/pa-hpux11.h
===================================================================
--- config/pa/pa-hpux11.h (revision 146867)
+++ config/pa/pa-hpux11.h (working copy)
@@ -37,11 +37,11 @@ along with GCC; see the file COPYING3.
builtin_define ("__hpux__"); \
builtin_define ("__unix"); \
builtin_define ("__unix__"); \
+ builtin_define ("__STDC_EXT__"); \
if (c_dialect_cxx ()) \
{ \
builtin_define ("_HPUX_SOURCE"); \
builtin_define ("_INCLUDE_LONGLONG"); \
- builtin_define ("__STDC_EXT__"); \
builtin_define ("__STDCPP__"); \
} \
else \
@@ -59,8 +59,6 @@ along with GCC; see the file COPYING3.
builtin_define ("_PWB"); \
builtin_define ("PWB"); \
} \
- else \
- builtin_define ("__STDC_EXT__"); \
} \
} \
if (!TARGET_64BIT) \