This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: kill HOST_PTR_PRINTF


As part of getting rid of legacy traditional C hacks, another thing we
can zap is HOST_PTR_PRINTF.

I'm convinced no supported systems use the backup definitions for
"%p", and here's why: For the backup definitions, in system.h we try
to find an integer format with the same width as a pointer to use as
an alternative.  If GCC were ever to actually use these, the printf
format checks would spank us and with -Werror that would interrupt
bootstrap.  So I doubt any systems without "%p" are bootstrapped on
mainline.  Given that we've been using -Werror for a couple of years,
removing this stuff should be okay.

This patch was bootstrapped on x86_64-unknown-linux-gnu.  Tests are
underway.  Assuming no regressions, okay for mainline?

		Thanks,
		--Kaveh

2005-08-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* aclocal.m4 (gcc_AC_FUNC_PRINTF_PTR): Delete.
	* configure.ac: Don't call gcc_AC_FUNC_PRINTF_PTR.
	* system.h (HOST_PTR_PRINTF): Don't define, poison it.
	
	* bitmap.c, c-decl.c, config/i386/i386-interix.h,
	config/iq2000/iq2000.c, mips-tfile.c, print-rtl.c, print-tree.c:
	Delete HOST_PTR_PRINTF.

	* configure, config.in: Regenerate.

cp:
	* name-lookup.c, ptree.c: Delete HOST_PTR_PRINTF.

diff -rup orig/egcc-CVS20050814/gcc/aclocal.m4 egcc-CVS20050814/gcc/aclocal.m4
--- orig/egcc-CVS20050814/gcc/aclocal.m4	2005-07-25 22:27:38.000000000 -0400
+++ egcc-CVS20050814/gcc/aclocal.m4	2005-08-14 11:48:34.000000000 -0400
@@ -89,27 +89,6 @@ make_compare_target=$gcc_cv_prog_cmp_ski
 AC_SUBST(make_compare_target)
 ])
 
