Commit da61dec9 by Joseph Myers Committed by Joseph Myers

Use memset/memcmp instead of bzero/bcmp.

	* c-decl.c (duplicate_decls, copy_lang_decl), dwarfout.c
	(dwarfout_line), gcc.c (main, save_string), tree.c (init_obstacks,
	perm_calloc, get_identifier, maybe_get_identifier,
	real_value_from_int_cst, simple_cst_equal), varasm.c
	(assemble_name, assemble_real, immed_real_const_1,
	compare_constant_1, decode_rtx_const, output_constant_pool): Use
	strrchr () instead of rindex ().  Use memcmp () instead of bcmp
	().  Use memcpy () instead of bcopy ().  Use memset () instead of
	bzero ().

cp:
	* tree.c (cp_tree_equal): Use memcmp () instead of bcmp ().

From-SVN: r37228
parent def3263a
2000-11-03 Joseph S. Myers <jsm28@cam.ac.uk>
* c-decl.c (duplicate_decls, copy_lang_decl), dwarfout.c
(dwarfout_line), gcc.c (main, save_string), tree.c (init_obstacks,
perm_calloc, get_identifier, maybe_get_identifier,
real_value_from_int_cst, simple_cst_equal), varasm.c
(assemble_name, assemble_real, immed_real_const_1,
compare_constant_1, decode_rtx_const, output_constant_pool): Use
strrchr () instead of rindex (). Use memcmp () instead of bcmp
(). Use memcpy () instead of bcopy (). Use memset () instead of
bzero ().
2000-11-03 Nathan Sidwell <nathan@codesourcery.com> 2000-11-03 Nathan Sidwell <nathan@codesourcery.com>
* cppfiles.c (open_file): If already read, then don't reopen. * cppfiles.c (open_file): If already read, then don't reopen.
......
...@@ -2054,9 +2054,9 @@ duplicate_decls (newdecl, olddecl, different_binding_level) ...@@ -2054,9 +2054,9 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
{ {
register unsigned olddecl_uid = DECL_UID (olddecl); register unsigned olddecl_uid = DECL_UID (olddecl);
bcopy ((char *) newdecl + sizeof (struct tree_common), memcpy ((char *) olddecl + sizeof (struct tree_common),
(char *) olddecl + sizeof (struct tree_common), (char *) newdecl + sizeof (struct tree_common),
sizeof (struct tree_decl) - sizeof (struct tree_common)); sizeof (struct tree_decl) - sizeof (struct tree_common));
DECL_UID (olddecl) = olddecl_uid; DECL_UID (olddecl) = olddecl_uid;
} }
...@@ -7006,8 +7006,8 @@ copy_lang_decl (decl) ...@@ -7006,8 +7006,8 @@ copy_lang_decl (decl)
return; return;
ld = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl)); ld = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl));
bcopy ((char *)DECL_LANG_SPECIFIC (decl), (char *)ld, memcpy ((char *) ld, (char *) DECL_LANG_SPECIFIC (decl),
sizeof (struct lang_decl)); sizeof (struct lang_decl));
DECL_LANG_SPECIFIC (decl) = ld; DECL_LANG_SPECIFIC (decl) = ld;
} }
......
2000-11-03 Joseph S. Myers <jsm28@cam.ac.uk>
* tree.c (cp_tree_equal): Use memcmp () instead of bcmp ().
2000-11-02 Joseph S. Myers <jsm28@cam.ac.uk> 2000-11-02 Joseph S. Myers <jsm28@cam.ac.uk>
* dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c * dump.c (dequeue_and_dump), lex.c (interface_strcmp), method.c
......
...@@ -1984,7 +1984,7 @@ cp_tree_equal (t1, t2) ...@@ -1984,7 +1984,7 @@ cp_tree_equal (t1, t2)
case STRING_CST: case STRING_CST:
return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2) return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
&& !bcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2), && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
TREE_STRING_LENGTH (t1)); TREE_STRING_LENGTH (t1));
case CONSTRUCTOR: case CONSTRUCTOR:
......
...@@ -5535,7 +5535,7 @@ dwarfout_line (filename, line) ...@@ -5535,7 +5535,7 @@ dwarfout_line (filename, line)
} }
{ {
register const char *tail = rindex (filename, '/'); register const char *tail = strrchr (filename, '/');
if (tail != NULL) if (tail != NULL)
filename = tail; filename = tail;
......
...@@ -5319,8 +5319,8 @@ main (argc, argv) ...@@ -5319,8 +5319,8 @@ main (argc, argv)
This means one element containing 0s, as a terminator. */ This means one element containing 0s, as a terminator. */
compilers = (struct compiler *) xmalloc (sizeof default_compilers); compilers = (struct compiler *) xmalloc (sizeof default_compilers);
bcopy ((char *) default_compilers, (char *) compilers, memcpy ((char *) compilers, (char *) default_compilers,
sizeof default_compilers); sizeof default_compilers);
n_compilers = n_default_compilers; n_compilers = n_default_compilers;
/* Read specs from a file if there is one. */ /* Read specs from a file if there is one. */
...@@ -5737,7 +5737,7 @@ save_string (s, len) ...@@ -5737,7 +5737,7 @@ save_string (s, len)
{ {
register char *result = xmalloc (len + 1); register char *result = xmalloc (len + 1);
bcopy (s, result, len); memcpy (result, s, len);
result[len] = 0; result[len] = 0;
return result; return result;
} }
......
...@@ -205,7 +205,7 @@ init_obstacks () ...@@ -205,7 +205,7 @@ init_obstacks ()
gcc_obstack_init (&permanent_obstack); gcc_obstack_init (&permanent_obstack);
/* Init the hash table of identifiers. */ /* Init the hash table of identifiers. */
bzero ((char *) hash_table, sizeof hash_table); memset ((char *) hash_table, 0, sizeof hash_table);
ggc_add_tree_root (hash_table, sizeof hash_table / sizeof (tree)); ggc_add_tree_root (hash_table, sizeof hash_table / sizeof (tree));
/* Initialize the hash table of types. */ /* Initialize the hash table of types. */
...@@ -257,7 +257,7 @@ perm_calloc (nelem, size) ...@@ -257,7 +257,7 @@ perm_calloc (nelem, size)
long size; long size;
{ {
char *rval = (char *) obstack_alloc (&permanent_obstack, nelem * size); char *rval = (char *) obstack_alloc (&permanent_obstack, nelem * size);
bzero (rval, nelem * size); memset (rval, 0, nelem * size);
return rval; return rval;
} }
...@@ -591,7 +591,7 @@ get_identifier (text) ...@@ -591,7 +591,7 @@ get_identifier (text)
for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp)) for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp))
if (IDENTIFIER_LENGTH (idp) == len if (IDENTIFIER_LENGTH (idp) == len
&& IDENTIFIER_POINTER (idp)[0] == text[0] && IDENTIFIER_POINTER (idp)[0] == text[0]
&& !bcmp (IDENTIFIER_POINTER (idp), text, len)) && !memcmp (IDENTIFIER_POINTER (idp), text, len))
/* Return if found. */ /* Return if found. */
return idp; return idp;
...@@ -655,7 +655,7 @@ maybe_get_identifier (text) ...@@ -655,7 +655,7 @@ maybe_get_identifier (text)
for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp)) for (idp = hash_table[hi]; idp; idp = TREE_CHAIN (idp))
if (IDENTIFIER_LENGTH (idp) == len if (IDENTIFIER_LENGTH (idp) == len
&& IDENTIFIER_POINTER (idp)[0] == text[0] && IDENTIFIER_POINTER (idp)[0] == text[0]
&& !bcmp (IDENTIFIER_POINTER (idp), text, len)) && !memcmp (IDENTIFIER_POINTER (idp), text, len))
return idp; /* <-- return if found */ return idp; /* <-- return if found */
return NULL_TREE; return NULL_TREE;
...@@ -739,7 +739,7 @@ real_value_from_int_cst (type, i) ...@@ -739,7 +739,7 @@ real_value_from_int_cst (type, i)
#ifdef REAL_ARITHMETIC #ifdef REAL_ARITHMETIC
/* Clear all bits of the real value type so that we can later do /* Clear all bits of the real value type so that we can later do
bitwise comparisons to see if two values are the same. */ bitwise comparisons to see if two values are the same. */
bzero ((char *) &d, sizeof d); memset ((char *) &d, 0, sizeof d);
if (! TREE_UNSIGNED (TREE_TYPE (i))) if (! TREE_UNSIGNED (TREE_TYPE (i)))
REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i), REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i),
...@@ -3625,7 +3625,7 @@ simple_cst_equal (t1, t2) ...@@ -3625,7 +3625,7 @@ simple_cst_equal (t1, t2)
case STRING_CST: case STRING_CST:
return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2) return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
&& ! bcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2), && ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
TREE_STRING_LENGTH (t1))); TREE_STRING_LENGTH (t1)));
case CONSTRUCTOR: case CONSTRUCTOR:
......
...@@ -1772,7 +1772,7 @@ assemble_name (file, name) ...@@ -1772,7 +1772,7 @@ assemble_name (file, name)
STRIP_NAME_ENCODING (real_name, name); STRIP_NAME_ENCODING (real_name, name);
if (flag_prefix_function_name if (flag_prefix_function_name
&& ! bcmp (real_name, CHKR_PREFIX, CHKR_PREFIX_SIZE)) && ! memcmp (real_name, CHKR_PREFIX, CHKR_PREFIX_SIZE))
real_name = real_name + CHKR_PREFIX_SIZE; real_name = real_name + CHKR_PREFIX_SIZE;
id = maybe_get_identifier (real_name); id = maybe_get_identifier (real_name);
...@@ -1972,7 +1972,7 @@ assemble_real (d, mode) ...@@ -1972,7 +1972,7 @@ assemble_real (d, mode)
{ {
error ("floating point trap outputting a constant"); error ("floating point trap outputting a constant");
#ifdef REAL_IS_NOT_DOUBLE #ifdef REAL_IS_NOT_DOUBLE
bzero ((char *) &d, sizeof d); memset ((char *) &d, 0, sizeof d);
d = dconst0; d = dconst0;
#else #else
d = 0; d = 0;
...@@ -2164,7 +2164,7 @@ immed_real_const_1 (d, mode) ...@@ -2164,7 +2164,7 @@ immed_real_const_1 (d, mode)
If one is found, return it. */ If one is found, return it. */
if (cfun != 0) if (cfun != 0)
for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r)) for (r = const_double_chain; r; r = CONST_DOUBLE_CHAIN (r))
if (! bcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u) if (! memcmp ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u)
&& GET_MODE (r) == mode) && GET_MODE (r) == mode)
return r; return r;
...@@ -2176,7 +2176,7 @@ immed_real_const_1 (d, mode) ...@@ -2176,7 +2176,7 @@ immed_real_const_1 (d, mode)
freed memory. */ freed memory. */
r = rtx_alloc (CONST_DOUBLE); r = rtx_alloc (CONST_DOUBLE);
PUT_MODE (r, mode); PUT_MODE (r, mode);
bcopy ((char *) &u, (char *) &CONST_DOUBLE_LOW (r), sizeof u); memcpy ((char *) &CONST_DOUBLE_LOW (r), (char *) &u, sizeof u);
/* If we aren't inside a function, don't put r on the /* If we aren't inside a function, don't put r on the
const_double_chain. */ const_double_chain. */
...@@ -2533,7 +2533,7 @@ compare_constant_1 (exp, p) ...@@ -2533,7 +2533,7 @@ compare_constant_1 (exp, p)
strp = (unsigned char *)TREE_STRING_POINTER (exp); strp = (unsigned char *)TREE_STRING_POINTER (exp);
len = TREE_STRING_LENGTH (exp); len = TREE_STRING_LENGTH (exp);
if (bcmp ((char *) &TREE_STRING_LENGTH (exp), p, if (memcmp ((char *) &TREE_STRING_LENGTH (exp), p,
sizeof TREE_STRING_LENGTH (exp))) sizeof TREE_STRING_LENGTH (exp)))
return 0; return 0;
...@@ -2555,7 +2555,7 @@ compare_constant_1 (exp, p) ...@@ -2555,7 +2555,7 @@ compare_constant_1 (exp, p)
get_set_constructor_bytes (exp, tmp, len); get_set_constructor_bytes (exp, tmp, len);
strp = (unsigned char *) tmp; strp = (unsigned char *) tmp;
if (bcmp ((char *) &xlen, p, sizeof xlen)) if (memcmp ((char *) &xlen, p, sizeof xlen))
return 0; return 0;
p += sizeof xlen; p += sizeof xlen;
...@@ -2573,7 +2573,7 @@ compare_constant_1 (exp, p) ...@@ -2573,7 +2573,7 @@ compare_constant_1 (exp, p)
if (TREE_PURPOSE (link)) if (TREE_PURPOSE (link))
have_purpose = 1; have_purpose = 1;
if (bcmp ((char *) &length, p, sizeof length)) if (memcmp ((char *) &length, p, sizeof length))
return 0; return 0;
p += sizeof length; p += sizeof length;
...@@ -2587,12 +2587,12 @@ compare_constant_1 (exp, p) ...@@ -2587,12 +2587,12 @@ compare_constant_1 (exp, p)
else else
type = 0; type = 0;
if (bcmp ((char *) &type, p, sizeof type)) if (memcmp ((char *) &type, p, sizeof type))
return 0; return 0;
if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE) if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
{ {
if (bcmp ((char *) &mode, p, sizeof mode)) if (memcmp ((char *) &mode, p, sizeof mode))
return 0; return 0;
p += sizeof mode; p += sizeof mode;
...@@ -2600,7 +2600,7 @@ compare_constant_1 (exp, p) ...@@ -2600,7 +2600,7 @@ compare_constant_1 (exp, p)
p += sizeof type; p += sizeof type;
if (bcmp ((char *) &have_purpose, p, sizeof have_purpose)) if (memcmp ((char *) &have_purpose, p, sizeof have_purpose))
return 0; return 0;
p += sizeof have_purpose; p += sizeof have_purpose;
...@@ -2610,7 +2610,7 @@ compare_constant_1 (exp, p) ...@@ -2610,7 +2610,7 @@ compare_constant_1 (exp, p)
{ {
HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp));
if (bcmp ((char *) &size, p, sizeof size)) if (memcmp ((char *) &size, p, sizeof size))
return 0; return 0;
p += sizeof size; p += sizeof size;
...@@ -2627,7 +2627,7 @@ compare_constant_1 (exp, p) ...@@ -2627,7 +2627,7 @@ compare_constant_1 (exp, p)
{ {
tree zero = 0; tree zero = 0;
if (bcmp ((char *) &zero, p, sizeof zero)) if (memcmp ((char *) &zero, p, sizeof zero))
return 0; return 0;
p += sizeof zero; p += sizeof zero;
...@@ -2636,7 +2636,7 @@ compare_constant_1 (exp, p) ...@@ -2636,7 +2636,7 @@ compare_constant_1 (exp, p)
if (TREE_PURPOSE (link) if (TREE_PURPOSE (link)
&& TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL) && TREE_CODE (TREE_PURPOSE (link)) == FIELD_DECL)
{ {
if (bcmp ((char *) &TREE_PURPOSE (link), p, if (memcmp ((char *) &TREE_PURPOSE (link), p,
sizeof TREE_PURPOSE (link))) sizeof TREE_PURPOSE (link)))
return 0; return 0;
...@@ -2651,7 +2651,7 @@ compare_constant_1 (exp, p) ...@@ -2651,7 +2651,7 @@ compare_constant_1 (exp, p)
{ {
int zero = 0; int zero = 0;
if (bcmp ((char *) &zero, p, sizeof zero)) if (memcmp ((char *) &zero, p, sizeof zero))
return 0; return 0;
p += sizeof zero; p += sizeof zero;
...@@ -3352,7 +3352,7 @@ decode_rtx_const (mode, x, value) ...@@ -3352,7 +3352,7 @@ decode_rtx_const (mode, x, value)
struct rtx_const *value; struct rtx_const *value;
{ {
/* Clear the whole structure, including any gaps. */ /* Clear the whole structure, including any gaps. */
bzero (value, sizeof (struct rtx_const)); memset (value, 0, sizeof (struct rtx_const));
value->kind = RTX_INT; /* Most usual kind. */ value->kind = RTX_INT; /* Most usual kind. */
value->mode = mode; value->mode = mode;
...@@ -3364,8 +3364,8 @@ decode_rtx_const (mode, x, value) ...@@ -3364,8 +3364,8 @@ decode_rtx_const (mode, x, value)
if (GET_MODE (x) != VOIDmode) if (GET_MODE (x) != VOIDmode)
{ {
value->mode = GET_MODE (x); value->mode = GET_MODE (x);
bcopy ((char *) &CONST_DOUBLE_LOW (x), memcpy ((char *) &value->un.du,
(char *) &value->un.du, sizeof value->un.du); (char *) &CONST_DOUBLE_LOW (x), sizeof value->un.du);
} }
else else
{ {
...@@ -3797,7 +3797,7 @@ output_constant_pool (fnname, fndecl) ...@@ -3797,7 +3797,7 @@ output_constant_pool (fnname, fndecl)
if (GET_CODE (x) != CONST_DOUBLE) if (GET_CODE (x) != CONST_DOUBLE)
abort (); abort ();
bcopy ((char *) &CONST_DOUBLE_LOW (x), (char *) &u, sizeof u); memcpy ((char *) &u, (char *) &CONST_DOUBLE_LOW (x), sizeof u);
assemble_real (u.d, pool->mode); assemble_real (u.d, pool->mode);
break; break;
......
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