Patch for more removal of old string functions

Joseph S. Myers jsm28@cam.ac.uk
Wed Nov 8 14:42:00 GMT 2000


This patch gets rid of more uses of pre-ISO string functions: it
removes the remaining uses of bzero/bcmp/index/rindex along with their
configure/system.h support, and converts a few more uses of bcopy to
memcpy.  (gcc/fixinc/gnu-regex.c does its own stuff regarding these
functions; the support in gcc/configure is irrelevant to it.)

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

gcc/ChangeLog:
2000-11-08  Joseph S. Myers  <jsm28@cam.ac.uk>

	* calls.c (expand_call, emit_library_call_value_1), collect2.c
	(scan_prog_file), config/a29k/a29k.c (print_operand),
	config/sparc/sparc.c (order_regs_for_local_alloc): Use memcpy ()
	instead of bcopy ().
	* real.h: Use memcmp () instead of bcmp ().
	* config/m88k/m88k.c (m88k_layout_frame), config/sh/sh.c
	(split_branches), config/sparc/sparc.c (ultra_flush_pipeline,
	ultrasparc_sched_init, ultrasparc_sched_reorder),
	config/sparc/sparc.h (CONDITIONAL_REGISTER_USAGE): Use memset ()
	instead of bzero ().
	* config/vax/xm-xms.h (FILE_NAME_NONDIRECTORY): Use strrchr ()
	instead of rindex ().
	* configure.in: Don't check for bzero, bcmp, index or rindex.
	* configure, config.in: Regenerate.
	* system.h: Don't include declarations for bzero, bcmp, index or
	rindex.
	* config/i386/xm-beos.h, config/rs6000/xm-beos.h: Don't define
	bzero, bcmp, index or rindex.

gcc/java/ChangeLog:
2000-11-08  Joseph S. Myers  <jsm28@cam.ac.uk>

	* parse.y (create_new_parser_context): Use memset () instead of
	bzero ().

--- calls.c.orig	Tue Nov  7 22:40:50 2000
+++ calls.c	Wed Nov  8 12:58:46 2000
@@ -2782,8 +2782,8 @@ expand_call (exp, target, ignore)
 		    = (char *) alloca (highest_outgoing_arg_in_use);

 		  if (initial_highest_arg_in_use)
