This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch]: handle missing fputc_unlocked on hpux
- From: "Kaveh R. Ghazi" <ghazi at caipclassic dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dave at hiauly1 dot hia dot nrc dot ca
- Date: Wed, 30 Nov 2005 12:50:03 -0500 (EST)
- Subject: [Patch]: handle missing fputc_unlocked on hpux
During an offline discussion about PR 25158, Dave listed for me all
the unlocked stdio functions in hpux's libc. Turns out it has
putc_unlocked, which can be used in lieu of fputc_unlocked.
This patch allows hpux to optimize fputs_unlocked with a string length
of 1 into putc_unlocked.
I believe the oldest hpux we support is 10. Dave is checking if
putc_unlocked exists there as well.
I tested with a cross compiler targetted to hppa2.0w-hp-hpux11.11 and
compiled a fputs_unlocked testcase with strings of length 1. They
turned into fputc_unlocked as expected, whereas before they weren't.
Assuming Dave's testing passes, okay for mainline and 4.1?
Thanks,
--Kaveh
2005-11-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.def (BUILT_IN_PUTC, BUILT_IN_PUTC_UNLOCKED): New.
* config/pa/pa.c (pa_init_builtins): If we detect
DONT_HAVE_FPUTC_UNLOCKED, set builtin fputc_unlocked to
putc_unlocked.
diff -rup orig/egcc-SVN20051129/gcc/builtins.def egcc-SVN20051129/gcc/builtins.def
--- orig/egcc-SVN20051129/gcc/builtins.def 2005-11-03 10:40:14.000000000 -0500
+++ egcc-SVN20051129/gcc/builtins.def 2005-11-30 12:09:15.000000000 -0500
@@ -510,6 +510,8 @@ DEF_LIB_BUILTIN (BUILT_IN_STRSTR,
/* Category: stdio builtins. */
DEF_LIB_BUILTIN (BUILT_IN_FPRINTF, "fprintf", BT_FN_INT_FILEPTR_CONST_STRING_VAR, ATTR_FORMAT_PRINTF_2_3)
DEF_EXT_LIB_BUILTIN (BUILT_IN_FPRINTF_UNLOCKED, "fprintf_unlocked", BT_FN_INT_FILEPTR_CONST_STRING_VAR, ATTR_FORMAT_PRINTF_2_3)
+DEF_LIB_BUILTIN (BUILT_IN_PUTC, "putc", BT_FN_INT_INT_FILEPTR, ATTR_NONNULL_LIST)
+DEF_EXT_LIB_BUILTIN (BUILT_IN_PUTC_UNLOCKED, "putc_unlocked", BT_FN_INT_INT_FILEPTR, ATTR_NONNULL_LIST)
DEF_LIB_BUILTIN (BUILT_IN_FPUTC, "fputc", BT_FN_INT_INT_FILEPTR, ATTR_NONNULL_LIST)
DEF_EXT_LIB_BUILTIN (BUILT_IN_FPUTC_UNLOCKED, "fputc_unlocked", BT_FN_INT_INT_FILEPTR, ATTR_NONNULL_LIST)
DEF_LIB_BUILTIN (BUILT_IN_FPUTS, "fputs", BT_FN_INT_CONST_STRING_FILEPTR, ATTR_NONNULL_LIST)
diff -rup orig/egcc-SVN20051129/gcc/config/pa/pa.c egcc-SVN20051129/gcc/config/pa/pa.c
--- orig/egcc-SVN20051129/gcc/config/pa/pa.c 2005-11-22 20:00:46.000000000 -0500
+++ egcc-SVN20051129/gcc/config/pa/pa.c 2005-11-30 12:06:41.000000000 -0500
@@ -495,8 +495,10 @@ static void
pa_init_builtins (void)
{
#ifdef DONT_HAVE_FPUTC_UNLOCKED
- built_in_decls[(int) BUILT_IN_FPUTC_UNLOCKED] = NULL_TREE;
- implicit_built_in_decls[(int) BUILT_IN_FPUTC_UNLOCKED] = NULL_TREE;
+ built_in_decls[(int) BUILT_IN_FPUTC_UNLOCKED] =
+ built_in_decls[(int) BUILT_IN_PUTC_UNLOCKED];
+ implicit_built_in_decls[(int) BUILT_IN_FPUTC_UNLOCKED]
+ = implicit_built_in_decls[(int) BUILT_IN_PUTC_UNLOCKED];
#endif
}