summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/cccp.c25
-rw-r--r--gcc/collect2.c15
-rw-r--r--gcc/genextract.c44
-rw-r--r--gcc/genoutput.c127
-rw-r--r--gcc/genrecog.c54
6 files changed, 116 insertions, 166 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 868f971ba2e..8342b555aa1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,20 @@
+Wed Jan 13 13:30:08 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cccp.c (xstrdup): Renamed from `savestring'. All callers changed.
+ Remove prototype which we get from libiberty.h.
+
+ * collect2.c (xstrdup): Likewise.
+
+ * genextract.c (xstrdup): Likewise for `copystr'.
+ (mybzero): Remove it and use `memset' instead.
+
+ * genoutput.c (mybcopy, mybzero): Remove these. All callers changed
+ to use `memcpy' and `memset' instead.
+
+ * genrecog.c (xstrdup): Renamed from `copystr'. All callers
+ changed. Remove prototype.
+ (mybcopy, mybzero): Remove these and use memcpy/memset.
+
Wed Jan 13 00:59:04 1999 Jeffrey A Law (law@cygnus.com)
* mips.h (LOAD_EXTEND_OP): Correct for SImode and CCmode moves when
diff --git a/gcc/cccp.c b/gcc/cccp.c
index eb985dde986..44c7e5d9b2c 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -1042,7 +1042,6 @@ static void pfatal_with_name PROTO((char *)) __attribute__ ((noreturn));
static void pipe_closed PROTO((int)) __attribute__ ((noreturn));
static void memory_full PROTO((void)) __attribute__ ((noreturn));
-static char *savestring PROTO((char *));
static void print_help PROTO((void));
/* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
@@ -1276,7 +1275,7 @@ main (argc, argv)
{
/* Remove extension from PROGNAME. */
char *p;
- char *s = progname = savestring (progname);
+ char *s = progname = xstrdup (progname);
if ((p = rindex (s, ';')) != 0) *p = '\0'; /* strip version number */
if ((p = rindex (s, '.')) != 0 /* strip type iff ".exe" */
@@ -1378,7 +1377,7 @@ main (argc, argv)
if (include_prefix != 0)
prefix = include_prefix;
else {
- prefix = savestring (GCC_INCLUDE_DIR);
+ prefix = xstrdup (GCC_INCLUDE_DIR);
/* Remove the `include' from /usr/local/lib/gcc.../include. */
if (!strcmp (prefix + strlen (prefix) - 8, "/include"))
prefix[strlen (prefix) - 7] = 0;
@@ -1403,7 +1402,7 @@ main (argc, argv)
if (include_prefix != 0)
prefix = include_prefix;
else {
- prefix = savestring (GCC_INCLUDE_DIR);
+ prefix = xstrdup (GCC_INCLUDE_DIR);
/* Remove the `include' from /usr/local/lib/gcc.../include. */
if (!strcmp (prefix + strlen (prefix) - 8, "/include"))
prefix[strlen (prefix) - 7] = 0;
@@ -1977,7 +1976,7 @@ main (argc, argv)
if (c == PATH_SEPARATOR || !c) {
endp[-1] = 0;
include_defaults[num_dirs].fname
- = startp == endp ? "." : savestring (startp);
+ = startp == endp ? "." : xstrdup (startp);
endp[-1] = c;
include_defaults[num_dirs].component = 0;
include_defaults[num_dirs].cplusplus = cplusplus;
@@ -2003,7 +2002,7 @@ main (argc, argv)
if (!no_standard_includes) {
struct default_include *p = include_defaults;
char *specd_prefix = include_prefix;
- char *default_prefix = savestring (GCC_INCLUDE_DIR);
+ char *default_prefix = xstrdup (GCC_INCLUDE_DIR);
int default_len = 0;
/* Remove the `include' from /usr/local/lib/gcc.../include. */
if (!strcmp (default_prefix + strlen (default_prefix) - 8, "/include")) {
@@ -5067,7 +5066,7 @@ read_name_map (dirname)
map_list_ptr = ((struct file_name_map_list *)
xmalloc (sizeof (struct file_name_map_list)));
- map_list_ptr->map_list_name = savestring (dirname);
+ map_list_ptr->map_list_name = xstrdup (dirname);
map_list_ptr->map_list_map = NULL;
dirlen = strlen (dirname);
@@ -10762,13 +10761,13 @@ xcalloc (number, size)
return ptr;
}
-static char *
-savestring (input)
- char *input;
+char *
+xstrdup (input)
+ const char *input;
{
- size_t size = strlen (input);
- char *output = xmalloc (size + 1);
- strcpy (output, input);
+ register size_t len = strlen (input) + 1;
+ register char *output = xmalloc (len);
+ memcpy (output, input, len);
return output;
}
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 8da28465334..2184e0e2398 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -1,6 +1,6 @@
/* Collect static initialization info into data structures that can be
traversed by C++ initialization and finalization routines.
- Copyright (C) 1992, 93-97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
Contributed by Chris Smith (csmith@convex.com).
Heavily modified by Michael Meissner (meissner@cygnus.com),
Per Bothner (bothner@cygnus.com), and John Gilmore (gnu@cygnus.com).
@@ -551,13 +551,12 @@ file_exists (name)
/* Make a copy of a string INPUT with size SIZE. */
char *
-savestring (input, size)
- char *input;
- int size;
+xstrdup (input)
+ const char *input;
{
- char *output = (char *) xmalloc (size + 1);
- bcopy (input, output, size);
- output[size] = 0;
+ register size_t len = strlen (input) + 1;
+ register char *output = xmalloc (len);
+ memcpy (output, input, len);
return output;
}
@@ -874,7 +873,7 @@ add_prefix (pprefix, prefix)
pprefix->max_len = len;
pl = (struct prefix_list *) xmalloc (sizeof (struct prefix_list));
- pl->prefix = savestring (prefix, len);
+ pl->prefix = xstrdup (prefix);
if (*prev)
pl->next = *prev;
diff --git a/gcc/genextract.c b/gcc/genextract.c
index e8efcd2cfe3..6340490f27f 100644
--- a/gcc/genextract.c
+++ b/gcc/genextract.c
@@ -1,5 +1,5 @@
/* Generate code from machine description to extract operands from insn as rtl.
- Copyright (C) 1987, 91, 92, 93, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 91-93, 97-98, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -100,8 +100,6 @@ static void walk_rtx PROTO ((rtx, const char *));
static void print_path PROTO ((char *));
static void fatal PVPROTO ((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
-static char *copystr PROTO ((const char *));
-static void mybzero ();
void fancy_abort PROTO ((void)) ATTRIBUTE_NORETURN;
static void
@@ -116,7 +114,7 @@ gen_insn (insn)
dup_count = 0;
/* No operands seen so far in this pattern. */
- mybzero (oplocs, sizeof oplocs);
+ memset (oplocs, 0, sizeof oplocs);
/* Walk the insn's pattern, remembering at all times the path
down to the walking point. */
@@ -211,19 +209,19 @@ walk_rtx (x, path)
case MATCH_OPERAND:
case MATCH_SCRATCH:
- oplocs[XINT (x, 0)] = copystr (path);
+ oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
break;
case MATCH_DUP:
case MATCH_PAR_DUP:
- duplocs[dup_count] = copystr (path);
+ duplocs[dup_count] = xstrdup (path);
dupnums[dup_count] = XINT (x, 0);
dup_count++;
break;
case MATCH_OP_DUP:
- duplocs[dup_count] = copystr (path);
+ duplocs[dup_count] = xstrdup (path);
dupnums[dup_count] = XINT (x, 0);
dup_count++;
@@ -239,7 +237,7 @@ walk_rtx (x, path)
return;
case MATCH_OPERATOR:
- oplocs[XINT (x, 0)] = copystr (path);
+ oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
newpath = (char *) alloca (depth + 2);
@@ -254,7 +252,7 @@ walk_rtx (x, path)
return;
case MATCH_PARALLEL:
- oplocs[XINT (x, 0)] = copystr (path);
+ oplocs[XINT (x, 0)] = xstrdup (path);
op_count = MAX (op_count, XINT (x, 0) + 1);
newpath = (char *) alloca (depth + 2);
@@ -398,28 +396,14 @@ fancy_abort ()
fatal ("Internal gcc abort.");
}
-static char *
-copystr (s1)
- const char *s1;
+char *
+xstrdup (s1)
+ const char *input;
{
- register char *tem;
-
- if (s1 == 0)
- return 0;
-
- tem = (char *) xmalloc (strlen (s1) + 1);
- strcpy (tem, s1);
-
- return tem;
-}
-
-static void
-mybzero (b, length)
- register char *b;
- register unsigned length;
-{
- while (length-- > 0)
- *b++ = 0;
+ register size_t len = strlen (input) + 1;
+ register char *output = xmalloc (len);
+ memcpy (output, input, len);
+ return output;
}
int
diff --git a/gcc/genoutput.c b/gcc/genoutput.c
index 7aa97697ef1..eaa4461c304 100644
--- a/gcc/genoutput.c
+++ b/gcc/genoutput.c
@@ -1,5 +1,5 @@
/* Generate code from to output assembler insns as recognized from rtl.
- Copyright (C) 1987, 88, 92, 94, 95, 97, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 92, 94-95, 97-98, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -111,8 +111,6 @@ static void fatal PVPROTO ((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
void fancy_abort PROTO((void)) ATTRIBUTE_NORETURN;
static void error PVPROTO ((const char *, ...)) ATTRIBUTE_PRINTF_1;
-static void mybcopy ();
-static void mybzero ();
static int n_occurrences PROTO((int, char *));
/* Define this so we can link with print-rtl.o to get debug_rtx function. */
@@ -684,13 +682,13 @@ gen_insn (insn)
max_opno = -1;
num_dups = 0;
- mybzero (constraints, sizeof constraints);
- mybzero (op_n_alternatives, sizeof op_n_alternatives);
- mybzero (predicates, sizeof predicates);
- mybzero (address_p, sizeof address_p);
- mybzero (modes, sizeof modes);
- mybzero (strict_low, sizeof strict_low);
- mybzero (seen, sizeof seen);
+ memset (constraints, 0, sizeof constraints);
+ memset (op_n_alternatives, 0, sizeof op_n_alternatives);
+ memset (predicates, 0, sizeof predicates);
+ memset (address_p, 0, sizeof address_p);
+ memset (modes, 0, sizeof modes);
+ memset (strict_low, 0, sizeof strict_low);
+ memset (seen, 0, sizeof seen);
for (i = 0; i < XVECLEN (insn, 1); i++)
scan_operands (XVECEXP (insn, 1, i), 0, 0);
@@ -698,12 +696,12 @@ gen_insn (insn)
d->n_operands = max_opno + 1;
d->n_dups = num_dups;
- mybcopy (constraints, d->constraints, sizeof constraints);
- mybcopy (op_n_alternatives, d->op_n_alternatives, sizeof op_n_alternatives);
- mybcopy (predicates, d->predicates, sizeof predicates);
- mybcopy (address_p, d->address_p, sizeof address_p);
- mybcopy (modes, d->modes, sizeof modes);
- mybcopy (strict_low, d->strict_low, sizeof strict_low);
+ memcpy (d->constraints, constraints, sizeof constraints);
+ memcpy (d->op_n_alternatives, op_n_alternatives, sizeof op_n_alternatives);
+ memcpy (d->predicates, predicates, sizeof predicates);
+ memcpy (d->address_p, address_p, sizeof address_p);
+ memcpy (d->modes, modes, sizeof modes);
+ memcpy (d->strict_low, strict_low, sizeof strict_low);
validate_insn_alternatives (d);
process_template (d, XSTR (insn, 3));
@@ -735,13 +733,13 @@ gen_peephole (peep)
end_of_insn_data = d;
max_opno = -1;
- mybzero (constraints, sizeof constraints);
- mybzero (op_n_alternatives, sizeof op_n_alternatives);
- mybzero (predicates, sizeof predicates);
- mybzero (address_p, sizeof address_p);
- mybzero (modes, sizeof modes);
- mybzero (strict_low, sizeof strict_low);
- mybzero (seen, sizeof seen);
+ memset (constraints, 0, sizeof constraints);
+ memset (op_n_alternatives, 0, sizeof op_n_alternatives);
+ memset (predicates, 0, sizeof predicates);
+ memset (address_p, 0, sizeof address_p);
+ memset (modes, 0, sizeof modes);
+ memset (strict_low, 0, sizeof strict_low);
+ memset (seen, 0, sizeof seen);
/* Get the number of operands by scanning all the
patterns of the peephole optimizer.
@@ -752,12 +750,12 @@ gen_peephole (peep)
d->n_operands = max_opno + 1;
d->n_dups = 0;
- mybcopy (constraints, d->constraints, sizeof constraints);
- mybcopy (op_n_alternatives, d->op_n_alternatives, sizeof op_n_alternatives);
- mybzero (d->predicates, sizeof predicates);
- mybzero (d->address_p, sizeof address_p);
- mybzero (d->modes, sizeof modes);
- mybzero (d->strict_low, sizeof strict_low);
+ memcpy (d->constraints, constraints, sizeof constraints);
+ memcpy (d->op_n_alternatives, op_n_alternatives, sizeof op_n_alternatives);
+ memset (d->predicates, 0, sizeof predicates);
+ memset (d->address_p, 0, sizeof address_p);
+ memset (d->modes, 0, sizeof modes);
+ memset (d->strict_low, 0, sizeof strict_low);
validate_insn_alternatives (d);
process_template (d, XSTR (peep, 2));
@@ -796,13 +794,13 @@ gen_expand (insn)
/* Scan the operands to get the specified predicates and modes,
since expand_binop needs to know them. */
- mybzero (constraints, sizeof constraints);
- mybzero (op_n_alternatives, sizeof op_n_alternatives);
- mybzero (predicates, sizeof predicates);
- mybzero (address_p, sizeof address_p);
- mybzero (modes, sizeof modes);
- mybzero (strict_low, sizeof strict_low);
- mybzero (seen, sizeof seen);
+ memset (constraints, 0, sizeof constraints);
+ memset (op_n_alternatives, 0, sizeof op_n_alternatives);
+ memset (predicates, 0, sizeof predicates);
+ memset (address_p, 0, sizeof address_p);
+ memset (modes, 0, sizeof modes);
+ memset (strict_low, 0, sizeof strict_low);
+ memset (seen, 0, sizeof seen);
if (XVEC (insn, 1))
for (i = 0; i < XVECLEN (insn, 1); i++)
@@ -811,12 +809,12 @@ gen_expand (insn)
d->n_operands = max_opno + 1;
d->n_dups = num_dups;
- mybcopy (constraints, d->constraints, sizeof constraints);
- mybcopy (op_n_alternatives, d->op_n_alternatives, sizeof op_n_alternatives);
- mybcopy (predicates, d->predicates, sizeof predicates);
- mybcopy (address_p, d->address_p, sizeof address_p);
- mybcopy (modes, d->modes, sizeof modes);
- mybcopy (strict_low, d->strict_low, sizeof strict_low);
+ memcpy (d->constraints, constraints, sizeof constraints);
+ memcpy (d->op_n_alternatives, op_n_alternatives, sizeof op_n_alternatives);
+ memcpy (d->predicates, predicates, sizeof predicates);
+ memcpy (d->address_p, address_p, sizeof address_p);
+ memcpy (d->modes, modes, sizeof modes);
+ memcpy (d->strict_low, strict_low, sizeof strict_low);
d->template = 0;
d->outfun = 0;
@@ -851,13 +849,13 @@ gen_split (split)
max_opno = -1;
num_dups = 0;
- mybzero (constraints, sizeof constraints);
- mybzero (op_n_alternatives, sizeof op_n_alternatives);
- mybzero (predicates, sizeof predicates);
- mybzero (address_p, sizeof address_p);
- mybzero (modes, sizeof modes);
- mybzero (strict_low, sizeof strict_low);
- mybzero (seen, sizeof seen);
+ memset (constraints, 0, sizeof constraints);
+ memset (op_n_alternatives, 0, sizeof op_n_alternatives);
+ memset (predicates, 0, sizeof predicates);
+ memset (address_p, 0, sizeof address_p);
+ memset (modes, 0, sizeof modes);
+ memset (strict_low, 0, sizeof strict_low);
+ memset (seen, 0, sizeof seen);
/* Get the number of operands by scanning all the
patterns of the split patterns.
@@ -867,12 +865,12 @@ gen_split (split)
d->n_operands = max_opno + 1;
- mybzero (d->constraints, sizeof constraints);
- mybzero (d->op_n_alternatives, sizeof op_n_alternatives);
- mybzero (d->predicates, sizeof predicates);
- mybzero (d->address_p, sizeof address_p);
- mybzero (d->modes, sizeof modes);
- mybzero (d->strict_low, sizeof strict_low);
+ memset (d->constraints, 0, sizeof constraints);
+ memset (d->op_n_alternatives, 0, sizeof op_n_alternatives);
+ memset (d->predicates, 0, sizeof predicates);
+ memset (d->address_p, 0, sizeof address_p);
+ memset (d->modes, 0, sizeof modes);
+ memset (d->strict_low, 0, sizeof strict_low);
d->n_dups = 0;
d->n_alternatives = 0;
@@ -903,25 +901,6 @@ xrealloc (ptr, size)
}
static void
-mybzero (b, length)
- register char *b;
- register unsigned length;
-{
- while (length-- > 0)
- *b++ = 0;
-}
-
-static void
-mybcopy (b1, b2, length)
- register char *b1;
- register char *b2;
- register unsigned length;
-{
- while (length-- > 0)
- *b2++ = *b1++;
-}
-
-static void
fatal VPROTO ((const char *format, ...))
{
#ifndef ANSI_PROTOTYPES
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index 8d9871de1d5..bf0c0dad50c 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -1,5 +1,5 @@
/* Generate code from machine description to recognize rtl as insns.
- Copyright (C) 1987, 88, 92, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 92-95, 97-98, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -191,9 +191,6 @@ static void write_tree PROTO((struct decision *, const char *,
struct decision *, int,
enum routine_type));
static void change_state PROTO((const char *, const char *, int));
-static char *copystr PROTO((const char *));
-static void mybzero PROTO((char *, unsigned));
-static void mybcopy PROTO((char *, char *, unsigned));
static void fatal PVPROTO((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
void fancy_abort PROTO((void)) ATTRIBUTE_NORETURN;
@@ -310,7 +307,7 @@ add_to_sequence (pattern, last, position)
max_depth = depth;
new->number = next_number++;
- new->position = copystr (position);
+ new->position = xstrdup (position);
new->ignore_code = 0;
new->ignore_mode = 0;
new->enforce_mode = 1;
@@ -833,8 +830,7 @@ merge_trees (oldh, addh)
struct decision *split
= (struct decision *) xmalloc (sizeof (struct decision));
- mybcopy ((char *) old, (char *) split,
- sizeof (struct decision));
+ memcpy (split, old, sizeof (struct decision));
old->success.first = old->success.last = split;
old->c_test = 0;
@@ -860,8 +856,7 @@ merge_trees (oldh, addh)
struct decision *split
= (struct decision *) xmalloc (sizeof (struct decision));
- mybcopy ((char *) add, (char *) split,
- sizeof (struct decision));
+ memcpy (split, add, sizeof (struct decision));
add->success.first = add->success.last = split;
add->c_test = 0;
@@ -1300,7 +1295,7 @@ write_tree_1 (tree, prevpos, afterward, type)
if (switch_mode == VOIDmode && mode != VOIDmode && p->next != 0
&& p->next->enforce_mode && p->next->mode != VOIDmode)
{
- mybzero (modemap, sizeof modemap);
+ memset (modemap, 0, sizeof modemap);
printf ("%sswitch (GET_MODE (x%d))\n", indents[indent], depth);
printf ("%s{\n", indents[indent + 2]);
indent += 4;
@@ -1317,7 +1312,7 @@ write_tree_1 (tree, prevpos, afterward, type)
if (switch_code == UNKNOWN && p->code != UNKNOWN && ! p->ignore_code
&& p->next != 0 && p->next->code != UNKNOWN)
{
- mybzero (codemap, sizeof codemap);
+ memset (codemap, 0, sizeof codemap);
printf ("%sswitch (GET_CODE (x%d))\n", indents[indent], depth);
printf ("%s{\n", indents[indent + 2]);
indent += 4;
@@ -1628,37 +1623,14 @@ change_state (oldpos, newpos, indent)
}
}
-static char *
-copystr (s1)
- const char *s1;
+char *
+xstrdup (s1)
+ const char *input;
{
- register char *tem;
-
- if (s1 == 0)
- return 0;
-
- tem = (char *) xmalloc (strlen (s1) + 1);
- strcpy (tem, s1);
-
- return tem;
-}
-
-static void
-mybzero (b, length)
- register char *b;
- register unsigned length;
-{
- while (length-- > 0)
- *b++ = 0;
-}
-
-static void
-mybcopy (in, out, length)
- register char *in, *out;
- register unsigned length;
-{
- while (length-- > 0)
- *out++ = *in++;
+ register size_t len = strlen (input) + 1;
+ register char *output = xmalloc (len);
+ memcpy (output, input, len);
+ return output;
}
PTR