-		    bcopy (initial_stack_usage_map, stack_usage_map,
-			   initial_highest_arg_in_use);
+		    memcpy (stack_usage_map, initial_stack_usage_map,
+			    initial_highest_arg_in_use);

 		  if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
 		    memset (&stack_usage_map[initial_highest_arg_in_use], 0,
@@ -3766,8 +3766,8 @@ emit_library_call_value_1 (retval, orgfu
       stack_usage_map = (char *) alloca (highest_outgoing_arg_in_use);

       if (initial_highest_arg_in_use)
-	bcopy (initial_stack_usage_map, stack_usage_map,
-	       initial_highest_arg_in_use);
+	memcpy (stack_usage_map, initial_stack_usage_map,
+		initial_highest_arg_in_use);

       if (initial_highest_arg_in_use != highest_outgoing_arg_in_use)
 	memset (&stack_usage_map[initial_highest_arg_in_use], 0,
--- collect2.c.orig	Thu Nov  2 18:59:32 2000
+++ collect2.c	Wed Nov  8 13:03:11 2000
@@ -3057,7 +3057,7 @@ scan_prog_file (prog_name, which_pass)
       if (rw)
 	{
 	  load_union_t *ptr = (load_union_t *) xmalloc (load_hdr->hdr.ldci_cmd_size);
-	  bcopy ((char *)load_hdr, (char *)ptr, load_hdr->hdr.ldci_cmd_size);
+	  memcpy ((char *)ptr, (char *)load_hdr, load_hdr->hdr.ldci_cmd_size);
 	  load_hdr = ptr;

 	  /* null out old command map, because we will rewrite at the end.  */
--- configure.in.orig	Tue Nov  7 22:36:57 2000
+++ configure.in	Wed Nov  8 16:48:28 2000
@@ -510,8 +510,8 @@ if test $gcc_cv_enum_bf_unsigned = yes;
     [Define if enumerated bitfields are treated as unsigned values.])
 fi

-AC_CHECK_FUNCS(strtoul bsearch putenv popen bcopy bzero bcmp \
-	index rindex strchr strrchr kill getrlimit setrlimit atoll atoq \
+AC_CHECK_FUNCS(strtoul bsearch putenv popen bcopy \
+	strchr strrchr kill getrlimit setrlimit atoll atoq \
 	sysconf isascii gettimeofday strsignal putc_unlocked fputc_unlocked \
 	fputs_unlocked getrusage valloc iconv nl_langinfo)

@@ -555,8 +555,8 @@ AC_FUNC_MMAP_FILE
 # We will need to find libiberty.h and ansidecl.h
 saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
-gcc_AC_CHECK_DECLS(bcopy bzero bcmp \
-	index rindex getenv atol sbrk abort atof getcwd getwd \
+gcc_AC_CHECK_DECLS(bcopy \
+	getenv atol sbrk abort atof getcwd getwd \
 	strsignal putc_unlocked fputs_unlocked strstr environ \
 	malloc realloc calloc free basename getopt, , ,[
 #include "gansidecl.h"
--- real.h.orig	Tue Aug 15 12:06:58 2000
+++ real.h	Wed Nov  8 12:17:39 2000
@@ -327,7 +327,7 @@ do {									\
    -0.0 equals 0.0 but they are not identical, and conversely
    two NaNs might be identical but they cannot be equal.  */
 #define REAL_VALUES_IDENTICAL(x, y) \
-  (!bcmp ((char *) &(x), (char *) &(y), sizeof (REAL_VALUE_TYPE)))
+  (!memcmp ((char *) &(x), (char *) &(y), sizeof (REAL_VALUE_TYPE)))

 /* Compare two floating-point values for equality.  */
 #ifndef REAL_VALUES_EQUAL
--- system.h.orig	Fri Oct 20 19:43:28 2000
+++ system.h	Wed Nov  8 16:47:05 2000
@@ -336,46 +336,6 @@ extern void bcopy PARAMS ((const PTR, PT
 # endif
 #endif

-#ifndef bcmp
-# ifdef HAVE_BCMP
-#  if defined (HAVE_DECL_BCMP) && !HAVE_DECL_BCMP
-extern int bcmp PARAMS ((const PTR, const PTR, size_t));
-#  endif
-# else /* ! HAVE_BCMP */
-#  define bcmp(left,right,len) memcmp ((left),(right),(len))
-# endif
-#endif
-
-#ifndef bzero
-# ifdef HAVE_BZERO
-#  if defined (HAVE_DECL_BZERO) && !HAVE_DECL_BZERO
-extern void bzero PARAMS ((PTR, size_t));
-#  endif
-# else /* ! HAVE_BZERO */
-#  define bzero(dst,len) memset ((dst),0,(len))
-# endif
-#endif
-
-#ifndef index
-# ifdef HAVE_INDEX
-#  if defined (HAVE_DECL_INDEX) && !HAVE_DECL_INDEX
-extern char *index PARAMS ((const char *, int));
-#  endif
-# else /* ! HAVE_INDEX */
-#  define index strchr
-# endif
-#endif
-
-#ifndef rindex
-# ifdef HAVE_RINDEX
-#  if defined (HAVE_DECL_RINDEX) && !HAVE_DECL_RINDEX
-extern char *rindex PARAMS ((const char *, int));
-#  endif
-# else /* ! HAVE_RINDEX */
-#  define rindex strrchr
-# endif
-#endif
-
 #if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF
 extern double atof PARAMS ((const char *));
 #endif
--- config/a29k/a29k.c.orig	Sat Feb 26 20:41:07 2000
+++ config/a29k/a29k.c	Wed Nov  8 12:53:53 2000
@@ -1122,7 +1122,7 @@ print_operand (file, x, code)
 	{
 	  union real_extract u;

-	  bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u);
+	  memcpy ((char *) &u, (char *) &CONST_DOUBLE_LOW (x), sizeof u);
 	  fprintf (file, "$double1(%.20e)", u.d);
 	}
       else if (GET_CODE (x) == REG)
@@ -1186,8 +1186,8 @@ print_operand (file, x, code)
 	fprintf (file, "$float");
       else
 	fprintf (file, "$double%d", SUBREG_WORD (XEXP (x, 0)));
-      bcopy ((char *) &CONST_DOUBLE_LOW (SUBREG_REG (XEXP (x, 0))),
-	     (char *) &u, sizeof u);
+      memcpy ((char *) &u,
+	      (char *) &CONST_DOUBLE_LOW (SUBREG_REG (XEXP (x, 0))), sizeof u);
       fprintf (file, "(%.20e)", u.d);
     }

@@ -1196,7 +1196,7 @@ print_operand (file, x, code)
     {
       union real_extract u;

-      bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u);
+      memcpy ((char *) &u, (char *) &CONST_DOUBLE_LOW (x), sizeof u);
       fprintf (file, "$%s(%.20e)",
 	       GET_MODE (x) == SFmode ? "float" : "double0", u.d);
     }
--- config/i386/xm-beos.h.orig	Sat Feb 26 21:44:42 2000
+++ config/i386/xm-beos.h	Wed Nov  8 16:46:02 2000
@@ -38,14 +38,6 @@ Boston, MA 02111-1307, USA.  */

 #undef bcopy
 #define bcopy(s,d,n)	memmove((d),(s),(n))
-#undef bzero
-#define bzero(d,n)	memset((d),0,(n))
-#undef bcmp
-#define bcmp(l,r,n)	memcmp((l),(r),(n))
-#undef index
-#define index		strchr
-#undef rindex
-#define rindex		strrchr

 /* BeOS is closer to USG than BSD */

--- config/m88k/m88k.c.orig	Mon Sep 25 14:17:57 2000
+++ config/m88k/m88k.c	Wed Nov  8 12:44:14 2000
@@ -1786,7 +1786,7 @@ m88k_layout_frame ()

   frame_laid_out++;

-  bzero ((char *) &save_regs[0], sizeof (save_regs));
+  memset ((char *) &save_regs[0], 0, sizeof (save_regs));
   sp_size = nregs = nxregs = 0;
   frame_size = get_frame_size ();

--- config/rs6000/xm-beos.h.orig	Wed Sep 15 21:41:16 1999
+++ config/rs6000/xm-beos.h	Wed Nov  8 16:46:22 2000
@@ -57,14 +57,6 @@ extern void *alloca ();

 #undef bcopy
 #define bcopy(s,d,n)	memmove((d),(s),(n))
-#undef bzero
-#define bzero(d,n)	memset((d),0,(n))
-#undef bcmp
-#define bcmp(l,r,n)	memcmp((l),(r),(n))
-#undef index
-#define index		strchr
-#undef rindex
-#define rindex		strrchr

 /* BeOS is closer to USG than BSD */

--- config/sh/sh.c.orig	Tue Oct 31 16:41:17 2000
+++ config/sh/sh.c	Wed Nov  8 12:46:47 2000
@@ -3381,7 +3381,7 @@ split_branches (first)
   shorten_branches (first);

   uid_branch = (struct far_branch **) alloca (max_uid * sizeof *uid_branch);
-  bzero ((char *) uid_branch, max_uid * sizeof *uid_branch);
+  memset ((char *) uid_branch, 0, max_uid * sizeof *uid_branch);

   for (insn = first; insn; insn = NEXT_INSN (insn))
     if (! INSN_P (insn))
--- config/sparc/sparc.c.orig	Sat Oct 21 00:53:18 2000
+++ config/sparc/sparc.c	Wed Nov  8 12:52:14 2000
@@ -5440,8 +5440,9 @@ order_regs_for_local_alloc ()
   if (regs_ever_live[15] != last_order_nonleaf)
     {
       last_order_nonleaf = !last_order_nonleaf;
-      bcopy ((char *) reg_alloc_orders[last_order_nonleaf],
-	     (char *) reg_alloc_order, FIRST_PSEUDO_REGISTER * sizeof (int));
+      memcpy ((char *) reg_alloc_order,
+	      (char *) reg_alloc_orders[last_order_nonleaf],
+	      FIRST_PSEUDO_REGISTER * sizeof (int));
     }
 }

@@ -7553,7 +7554,7 @@ ultra_flush_pipeline ()
 {
   ultra_cur_hist = (ultra_cur_hist + 1) & (ULTRA_NUM_HIST - 1);
   ultra_cycles_elapsed += 1;
-  bzero ((char *) &ultra_pipe, sizeof ultra_pipe);
+  memset ((char *) &ultra_pipe, 0, sizeof ultra_pipe);
   ultra_pipe.free_slot_mask = 0xf;
 }

@@ -7563,7 +7564,7 @@ ultrasparc_sched_init (dump, sched_verbo
      FILE *dump ATTRIBUTE_UNUSED;
      int sched_verbose ATTRIBUTE_UNUSED;
 {
-  bzero ((char *) ultra_pipe_hist, sizeof ultra_pipe_hist);
+  memset ((char *) ultra_pipe_hist, 0, sizeof ultra_pipe_hist);
   ultra_cur_hist = 0;
   ultra_cycles_elapsed = 0;
   ultra_pipe.free_slot_mask = 0xf;
@@ -7899,7 +7900,7 @@ ultrasparc_sched_reorder (dump, sched_ve
       }
     else
       {
-	bzero ((char *) &ultra_pipe, sizeof ultra_pipe);
+	memset ((char *) &ultra_pipe, 0, sizeof ultra_pipe);
 	ultra_pipe.free_slot_mask = 0xf;
       }
   }
--- config/sparc/sparc.h.orig	Mon Nov  6 14:22:22 2000
+++ config/sparc/sparc.h	Wed Nov  8 12:47:02 2000
@@ -1118,7 +1118,7 @@ do								\
 	fixed_regs[31] = 1;					\
 	reg_names[FRAME_POINTER_REGNUM] = "%i7";		\
 	/* Disable leaf functions */				\
-	bzero (sparc_leaf_regs, FIRST_PSEUDO_REGISTER);		\
+	memset (sparc_leaf_regs, 0, FIRST_PSEUDO_REGISTER);	\
       }								\
     if (profile_block_flag)					\
       {								\
--- config/vax/xm-vms.h.orig	Sat Mar  4 05:36:14 2000
+++ config/vax/xm-vms.h	Wed Nov  8 12:18:06 2000
@@ -98,9 +98,9 @@ Boston, MA 02111-1307, USA.  */
    pnt1_ = pnt_ - 1;						\
    while (*++pnt1_)						\
      if ((*pnt1_ >= 'A' && *pnt1_ <= 'Z')) *pnt1_ |= 0x20;	\
-   pnt1_ = rindex (pnt_, ']'); 					\
-   pnt1_ = (pnt1_ == 0 ? rindex (pnt_, '>') : pnt1_);		\
-   pnt1_ = (pnt1_ == 0 ? rindex (pnt_, ':') : pnt1_);		\
+   pnt1_ = strrchr (pnt_, ']'); 				\
+   pnt1_ = (pnt1_ == 0 ? strrchr (pnt_, '>') : pnt1_);		\
+   pnt1_ = (pnt1_ == 0 ? strrchr (pnt_, ':') : pnt1_);		\
    (pnt1_ == 0 ? pnt_ : pnt1_ + 1);				\
  })

--- java/parse.y.orig	Mon Oct 30 07:41:49 2000
+++ java/parse.y	Wed Nov  8 12:41:24 2000
@@ -2615,7 +2615,7 @@ create_new_parser_context (copy_from_pre
       new->saved_data_ctx = 1;
     }
   else
-    bzero ((PTR) new, sizeof (struct parser_ctxt));
+    memset ((PTR) new, 0, sizeof (struct parser_ctxt));

   new->next = ctxp;
   ctxp = new;

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list