-dnl See if the printf functions in libc support %p in format strings.
-AC_DEFUN([gcc_AC_FUNC_PRINTF_PTR],
-[AC_CACHE_CHECK(whether the printf functions support %p,
-  gcc_cv_func_printf_ptr,
-[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
-
-int main()
-{
-  char buf[64];
-  char *p = buf, *q = NULL;
-  sprintf(buf, "%p", p);
-  sscanf(buf, "%p", &q);
-  return (p != q);
-}]])], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
-	gcc_cv_func_printf_ptr=no)
-rm -f core core.* *.core])
-if test $gcc_cv_func_printf_ptr = yes ; then
-  AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
-fi
-])
-
 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
 AC_DEFUN([gcc_AC_PROG_LN_S],
 [AC_MSG_CHECKING(whether ln -s works)
diff -rup orig/egcc-CVS20050814/gcc/bitmap.c egcc-CVS20050814/gcc/bitmap.c
--- orig/egcc-CVS20050814/gcc/bitmap.c	2005-07-08 21:18:58.000000000 -0400
+++ egcc-CVS20050814/gcc/bitmap.c	2005-08-14 11:49:47.000000000 -0400
@@ -1217,16 +1217,14 @@ debug_bitmap_file (FILE *file, bitmap he
 {
   bitmap_element *ptr;
 
-  fprintf (file, "\nfirst = " HOST_PTR_PRINTF
-	   " current = " HOST_PTR_PRINTF " indx = %u\n",
+  fprintf (file, "\nfirst = %p current = %p indx = %u\n",
 	   (void *) head->first, (void *) head->current, head->indx);
 
   for (ptr = head->first; ptr; ptr = ptr->next)
     {
       unsigned int i, j, col = 26;
 
-      fprintf (file, "\t" HOST_PTR_PRINTF " next = " HOST_PTR_PRINTF
-	       " prev = " HOST_PTR_PRINTF " indx = %u\n\t\tbits = {",
+      fprintf (file, "\t%p next = %p prev = %p indx = %u\n\t\tbits = {",
 	       (void*) ptr, (void*) ptr->next, (void*) ptr->prev, ptr->indx);
 
       for (i = 0; i < BITMAP_ELEMENT_WORDS; i++)
diff -rup orig/egcc-CVS20050814/gcc/c-decl.c egcc-CVS20050814/gcc/c-decl.c
--- orig/egcc-CVS20050814/gcc/c-decl.c	2005-07-30 22:20:30.000000000 -0400
+++ egcc-CVS20050814/gcc/c-decl.c	2005-08-14 11:51:27.000000000 -0400
@@ -466,7 +466,7 @@ c_print_identifier (FILE *file, tree nod
     {
       tree rid = ridpointers[C_RID_CODE (node)];
       indent_to (file, indent + 4);
-      fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"",
+      fprintf (file, "rid %p \"%s\"",
 	       (void *) rid, IDENTIFIER_POINTER (rid));
     }
 }
diff -rup orig/egcc-CVS20050814/gcc/config/i386/i386-interix.h egcc-CVS20050814/gcc/config/i386/i386-interix.h
--- orig/egcc-CVS20050814/gcc/config/i386/i386-interix.h	2005-06-25 22:37:42.000000000 -0400
+++ egcc-CVS20050814/gcc/config/i386/i386-interix.h	2005-08-14 11:54:06.000000000 -0400
@@ -286,7 +286,6 @@ do									\
     }									\
 while (0)
 
-#define HOST_PTR_PRINTF "%p"
 #define HOST_PTR_AS_INT unsigned long
 
 #define PCC_BITFIELD_TYPE_MATTERS 1
diff -rup orig/egcc-CVS20050814/gcc/config/iq2000/iq2000.c egcc-CVS20050814/gcc/config/iq2000/iq2000.c
--- orig/egcc-CVS20050814/gcc/config/iq2000/iq2000.c	2005-07-03 21:40:05.000000000 -0400
+++ egcc-CVS20050814/gcc/config/iq2000/iq2000.c	2005-08-14 11:54:40.000000000 -0400
@@ -1124,7 +1124,7 @@ function_arg_advance (CUMULATIVE_ARGS *c
 	       "function_adv({gp reg found = %d, arg # = %2d, words = %2d}, %4s, ",
 	       cum->gp_reg_found, cum->arg_number, cum->arg_words,
 	       GET_MODE_NAME (mode));
-      fprintf (stderr, HOST_PTR_PRINTF, (const PTR) type);
+      fprintf (stderr, "%p", (void *) type);
       fprintf (stderr, ", %d )\n\n", named);
     }
 
@@ -1197,7 +1197,7 @@ function_arg (CUMULATIVE_ARGS *cum, enum
 	       "function_arg( {gp reg found = %d, arg # = %2d, words = %2d}, %4s, ",
 	       cum->gp_reg_found, cum->arg_number, cum->arg_words,
 	       GET_MODE_NAME (mode));
-      fprintf (stderr, HOST_PTR_PRINTF, (const PTR) type);
+      fprintf (stderr, "%p", (void *) type);
       fprintf (stderr, ", %d ) = ", named);
     }
 
diff -rup orig/egcc-CVS20050814/gcc/configure.ac egcc-CVS20050814/gcc/configure.ac
--- orig/egcc-CVS20050814/gcc/configure.ac	2005-07-29 20:08:27.000000000 -0400
+++ egcc-CVS20050814/gcc/configure.ac	2005-08-14 11:57:52.000000000 -0400
@@ -1044,7 +1044,6 @@ else
 fi
 AC_SUBST(TARGET_GETGROUPS_T)
 
-gcc_AC_FUNC_PRINTF_PTR
 gcc_AC_FUNC_MMAP_BLACKLIST
 
 case "${host}" in
diff -rup orig/egcc-CVS20050814/gcc/cp/name-lookup.c egcc-CVS20050814/gcc/cp/name-lookup.c
--- orig/egcc-CVS20050814/gcc/cp/name-lookup.c	2005-08-11 21:12:05.000000000 -0400
+++ egcc-CVS20050814/gcc/cp/name-lookup.c	2005-08-14 11:52:38.000000000 -0400
@@ -1484,7 +1484,7 @@ print_binding_level (struct cp_binding_l
 {
   tree t;
   int i = 0, len;
-  fprintf (stderr, " blocks=" HOST_PTR_PRINTF, (void *) lvl->blocks);
+  fprintf (stderr, " blocks=%p", (void *) lvl->blocks);
   if (lvl->more_cleanups_ok)
     fprintf (stderr, " more-cleanups-ok");
   if (lvl->have_cleanups)
@@ -1549,7 +1549,7 @@ print_other_binding_stack (struct cp_bin
   struct cp_binding_level *level;
   for (level = stack; !global_scope_p (level); level = level->level_chain)
     {
-      fprintf (stderr, "binding level " HOST_PTR_PRINTF "\n", (void *) level);
+      fprintf (stderr, "binding level %p\n", (void *) level);
       print_binding_level (level);
     }
 }
@@ -1558,9 +1558,9 @@ void
 print_binding_stack (void)
 {
   struct cp_binding_level *b;
-  fprintf (stderr, "current_binding_level=" HOST_PTR_PRINTF
-	   "\nclass_binding_level=" HOST_PTR_PRINTF
-	   "\nNAMESPACE_LEVEL (global_namespace)=" HOST_PTR_PRINTF "\n",
+  fprintf (stderr, "current_binding_level=%p\n"
+	   "class_binding_level=%p\n"
+	   "NAMESPACE_LEVEL (global_namespace)=%p\n",
 	   (void *) current_binding_level, (void *) class_binding_level,
 	   (void *) NAMESPACE_LEVEL (global_namespace));
   if (class_binding_level)
diff -rup orig/egcc-CVS20050814/gcc/cp/ptree.c egcc-CVS20050814/gcc/cp/ptree.c
--- orig/egcc-CVS20050814/gcc/cp/ptree.c	2005-07-26 21:01:10.000000000 -0400
+++ egcc-CVS20050814/gcc/cp/ptree.c	2005-08-14 11:53:16.000000000 -0400
@@ -46,15 +46,15 @@ cxx_print_decl (FILE *file, tree node, i
   indent_to (file, indent + 3);
   if (TREE_CODE (node) == FUNCTION_DECL
       && DECL_PENDING_INLINE_INFO (node))
-    fprintf (file, " pending-inline-info " HOST_PTR_PRINTF,
+    fprintf (file, " pending-inline-info %p",
 	     (void *) DECL_PENDING_INLINE_INFO (node));
   if (TREE_CODE (node) == TYPE_DECL
       && DECL_SORTED_FIELDS (node))
-    fprintf (file, " sorted-fields " HOST_PTR_PRINTF,
+    fprintf (file, " sorted-fields %p",
 	     (void *) DECL_SORTED_FIELDS (node));
   if ((TREE_CODE (node) == FUNCTION_DECL || TREE_CODE (node) == VAR_DECL)
       && DECL_TEMPLATE_INFO (node))
-    fprintf (file, " template-info " HOST_PTR_PRINTF,
+    fprintf (file, " template-info %p",
 	     (void *) DECL_TEMPLATE_INFO (node));
 }
 
@@ -142,7 +142,7 @@ cxx_print_type (FILE *file, tree node, i
 static void
 cxx_print_binding (FILE *stream, cxx_binding *binding, const char *prefix)
 {
-  fprintf (stream, "%s <" HOST_PTR_PRINTF ">",
+  fprintf (stream, "%s <%p>",
 	   prefix, (void *) binding);
 }
 
diff -rup orig/egcc-CVS20050814/gcc/mips-tfile.c egcc-CVS20050814/gcc/mips-tfile.c
--- orig/egcc-CVS20050814/gcc/mips-tfile.c	2005-06-25 22:37:20.000000000 -0400
+++ egcc-CVS20050814/gcc/mips-tfile.c	2005-08-14 11:56:08.000000000 -0400
@@ -3980,8 +3980,7 @@ write_varray (varray_t *vp,    /* virtua
     return;
 
   if (debug)
-    fprintf (stderr, "\twarray\tvp = " HOST_PTR_PRINTF
-	     ", offset = %7lu, size = %7lu, %s\n",
+    fprintf (stderr, "\twarray\tvp = %p, offset = %7lu, size = %7lu, %s\n",
 	     (void *) vp, (unsigned long) offset,
 	     vp->num_allocated * vp->object_size, str);
 
@@ -4020,8 +4019,7 @@ write_object (void)
   off_t offset;
 
   if (debug)
-    fprintf (stderr, "\n\twrite\tvp = " HOST_PTR_PRINTF
-	     ", offset = %7u, size = %7lu, %s\n",
+    fprintf (stderr, "\n\twrite\tvp = %p, offset = %7u, size = %7lu, %s\n",
 	     (void *) &symbolic_header, 0,
 	     (unsigned long) sizeof (symbolic_header), "symbolic header");
 
@@ -4051,8 +4049,7 @@ write_object (void)
 	pfatal_with_name (object_name);
 
       if (debug)
-	fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
-		 ", offset = %7lu, size = %7lu, %s\n",
+	fprintf (stderr, "\twrite\tvp = %p, offset = %7lu, size = %7lu, %s\n",
 		 (void *) &orig_linenum, (long) symbolic_header.cbLineOffset,
 		 (long) symbolic_header.cbLine, "Line numbers");
 
@@ -4083,8 +4080,7 @@ write_object (void)
 	pfatal_with_name (object_name);
 
       if (debug)
-	fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
-		 ", offset = %7lu, size = %7lu, %s\n",
+	fprintf (stderr, "\twrite\tvp = %p, offset = %7lu, size = %7lu, %s\n",
 		 (void *) &orig_opt_syms, (long) symbolic_header.cbOptOffset,
 		 num_write, "Optimizer symbols");
 
@@ -4172,8 +4168,7 @@ write_object (void)
 	   file_ptr = file_ptr->next_file)
 	{
 	  if (debug)
-	    fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
-		     ", offset = %7lu, size = %7lu, %s\n",
+	    fprintf (stderr, "\twrite\tvp = %p, offset = %7lu, size = %7lu, %s\n",
 		     (void *) &file_ptr->fdr, file_offset,
 		     (unsigned long) sizeof (FDR), "File header");
 
@@ -4205,8 +4200,7 @@ write_object (void)
 	pfatal_with_name (object_name);
 
       if (debug)
-	fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
-		 ", offset = %7lu, size = %7lu, %s\n",
+	fprintf (stderr, "\twrite\tvp = %p, offset = %7lu, size = %7lu, %s\n",
 		 (void *) &orig_rfds, (long) symbolic_header.cbRfdOffset,
 		 num_write, "Relative file descriptors");
 
@@ -4999,7 +4993,7 @@ allocate_cluster (Size_t npages)
     pfatal_with_name ("allocate_cluster");
 
   if (debug > 3)
-    fprintf (stderr, "\talloc\tnpages = %lu, value = " HOST_PTR_PRINTF "\n",
+    fprintf (stderr, "\talloc\tnpages = %lu, value = %p\n",
 	     (unsigned long) npages, (void *) ptr);
 
   return ptr;
diff -rup orig/egcc-CVS20050814/gcc/print-rtl.c egcc-CVS20050814/gcc/print-rtl.c
--- orig/egcc-CVS20050814/gcc/print-rtl.c	2005-06-25 22:37:21.000000000 -0400
+++ egcc-CVS20050814/gcc/print-rtl.c	2005-08-14 11:50:22.000000000 -0400
@@ -287,7 +287,7 @@ print_rtx (rtx in_rtx)
 		if (flag_dump_unnumbered)
 		  fprintf (outfile, "#");
 		else
-		  fprintf (outfile, HOST_PTR_PRINTF,
+		  fprintf (outfile, "%p",
 			   (char *) NOTE_BLOCK (in_rtx));
 		sawclose = 1;
 		break;
@@ -539,7 +539,7 @@ print_rtx (rtx in_rtx)
 	break;
 
       case 't':
-	fprintf (outfile, " " HOST_PTR_PRINTF, (void *) XTREE (in_rtx, i));
+	fprintf (outfile, " %p", (void *) XTREE (in_rtx, i));
 	break;
 
       case '*':
diff -rup orig/egcc-CVS20050814/gcc/print-tree.c egcc-CVS20050814/gcc/print-tree.c
--- orig/egcc-CVS20050814/gcc/print-tree.c	2005-07-11 20:42:39.000000000 -0400
+++ egcc-CVS20050814/gcc/print-tree.c	2005-08-14 11:51:11.000000000 -0400
@@ -73,7 +73,7 @@ print_node_brief (FILE *file, const char
      name if any.  */
   if (indent > 0)
     fprintf (file, " ");
-  fprintf (file, "%s <%s " HOST_PTR_PRINTF,
+  fprintf (file, "%s <%s %p",
 	   prefix, tree_code_name[(int) TREE_CODE (node)], (char *) node);
 
   if (class == tcc_declaration)
@@ -218,7 +218,7 @@ print_node (FILE *file, const char *pref
   indent_to (file, indent);
 
   /* Print the slot this node is in, and its code, and address.  */
-  fprintf (file, "%s <%s " HOST_PTR_PRINTF,
+  fprintf (file, "%s <%s %p",
 	   prefix, tree_code_name[(int) TREE_CODE (node)], (void *) node);
 
   /* Print the name, if any.  */
@@ -495,7 +495,7 @@ print_node (FILE *file, const char *pref
 	       && DECL_STRUCT_FUNCTION (node) != 0)
 	{
 	  indent_to (file, indent + 4);
-	  fprintf (file, "saved-insns " HOST_PTR_PRINTF,
+	  fprintf (file, "saved-insns %p",
 		   (void *) DECL_STRUCT_FUNCTION (node));
 	}
 
@@ -755,7 +755,7 @@ print_node (FILE *file, const char *pref
 	  break;
 
     	case STATEMENT_LIST:
-	  fprintf (file, " head " HOST_PTR_PRINTF " tail " HOST_PTR_PRINTF " stmts",
+	  fprintf (file, " head %p tail %p stmts",
 		   (void *) node->stmt_list.head, (void *) node->stmt_list.tail);
 	  {
 	    tree_stmt_iterator i;
@@ -763,7 +763,7 @@ print_node (FILE *file, const char *pref
 	      {
 		/* Not printing the addresses of the (not-a-tree)
 		   'struct tree_stmt_list_node's.  */
-		fprintf (file, " " HOST_PTR_PRINTF, (void *)tsi_stmt (i));
+		fprintf (file, " %p", (void *)tsi_stmt (i));
 	      }
 	    fprintf (file, "\n");
 	    for (i = tsi_start (node); !tsi_end_p (i); tsi_next (&i))
diff -rup orig/egcc-CVS20050814/gcc/system.h egcc-CVS20050814/gcc/system.h
--- orig/egcc-CVS20050814/gcc/system.h	2005-07-20 21:57:08.000000000 -0400
+++ egcc-CVS20050814/gcc/system.h	2005-08-14 11:57:16.000000000 -0400
@@ -511,19 +511,6 @@ extern int vsnprintf(char *, size_t, con
 # define mkdir(a,b) mkdir(a)
 #endif
 
-/* Provide a way to print an address via printf.  */
-#ifndef HOST_PTR_PRINTF
-# ifdef HAVE_PRINTF_PTR
-#  define HOST_PTR_PRINTF "%p"
-# elif SIZEOF_INT == SIZEOF_VOID_P
-#  define HOST_PTR_PRINTF "%x"
-# elif SIZEOF_LONG == SIZEOF_VOID_P
-#  define HOST_PTR_PRINTF "%lx"
-# else
-#  define HOST_PTR_PRINTF "%llx"
-# endif
-#endif /* ! HOST_PTR_PRINTF */
-
 /* By default, colon separates directories in a path.  */
 #ifndef PATH_SEPARATOR
 #define PATH_SEPARATOR ':'
@@ -741,7 +728,7 @@ extern void fancy_abort (const char *, i
         TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT	   \
         LINK_LIBGCC_SPECIAL DONT_ACCESS_GBLS_AFTER_EPILOGUE		   \
 	TARGET_OPTIONS TARGET_SWITCHES EXTRA_CC_MODES FINALIZE_PIC	   \
-	PREDICATE_CODES SPECIAL_MODE_PREDICATES
+	PREDICATE_CODES SPECIAL_MODE_PREDICATES HOST_PTR_PRINTF
 
 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]