Commit 159b3be1 by Andreas Jaeger Committed by Andreas Jaeger

collect2.h: Convert prototypes to ISO C90.

	* collect2.h: Convert prototypes to ISO C90.
	* collect2.c: Likewise.
	* conflict.c: Likewise.
	* coverage.c: Likewise.
	* convert.h: Likewise.
	* convert.c: Likewise.

From-SVN: r68669
parent 4e3f84b7
2003-06-29 Andreas Jaeger <aj@suse.de>
* collect2.h: Convert prototypes to ISO C90.
* collect2.c: Likewise.
* conflict.c: Likewise.
* coverage.c: Likewise.
* convert.h: Likewise.
* convert.c: Likewise.
2003-06-29 Nathan Sidwell <nathan@codesourcery.com> 2003-06-29 Nathan Sidwell <nathan@codesourcery.com>
* c-decl.c (c_init_decl_processing): Use a location_t. Set input * c-decl.c (c_init_decl_processing): Use a location_t. Set input
......
...@@ -104,7 +104,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -104,7 +104,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* Some systems have an ISCOFF macro, but others do not. In some cases /* Some systems have an ISCOFF macro, but others do not. In some cases
the macro may be wrong. MY_ISCOFF is defined in tm.h files for machines the macro may be wrong. MY_ISCOFF is defined in tm.h files for machines
that either do not have an ISCOFF macro in /usr/include or for those that either do not have an ISCOFF macro in /usr/include or for those
where it is wrong. */ where it is wrong. */
#ifndef MY_ISCOFF #ifndef MY_ISCOFF
...@@ -175,7 +175,7 @@ int no_demangle; ...@@ -175,7 +175,7 @@ int no_demangle;
/* Linked lists of constructor and destructor names. */ /* Linked lists of constructor and destructor names. */
struct id struct id
{ {
struct id *next; struct id *next;
int sequence; int sequence;
...@@ -264,58 +264,55 @@ static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs, ...@@ -264,58 +264,55 @@ static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
static const char *const libexts[3] = {"a", "so", NULL}; /* possible library extensions */ static const char *const libexts[3] = {"a", "so", NULL}; /* possible library extensions */
#endif #endif
static void handler PARAMS ((int)); static void handler (int);
static int is_ctor_dtor PARAMS ((const char *)); static int is_ctor_dtor (const char *);
static char *find_a_file PARAMS ((struct path_prefix *, const char *)); static char *find_a_file (struct path_prefix *, const char *);
static void add_prefix PARAMS ((struct path_prefix *, const char *)); static void add_prefix (struct path_prefix *, const char *);
static void prefix_from_env PARAMS ((const char *, struct path_prefix *)); static void prefix_from_env (const char *, struct path_prefix *);
static void prefix_from_string PARAMS ((const char *, struct path_prefix *)); static void prefix_from_string (const char *, struct path_prefix *);
static void do_wait PARAMS ((const char *)); static void do_wait (const char *);
static void fork_execute PARAMS ((const char *, char **)); static void fork_execute (const char *, char **);
static void maybe_unlink PARAMS ((const char *)); static void maybe_unlink (const char *);
static void add_to_list PARAMS ((struct head *, const char *)); static void add_to_list (struct head *, const char *);
static int extract_init_priority PARAMS ((const char *)); static int extract_init_priority (const char *);
static void sort_ids PARAMS ((struct head *)); static void sort_ids (struct head *);
static void write_list PARAMS ((FILE *, const char *, struct id *)); static void write_list (FILE *, const char *, struct id *);
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static void dump_list PARAMS ((FILE *, const char *, struct id *)); static void dump_list (FILE *, const char *, struct id *);
#endif #endif
#if 0 #if 0
static void dump_prefix_list PARAMS ((FILE *, const char *, struct prefix_list *)); static void dump_prefix_list (FILE *, const char *, struct prefix_list *);
#endif #endif
static void write_list_with_asm PARAMS ((FILE *, const char *, struct id *)); static void write_list_with_asm (FILE *, const char *, struct id *);
static void write_c_file PARAMS ((FILE *, const char *)); static void write_c_file (FILE *, const char *);
static void write_c_file_stat PARAMS ((FILE *, const char *)); static void write_c_file_stat (FILE *, const char *);
#ifndef LD_INIT_SWITCH #ifndef LD_INIT_SWITCH
static void write_c_file_glob PARAMS ((FILE *, const char *)); static void write_c_file_glob (FILE *, const char *);
#endif #endif
static void scan_prog_file PARAMS ((const char *, enum pass)); static void scan_prog_file (const char *, enum pass);
#ifdef SCAN_LIBRARIES #ifdef SCAN_LIBRARIES
static void scan_libraries PARAMS ((const char *)); static void scan_libraries (const char *);
#endif #endif
#if LINK_ELIMINATE_DUPLICATE_LDIRECTORIES #if LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
static int is_in_args PARAMS ((const char *, const char **, const char **)); static int is_in_args (const char *, const char **, const char **);
#endif #endif
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
#if 0 #if 0
static int is_in_list PARAMS ((const char *, struct id *)); static int is_in_list (const char *, struct id *);
#endif #endif
static void write_aix_file PARAMS ((FILE *, struct id *)); static void write_aix_file (FILE *, struct id *);
static char *resolve_lib_name PARAMS ((const char *)); static char *resolve_lib_name (const char *);
#endif #endif
static char *extract_string PARAMS ((const char **)); static char *extract_string (const char **);
#ifndef HAVE_DUP2 #ifndef HAVE_DUP2
static int dup2 PARAMS ((int, int));
static int static int
dup2 (oldfd, newfd) dup2 (int oldfd, int newfd)
int oldfd;
int newfd;
{ {
int fdtmp[256]; int fdtmp[256];
int fdx = 0; int fdx = 0;
int fd; int fd;
if (oldfd == newfd) if (oldfd == newfd)
return oldfd; return oldfd;
close (newfd); close (newfd);
...@@ -331,8 +328,7 @@ dup2 (oldfd, newfd) ...@@ -331,8 +328,7 @@ dup2 (oldfd, newfd)
/* Delete tempfiles and exit function. */ /* Delete tempfiles and exit function. */
void void
collect_exit (status) collect_exit (int status)
int status;
{ {
if (c_file != 0 && c_file[0]) if (c_file != 0 && c_file[0])
maybe_unlink (c_file); maybe_unlink (c_file);
...@@ -363,7 +359,7 @@ void ...@@ -363,7 +359,7 @@ void
notice (const char *msgid, ...) notice (const char *msgid, ...)
{ {
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
vfprintf (stderr, _(msgid), ap); vfprintf (stderr, _(msgid), ap);
va_end (ap); va_end (ap);
...@@ -376,7 +372,7 @@ fatal_perror (const char * msgid, ...) ...@@ -376,7 +372,7 @@ fatal_perror (const char * msgid, ...)
{ {
int e = errno; int e = errno;
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
fprintf (stderr, "collect2: "); fprintf (stderr, "collect2: ");
vfprintf (stderr, _(msgid), ap); vfprintf (stderr, _(msgid), ap);
...@@ -392,7 +388,7 @@ void ...@@ -392,7 +388,7 @@ void
fatal (const char * msgid, ...) fatal (const char * msgid, ...)
{ {
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
fprintf (stderr, "collect2: "); fprintf (stderr, "collect2: ");
vfprintf (stderr, _(msgid), ap); vfprintf (stderr, _(msgid), ap);
...@@ -408,7 +404,7 @@ void ...@@ -408,7 +404,7 @@ void
error (const char * msgid, ...) error (const char * msgid, ...)
{ {
va_list ap; va_list ap;
va_start (ap, msgid); va_start (ap, msgid);
fprintf (stderr, "collect2: "); fprintf (stderr, "collect2: ");
vfprintf (stderr, _(msgid), ap); vfprintf (stderr, _(msgid), ap);
...@@ -420,14 +416,13 @@ error (const char * msgid, ...) ...@@ -420,14 +416,13 @@ error (const char * msgid, ...)
provide a default entry. */ provide a default entry. */
void void
fancy_abort () fancy_abort (void)
{ {
fatal ("internal error"); fatal ("internal error");
} }
static void static void
handler (signo) handler (int signo)
int signo;
{ {
if (c_file != 0 && c_file[0]) if (c_file != 0 && c_file[0])
maybe_unlink (c_file); maybe_unlink (c_file);
...@@ -449,8 +444,7 @@ handler (signo) ...@@ -449,8 +444,7 @@ handler (signo)
int int
file_exists (name) file_exists (const char *name)
const char *name;
{ {
return access (name, R_OK) == 0; return access (name, R_OK) == 0;
} }
...@@ -458,8 +452,7 @@ file_exists (name) ...@@ -458,8 +452,7 @@ file_exists (name)
/* Parse a reasonable subset of shell quoting syntax. */ /* Parse a reasonable subset of shell quoting syntax. */
static char * static char *
extract_string (pp) extract_string (const char **pp)
const char **pp;
{ {
const char *p = *pp; const char *p = *pp;
int backquote = 0; int backquote = 0;
...@@ -489,8 +482,7 @@ extract_string (pp) ...@@ -489,8 +482,7 @@ extract_string (pp)
} }
void void
dump_file (name) dump_file (const char *name)
const char *name;
{ {
FILE *stream = fopen (name, "r"); FILE *stream = fopen (name, "r");
...@@ -552,8 +544,7 @@ dump_file (name) ...@@ -552,8 +544,7 @@ dump_file (name)
nothing special (0). */ nothing special (0). */
static int static int
is_ctor_dtor (s) is_ctor_dtor (const char *s)
const char *s;
{ {
struct names { const char *const name; const int len; const int ret; struct names { const char *const name; const int len; const int ret;
const int two_underscores; }; const int two_underscores; };
...@@ -611,14 +602,12 @@ static const char *const target_machine = TARGET_MACHINE; ...@@ -611,14 +602,12 @@ static const char *const target_machine = TARGET_MACHINE;
#endif #endif
/* Search for NAME using prefix list PPREFIX. We only look for executable /* Search for NAME using prefix list PPREFIX. We only look for executable
files. files.
Return 0 if not found, otherwise return its name, allocated with malloc. */ Return 0 if not found, otherwise return its name, allocated with malloc. */
static char * static char *
find_a_file (pprefix, name) find_a_file (struct path_prefix *pprefix, const char *name)
struct path_prefix *pprefix;
const char *name;
{ {
char *temp; char *temp;
struct prefix_list *pl; struct prefix_list *pl;
...@@ -626,7 +615,7 @@ find_a_file (pprefix, name) ...@@ -626,7 +615,7 @@ find_a_file (pprefix, name)
if (debug) if (debug)
fprintf (stderr, "Looking for '%s'\n", name); fprintf (stderr, "Looking for '%s'\n", name);
#ifdef HOST_EXECUTABLE_SUFFIX #ifdef HOST_EXECUTABLE_SUFFIX
len += strlen (HOST_EXECUTABLE_SUFFIX); len += strlen (HOST_EXECUTABLE_SUFFIX);
#endif #endif
...@@ -647,7 +636,7 @@ find_a_file (pprefix, name) ...@@ -647,7 +636,7 @@ find_a_file (pprefix, name)
if (debug) if (debug)
fprintf (stderr, " - found: absolute path\n"); fprintf (stderr, " - found: absolute path\n");
return temp; return temp;
} }
...@@ -656,7 +645,7 @@ find_a_file (pprefix, name) ...@@ -656,7 +645,7 @@ find_a_file (pprefix, name)
So try appending that. */ So try appending that. */
strcpy (temp, name); strcpy (temp, name);
strcat (temp, HOST_EXECUTABLE_SUFFIX); strcat (temp, HOST_EXECUTABLE_SUFFIX);
if (access (temp, X_OK) == 0) if (access (temp, X_OK) == 0)
return temp; return temp;
#endif #endif
...@@ -671,7 +660,7 @@ find_a_file (pprefix, name) ...@@ -671,7 +660,7 @@ find_a_file (pprefix, name)
strcpy (temp, pl->prefix); strcpy (temp, pl->prefix);
strcat (temp, name); strcat (temp, name);
if (stat (temp, &st) >= 0 if (stat (temp, &st) >= 0
&& ! S_ISDIR (st.st_mode) && ! S_ISDIR (st.st_mode)
&& access (temp, X_OK) == 0) && access (temp, X_OK) == 0)
...@@ -681,7 +670,7 @@ find_a_file (pprefix, name) ...@@ -681,7 +670,7 @@ find_a_file (pprefix, name)
/* Some systems have a suffix for executable files. /* Some systems have a suffix for executable files.
So try appending that. */ So try appending that. */
strcat (temp, HOST_EXECUTABLE_SUFFIX); strcat (temp, HOST_EXECUTABLE_SUFFIX);
if (stat (temp, &st) >= 0 if (stat (temp, &st) >= 0
&& ! S_ISDIR (st.st_mode) && ! S_ISDIR (st.st_mode)
&& access (temp, X_OK) == 0) && access (temp, X_OK) == 0)
...@@ -699,9 +688,7 @@ find_a_file (pprefix, name) ...@@ -699,9 +688,7 @@ find_a_file (pprefix, name)
/* Add an entry for PREFIX to prefix list PPREFIX. */ /* Add an entry for PREFIX to prefix list PPREFIX. */
static void static void
add_prefix (pprefix, prefix) add_prefix (struct path_prefix *pprefix, const char *prefix)
struct path_prefix *pprefix;
const char *prefix;
{ {
struct prefix_list *pl, **prev; struct prefix_list *pl, **prev;
int len; int len;
...@@ -735,9 +722,7 @@ add_prefix (pprefix, prefix) ...@@ -735,9 +722,7 @@ add_prefix (pprefix, prefix)
add of the entries to PPREFIX. */ add of the entries to PPREFIX. */
static void static void
prefix_from_env (env, pprefix) prefix_from_env (const char *env, struct path_prefix *pprefix)
const char *env;
struct path_prefix *pprefix;
{ {
const char *p; const char *p;
GET_ENVIRONMENT (p, env); GET_ENVIRONMENT (p, env);
...@@ -747,16 +732,14 @@ prefix_from_env (env, pprefix) ...@@ -747,16 +732,14 @@ prefix_from_env (env, pprefix)
} }
static void static void
prefix_from_string (p, pprefix) prefix_from_string (const char *p, struct path_prefix *pprefix)
const char *p;
struct path_prefix *pprefix;
{ {
const char *startp, *endp; const char *startp, *endp;
char *nstore = (char *) xmalloc (strlen (p) + 3); char *nstore = (char *) xmalloc (strlen (p) + 3);
if (debug) if (debug)
fprintf (stderr, "Convert string '%s' into prefixes, separator = '%c'\n", p, PATH_SEPARATOR); fprintf (stderr, "Convert string '%s' into prefixes, separator = '%c'\n", p, PATH_SEPARATOR);
startp = endp = p; startp = endp = p;
while (1) while (1)
{ {
...@@ -777,7 +760,7 @@ prefix_from_string (p, pprefix) ...@@ -777,7 +760,7 @@ prefix_from_string (p, pprefix)
if (debug) if (debug)
fprintf (stderr, " - add prefix: %s\n", nstore); fprintf (stderr, " - add prefix: %s\n", nstore);
add_prefix (pprefix, nstore); add_prefix (pprefix, nstore);
if (*endp == 0) if (*endp == 0)
break; break;
...@@ -790,11 +773,8 @@ prefix_from_string (p, pprefix) ...@@ -790,11 +773,8 @@ prefix_from_string (p, pprefix)
/* Main program. */ /* Main program. */
int main PARAMS ((int, char *[]));
int int
main (argc, argv) main (int argc, char **argv)
int argc;
char *argv[];
{ {
static const char *const ld_suffix = "ld"; static const char *const ld_suffix = "ld";
static const char *const real_ld_suffix = "real-ld"; static const char *const real_ld_suffix = "real-ld";
...@@ -890,7 +870,7 @@ main (argc, argv) ...@@ -890,7 +870,7 @@ main (argc, argv)
are called. */ are called. */
{ {
int i; int i;
for (i = 1; argv[i] != NULL; i ++) for (i = 1; argv[i] != NULL; i ++)
if (! strcmp (argv[i], "-debug")) if (! strcmp (argv[i], "-debug"))
debug = 1; debug = 1;
...@@ -1053,7 +1033,7 @@ main (argc, argv) ...@@ -1053,7 +1033,7 @@ main (argc, argv)
add_prefix (&libpath_lib_dirs, "/usr/lib"); add_prefix (&libpath_lib_dirs, "/usr/lib");
#endif #endif
/* Get any options that the upper GCC wants to pass to the sub-GCC. /* Get any options that the upper GCC wants to pass to the sub-GCC.
AIX support needs to know if -shared has been specified before AIX support needs to know if -shared has been specified before
parsing commandline arguments. */ parsing commandline arguments. */
...@@ -1143,10 +1123,10 @@ main (argc, argv) ...@@ -1143,10 +1123,10 @@ main (argc, argv)
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
/* Saving directories where to search for libraries. */ /* Saving directories where to search for libraries. */
case 'L': case 'L':
add_prefix (&cmdline_lib_dirs, arg+2); add_prefix (&cmdline_lib_dirs, arg+2);
break; break;
#else #else
#if LINK_ELIMINATE_DUPLICATE_LDIRECTORIES #if LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
case 'L': case 'L':
if (is_in_args (arg, (const char **) ld1_argv, ld1-1)) if (is_in_args (arg, (const char **) ld1_argv, ld1-1))
...@@ -1211,8 +1191,8 @@ main (argc, argv) ...@@ -1211,8 +1191,8 @@ main (argc, argv)
*object++ = arg; *object++ = arg;
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
/* libraries can be specified directly, i.e. without -l flag. */ /* libraries can be specified directly, i.e. without -l flag. */
else else
{ {
/* Saving a full library name. */ /* Saving a full library name. */
add_to_list (&libs, arg); add_to_list (&libs, arg);
} }
...@@ -1246,7 +1226,7 @@ main (argc, argv) ...@@ -1246,7 +1226,7 @@ main (argc, argv)
if (exports.first) if (exports.first)
{ {
char *buf = concat ("-bE:", export_file, NULL); char *buf = concat ("-bE:", export_file, NULL);
*ld1++ = buf; *ld1++ = buf;
*ld2++ = buf; *ld2++ = buf;
...@@ -1378,7 +1358,7 @@ main (argc, argv) ...@@ -1378,7 +1358,7 @@ main (argc, argv)
{ {
char **real_strip_argv = (char **) xcalloc (sizeof (char *), 3); char **real_strip_argv = (char **) xcalloc (sizeof (char *), 3);
const char ** strip_argv = (const char **) real_strip_argv; const char ** strip_argv = (const char **) real_strip_argv;
strip_argv[0] = strip_file_name; strip_argv[0] = strip_file_name;
strip_argv[1] = output_file; strip_argv[1] = output_file;
strip_argv[2] = (char *) 0; strip_argv[2] = (char *) 0;
...@@ -1470,7 +1450,7 @@ main (argc, argv) ...@@ -1470,7 +1450,7 @@ main (argc, argv)
/* Let scan_prog_file do any final mods (OSF/rose needs this for /* Let scan_prog_file do any final mods (OSF/rose needs this for
constructors/destructors in shared libraries. */ constructors/destructors in shared libraries. */
scan_prog_file (output_file, PASS_SECOND); scan_prog_file (output_file, PASS_SECOND);
#endif #endif
maybe_unlink (c_file); maybe_unlink (c_file);
maybe_unlink (o_file); maybe_unlink (o_file);
...@@ -1486,8 +1466,7 @@ main (argc, argv) ...@@ -1486,8 +1466,7 @@ main (argc, argv)
/* Wait for a process to finish, and exit if a nonzero status is found. */ /* Wait for a process to finish, and exit if a nonzero status is found. */
int int
collect_wait (prog) collect_wait (const char *prog)
const char *prog;
{ {
int status; int status;
...@@ -1510,8 +1489,7 @@ collect_wait (prog) ...@@ -1510,8 +1489,7 @@ collect_wait (prog)
} }
static void static void
do_wait (prog) do_wait (const char *prog)
const char *prog;
{ {
int ret = collect_wait (prog); int ret = collect_wait (prog);
if (ret != 0) if (ret != 0)
...@@ -1525,10 +1503,7 @@ do_wait (prog) ...@@ -1525,10 +1503,7 @@ do_wait (prog)
/* Execute a program, and wait for the reply. */ /* Execute a program, and wait for the reply. */
void void
collect_execute (prog, argv, redir) collect_execute (const char *prog, char **argv, const char *redir)
const char *prog;
char **argv;
const char *redir;
{ {
char *errmsg_fmt; char *errmsg_fmt;
char *errmsg_arg; char *errmsg_arg;
...@@ -1598,9 +1573,7 @@ collect_execute (prog, argv, redir) ...@@ -1598,9 +1573,7 @@ collect_execute (prog, argv, redir)
} }
static void static void
fork_execute (prog, argv) fork_execute (const char *prog, char **argv)
const char *prog;
char **argv;
{ {
collect_execute (prog, argv, NULL); collect_execute (prog, argv, NULL);
do_wait (prog); do_wait (prog);
...@@ -1609,8 +1582,7 @@ fork_execute (prog, argv) ...@@ -1609,8 +1582,7 @@ fork_execute (prog, argv)
/* Unlink a file unless we are debugging. */ /* Unlink a file unless we are debugging. */
static void static void
maybe_unlink (file) maybe_unlink (const char *file)
const char *file;
{ {
if (!debug) if (!debug)
unlink (file); unlink (file);
...@@ -1624,9 +1596,7 @@ static long sequence_number = 0; ...@@ -1624,9 +1596,7 @@ static long sequence_number = 0;
/* Add a name to a linked list. */ /* Add a name to a linked list. */
static void static void
add_to_list (head_ptr, name) add_to_list (struct head *head_ptr, const char *name)
struct head *head_ptr;
const char *name;
{ {
struct id *newid struct id *newid
= (struct id *) xcalloc (sizeof (struct id) + strlen (name), 1); = (struct id *) xcalloc (sizeof (struct id) + strlen (name), 1);
...@@ -1659,8 +1629,7 @@ add_to_list (head_ptr, name) ...@@ -1659,8 +1629,7 @@ add_to_list (head_ptr, name)
looks like "_GLOBAL_.I.12345.foo". */ looks like "_GLOBAL_.I.12345.foo". */
static int static int
extract_init_priority (name) extract_init_priority (const char *name)
const char *name;
{ {
int pos = 0, pri; int pos = 0, pri;
...@@ -1677,8 +1646,7 @@ extract_init_priority (name) ...@@ -1677,8 +1646,7 @@ extract_init_priority (name)
ctors will be run from right to left, dtors from left to right. */ ctors will be run from right to left, dtors from left to right. */
static void static void
sort_ids (head_ptr) sort_ids (struct head *head_ptr)
struct head *head_ptr;
{ {
/* id holds the current element to insert. id_next holds the next /* id holds the current element to insert. id_next holds the next
element to insert. id_ptr iterates through the already sorted elements element to insert. id_ptr iterates through the already sorted elements
...@@ -1719,10 +1687,7 @@ sort_ids (head_ptr) ...@@ -1719,10 +1687,7 @@ sort_ids (head_ptr)
/* Write: `prefix', the names on list LIST, `suffix'. */ /* Write: `prefix', the names on list LIST, `suffix'. */
static void static void
write_list (stream, prefix, list) write_list (FILE *stream, const char *prefix, struct id *list)
FILE *stream;
const char *prefix;
struct id *list;
{ {
while (list) while (list)
{ {
...@@ -1736,10 +1701,8 @@ write_list (stream, prefix, list) ...@@ -1736,10 +1701,8 @@ write_list (stream, prefix, list)
[ARGS_BEGIN,ARGS_END). */ [ARGS_BEGIN,ARGS_END). */
static int static int
is_in_args (string, args_begin, args_end) is_in_args (const char *string, const char **args_begin,
const char *string; const char **args_end)
const char **args_begin;
const char **args_end;
{ {
const char **args_pointer; const char **args_pointer;
for (args_pointer = args_begin; args_pointer != args_end; ++args_pointer) for (args_pointer = args_begin; args_pointer != args_end; ++args_pointer)
...@@ -1753,9 +1716,7 @@ is_in_args (string, args_begin, args_end) ...@@ -1753,9 +1716,7 @@ is_in_args (string, args_begin, args_end)
/* This function is really used only on AIX, but may be useful. */ /* This function is really used only on AIX, but may be useful. */
#if 0 #if 0
static int static int
is_in_list (prefix, list) is_in_list (const char *prefix, struct id *list)
const char *prefix;
struct id *list;
{ {
while (list) while (list)
{ {
...@@ -1770,10 +1731,7 @@ is_in_list (prefix, list) ...@@ -1770,10 +1731,7 @@ is_in_list (prefix, list)
/* Added for debugging purpose. */ /* Added for debugging purpose. */
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static void static void
dump_list (stream, prefix, list) dump_list (FILE *stream, const char *prefix, struct id *list)
FILE *stream;
const char *prefix;
struct id *list;
{ {
while (list) while (list)
{ {
...@@ -1785,10 +1743,7 @@ dump_list (stream, prefix, list) ...@@ -1785,10 +1743,7 @@ dump_list (stream, prefix, list)
#if 0 #if 0
static void static void
dump_prefix_list (stream, prefix, list) dump_prefix_list (FILE *stream, const char *prefix, struct prefix_list *list)
FILE *stream;
const char *prefix;
struct prefix_list *list;
{ {
while (list) while (list)
{ {
...@@ -1799,10 +1754,7 @@ dump_prefix_list (stream, prefix, list) ...@@ -1799,10 +1754,7 @@ dump_prefix_list (stream, prefix, list)
#endif #endif
static void static void
write_list_with_asm (stream, prefix, list) write_list_with_asm (FILE *stream, const char *prefix, struct id *list)
FILE *stream;
const char *prefix;
struct id *list;
{ {
while (list) while (list)
{ {
...@@ -1816,9 +1768,7 @@ write_list_with_asm (stream, prefix, list) ...@@ -1816,9 +1768,7 @@ write_list_with_asm (stream, prefix, list)
object), along with the functions to execute them. */ object), along with the functions to execute them. */
static void static void
write_c_file_stat (stream, name) write_c_file_stat (FILE *stream, const char *name ATTRIBUTE_UNUSED)
FILE *stream;
const char *name ATTRIBUTE_UNUSED;
{ {
const char *p, *q; const char *p, *q;
char *prefix, *r; char *prefix, *r;
...@@ -1947,16 +1897,14 @@ write_c_file_stat (stream, name) ...@@ -1947,16 +1897,14 @@ write_c_file_stat (stream, name)
#ifndef LD_INIT_SWITCH #ifndef LD_INIT_SWITCH
static void static void
write_c_file_glob (stream, name) write_c_file_glob (FILE *stream, const char *name ATTRIBUTE_UNUSED)
FILE *stream;
const char *name ATTRIBUTE_UNUSED;
{ {
/* Write the tables as C code */ /* Write the tables as C code */
int frames = (frame_tables.number > 0); int frames = (frame_tables.number > 0);
fprintf (stream, "typedef void entry_pt();\n\n"); fprintf (stream, "typedef void entry_pt();\n\n");
write_list_with_asm (stream, "extern entry_pt ", constructors.first); write_list_with_asm (stream, "extern entry_pt ", constructors.first);
if (frames) if (frames)
...@@ -2012,9 +1960,7 @@ write_c_file_glob (stream, name) ...@@ -2012,9 +1960,7 @@ write_c_file_glob (stream, name)
#endif /* ! LD_INIT_SWITCH */ #endif /* ! LD_INIT_SWITCH */
static void static void
write_c_file (stream, name) write_c_file (FILE *stream, const char *name)
FILE *stream;
const char *name;
{ {
fprintf (stream, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n"); fprintf (stream, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
#ifndef LD_INIT_SWITCH #ifndef LD_INIT_SWITCH
...@@ -2028,9 +1974,7 @@ write_c_file (stream, name) ...@@ -2028,9 +1974,7 @@ write_c_file (stream, name)
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
static void static void
write_aix_file (stream, list) write_aix_file (FILE *stream, struct id *list)
FILE *stream;
struct id *list;
{ {
for (; list; list = list->next) for (; list; list = list->next)
{ {
...@@ -2052,12 +1996,10 @@ write_aix_file (stream, list) ...@@ -2052,12 +1996,10 @@ write_aix_file (stream, list)
destructor table has the same format, and begins at __DTOR_LIST__. */ destructor table has the same format, and begins at __DTOR_LIST__. */
static void static void
scan_prog_file (prog_name, which_pass) scan_prog_file (const char *prog_name, enum pass which_pass)
const char *prog_name;
enum pass which_pass;
{ {
void (*int_handler) PARAMS ((int)); void (*int_handler) (int);
void (*quit_handler) PARAMS ((int)); void (*quit_handler) (int);
char *real_nm_argv[4]; char *real_nm_argv[4];
const char **nm_argv = (const char **) real_nm_argv; const char **nm_argv = (const char **) real_nm_argv;
int argc = 0; int argc = 0;
...@@ -2123,9 +2065,9 @@ scan_prog_file (prog_name, which_pass) ...@@ -2123,9 +2065,9 @@ scan_prog_file (prog_name, which_pass)
} }
/* Parent context from here on. */ /* Parent context from here on. */
int_handler = (void (*) PARAMS ((int))) signal (SIGINT, SIG_IGN); int_handler = (void (*) (int)) signal (SIGINT, SIG_IGN);
#ifdef SIGQUIT #ifdef SIGQUIT
quit_handler = (void (*) PARAMS ((int))) signal (SIGQUIT, SIG_IGN); quit_handler = (void (*) (int)) signal (SIGQUIT, SIG_IGN);
#endif #endif
if (close (pipe_fd[1]) < 0) if (close (pipe_fd[1]) < 0)
...@@ -2149,7 +2091,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -2149,7 +2091,7 @@ scan_prog_file (prog_name, which_pass)
if (ch != '_') if (ch != '_')
continue; continue;
name = p; name = p;
/* Find the end of the symbol name. /* Find the end of the symbol name.
Do not include `|', because Encore nm can tack that on the end. */ Do not include `|', because Encore nm can tack that on the end. */
...@@ -2229,8 +2171,8 @@ scan_prog_file (prog_name, which_pass) ...@@ -2229,8 +2171,8 @@ scan_prog_file (prog_name, which_pass)
#include <sys/dir.h> #include <sys/dir.h>
/* pointers to the object file */ /* pointers to the object file */
unsigned object; /* address of memory mapped file */ unsigned object; /* address of memory mapped file */
unsigned objsize; /* size of memory mapped to file */ unsigned objsize; /* size of memory mapped to file */
char * code; /* pointer to code segment */ char * code; /* pointer to code segment */
char * data; /* pointer to data segment */ char * data; /* pointer to data segment */
struct nlist *symtab; /* pointer to symbol table */ struct nlist *symtab; /* pointer to symbol table */
...@@ -2240,11 +2182,8 @@ struct head libraries; ...@@ -2240,11 +2182,8 @@ struct head libraries;
/* Map the file indicated by NAME into memory and store its address. */ /* Map the file indicated by NAME into memory and store its address. */
static void mapfile PARAMS ((const char *));
static void static void
mapfile (name) mapfile (const char *name)
const char *name;
{ {
int fp; int fp;
struct stat s; struct stat s;
...@@ -2266,11 +2205,8 @@ mapfile (name) ...@@ -2266,11 +2205,8 @@ mapfile (name)
static const char *libname; static const char *libname;
static int libselect PARAMS ((struct direct *));
static int static int
libselect (d) libselect (struct direct *d)
struct direct *d;
{ {
return (strncmp (libname, d->d_name, strlen (libname)) == 0); return (strncmp (libname, d->d_name, strlen (libname)) == 0);
} }
...@@ -2282,11 +2218,9 @@ libselect (d) ...@@ -2282,11 +2218,9 @@ libselect (d)
We must verify that the extension is numeric, because Sun saves the We must verify that the extension is numeric, because Sun saves the
original versions of patched libraries with a .FCS extension. Files with original versions of patched libraries with a .FCS extension. Files with
invalid extensions must go last in the sort, so that they will not be used. */ invalid extensions must go last in the sort, so that they will not be used. */
static int libcompare PARAMS ((struct direct **, struct direct **));
static int static int
libcompare (d1, d2) libcompare (struct direct **d1, struct direct **d2)
struct direct **d1, **d2;
{ {
int i1, i2 = strlen (libname); int i1, i2 = strlen (libname);
char *e1 = (*d1)->d_name + i2; char *e1 = (*d1)->d_name + i2;
...@@ -2327,11 +2261,9 @@ libcompare (d1, d2) ...@@ -2327,11 +2261,9 @@ libcompare (d1, d2)
/* Given the name NAME of a dynamic dependency, find its pathname and add /* Given the name NAME of a dynamic dependency, find its pathname and add
it to the list of libraries. */ it to the list of libraries. */
static void locatelib PARAMS ((const char *));
static void static void
locatelib (name) locatelib (const char *name)
const char *name;
{ {
static const char **l; static const char **l;
static int cnt; static int cnt;
...@@ -2344,7 +2276,7 @@ locatelib (name) ...@@ -2344,7 +2276,7 @@ locatelib (name)
char *ld_rules; char *ld_rules;
char *ldr = 0; char *ldr = 0;
/* counting elements in array, need 1 extra for null */ /* counting elements in array, need 1 extra for null */
cnt = 1; cnt = 1;
ld_rules = (char *) (ld_2->ld_rules + code); ld_rules = (char *) (ld_2->ld_rules + code);
if (ld_rules) if (ld_rules)
{ {
...@@ -2370,7 +2302,7 @@ locatelib (name) ...@@ -2370,7 +2302,7 @@ locatelib (name)
if (ldr) if (ldr)
{ {
*pp++ = ldr; *pp++ = ldr;
for (; *ldr != 0; ldr++) for (; *ldr != 0; ldr++)
if (*ldr == ':') if (*ldr == ':')
{ {
*ldr++ = 0; *ldr++ = 0;
...@@ -2380,7 +2312,7 @@ locatelib (name) ...@@ -2380,7 +2312,7 @@ locatelib (name)
if (q) if (q)
{ {
*pp++ = q; *pp++ = q;
for (; *q != 0; q++) for (; *q != 0; q++)
if (*q == ':') if (*q == ':')
{ {
*q++ = 0; *q++ = 0;
...@@ -2419,9 +2351,8 @@ locatelib (name) ...@@ -2419,9 +2351,8 @@ locatelib (name)
/* Scan the _DYNAMIC structure of the output file to find shared libraries /* Scan the _DYNAMIC structure of the output file to find shared libraries
that it depends upon and any constructors or destructors they contain. */ that it depends upon and any constructors or destructors they contain. */
static void static void
scan_libraries (prog_name) scan_libraries (const char *prog_name)
const char *prog_name;
{ {
struct exec *header; struct exec *header;
char *base; char *base;
...@@ -2494,14 +2425,13 @@ scan_libraries (prog_name) ...@@ -2494,14 +2425,13 @@ scan_libraries (prog_name)
the output file depends upon and their initialization/finalization the output file depends upon and their initialization/finalization
routines, if any. */ routines, if any. */
static void static void
scan_libraries (prog_name) scan_libraries (const char *prog_name)
const char *prog_name;
{ {
static struct head libraries; /* list of shared libraries found */ static struct head libraries; /* list of shared libraries found */
struct id *list; struct id *list;
void (*int_handler) PARAMS ((int)); void (*int_handler) (int);
void (*quit_handler) PARAMS ((int)); void (*quit_handler) (int);
char *real_ldd_argv[4]; char *real_ldd_argv[4];
const char **ldd_argv = (const char **) real_ldd_argv; const char **ldd_argv = (const char **) real_ldd_argv;
int argc = 0; int argc = 0;
...@@ -2564,9 +2494,9 @@ scan_libraries (prog_name) ...@@ -2564,9 +2494,9 @@ scan_libraries (prog_name)
} }
/* Parent context from here on. */ /* Parent context from here on. */
int_handler = (void (*) PARAMS ((int))) signal (SIGINT, SIG_IGN); int_handler = (void (*) (int))) signal (SIGINT, SIG_IGN;
#ifdef SIGQUIT #ifdef SIGQUIT
quit_handler = (void (*) PARAMS ((int))) signal (SIGQUIT, SIG_IGN); quit_handler = (void (*) (int))) signal (SIGQUIT, SIG_IGN;
#endif #endif
if (close (pipe_fd[1]) < 0) if (close (pipe_fd[1]) < 0)
...@@ -2591,7 +2521,7 @@ scan_libraries (prog_name) ...@@ -2591,7 +2521,7 @@ scan_libraries (prog_name)
fatal ("dynamic dependency %s not found", buf); fatal ("dynamic dependency %s not found", buf);
/* Find the end of the symbol name. */ /* Find the end of the symbol name. */
for (end = p; for (end = p;
(ch2 = *end) != '\0' && ch2 != '\n' && !ISSPACE (ch2) && ch2 != '|'; (ch2 = *end) != '\0' && ch2 != '\n' && !ISSPACE (ch2) && ch2 != '|';
end++) end++)
continue; continue;
...@@ -2696,10 +2626,9 @@ static const char *const aix_std_libs[] = { ...@@ -2696,10 +2626,9 @@ static const char *const aix_std_libs[] = {
/* This function checks the filename and returns 1 /* This function checks the filename and returns 1
if this name matches the location of a standard AIX library. */ if this name matches the location of a standard AIX library. */
static int ignore_library PARAMS ((const char *)); static int ignore_library (const char *);
static int static int
ignore_library (name) ignore_library (const char *name)
const char *name;
{ {
const char *const *p = &aix_std_libs[0]; const char *const *p = &aix_std_libs[0];
while (*p++ != NULL) while (*p++ != NULL)
...@@ -2709,7 +2638,7 @@ ignore_library (name) ...@@ -2709,7 +2638,7 @@ ignore_library (name)
#endif /* COLLECT_EXPORT_LIST */ #endif /* COLLECT_EXPORT_LIST */
#if defined (HAVE_DECL_LDGETNAME) && !HAVE_DECL_LDGETNAME #if defined (HAVE_DECL_LDGETNAME) && !HAVE_DECL_LDGETNAME
extern char *ldgetname PARAMS ((LDFILE *, GCC_SYMENT *)); extern char *ldgetname (LDFILE *, GCC_SYMENT *);
#endif #endif
/* COFF version to scan the name list of the loaded program for /* COFF version to scan the name list of the loaded program for
...@@ -2722,9 +2651,7 @@ extern char *ldgetname PARAMS ((LDFILE *, GCC_SYMENT *)); ...@@ -2722,9 +2651,7 @@ extern char *ldgetname PARAMS ((LDFILE *, GCC_SYMENT *));
destructor table has the same format, and begins at __DTOR_LIST__. */ destructor table has the same format, and begins at __DTOR_LIST__. */
static void static void
scan_prog_file (prog_name, which_pass) scan_prog_file (const char *prog_name, enum pass which_pass)
const char *prog_name;
enum pass which_pass;
{ {
LDFILE *ldptr = NULL; LDFILE *ldptr = NULL;
int sym_index, sym_count; int sym_index, sym_count;
...@@ -2834,7 +2761,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -2834,7 +2761,7 @@ scan_prog_file (prog_name, which_pass)
#ifdef COLLECT_EXPORT_LIST #ifdef COLLECT_EXPORT_LIST
/* If we are building a shared object on AIX we need /* If we are building a shared object on AIX we need
to explicitly export all global symbols. */ to explicitly export all global symbols. */
if (shared_obj) if (shared_obj)
{ {
if (which_pass == PASS_OBJ && (! export_flag)) if (which_pass == PASS_OBJ && (! export_flag))
add_to_list (&exports, name); add_to_list (&exports, name);
...@@ -2887,8 +2814,7 @@ scan_prog_file (prog_name, which_pass) ...@@ -2887,8 +2814,7 @@ scan_prog_file (prog_name, which_pass)
/* Given a library name without "lib" prefix, this function /* Given a library name without "lib" prefix, this function
returns a full library name including a path. */ returns a full library name including a path. */
static char * static char *
resolve_lib_name (name) resolve_lib_name (const char *name)
const char *name;
{ {
char *lib_buf; char *lib_buf;
int i, j, l = 0; int i, j, l = 0;
...@@ -2912,7 +2838,7 @@ resolve_lib_name (name) ...@@ -2912,7 +2838,7 @@ resolve_lib_name (name)
p = "/"; p = "/";
for (j = 0; libexts[j]; j++) for (j = 0; libexts[j]; j++)
{ {
sprintf (lib_buf, "%s%slib%s.%s", sprintf (lib_buf, "%s%slib%s.%s",
list->prefix, p, name, libexts[j]); list->prefix, p, name, libexts[j]);
if (debug) fprintf (stderr, "searching for: %s\n", lib_buf); if (debug) fprintf (stderr, "searching for: %s\n", lib_buf);
if (file_exists (lib_buf)) if (file_exists (lib_buf))
...@@ -2976,16 +2902,16 @@ struct file_info ...@@ -2976,16 +2902,16 @@ struct file_info
int use_mmap; /* != 0 if mmap'ed */ int use_mmap; /* != 0 if mmap'ed */
}; };
extern int decode_mach_o_hdr (); extern int decode_mach_o_hdr (void);
extern int encode_mach_o_hdr (); extern int encode_mach_o_hdr (void);
static void add_func_table PARAMS ((mo_header_t *, load_all_t *, static void add_func_table (mo_header_t *, load_all_t *, symbol_info_t *,
symbol_info_t *, int)); int);
static void print_header PARAMS ((mo_header_t *)); static void print_header (mo_header_t *);
static void print_load_command PARAMS ((load_union_t *, size_t, int)); static void print_load_command (load_union_t *, size_t, int);
static void bad_header PARAMS ((int)); static void bad_header (int);
static struct file_info *read_file PARAMS ((const char *, int, int)); static struct file_info *read_file (const char *, int, int);
static void end_file PARAMS ((struct file_info *)); static void end_file (struct file_info *);
/* OSF/rose specific version to scan the name list of the loaded /* OSF/rose specific version to scan the name list of the loaded
program for the symbols g++ uses for static constructors and program for the symbols g++ uses for static constructors and
...@@ -2998,9 +2924,7 @@ static void end_file PARAMS ((struct file_info *)); ...@@ -2998,9 +2924,7 @@ static void end_file PARAMS ((struct file_info *));
destructor table has the same format, and begins at __DTOR_LIST__. */ destructor table has the same format, and begins at __DTOR_LIST__. */
static void static void
scan_prog_file (prog_name, which_pass) scan_prog_file (const char *prog_name, enum pass which_pass)
const char *prog_name;
enum pass which_pass;
{ {
char *obj; char *obj;
mo_header_t hdr; mo_header_t hdr;
...@@ -3267,15 +3191,15 @@ scan_prog_file (prog_name, which_pass) ...@@ -3267,15 +3191,15 @@ scan_prog_file (prog_name, which_pass)
} }
/* Add a function table to the load commands to call a function /* Add a function table to the load commands to call a function on
on initiation or termination of the process. */ initiation or termination of the process. The function takes HDR_P
as pointer to the global header, LOAD_ARRAY as array of pointers to
load commands, SYM as pointer to symbol entry and the fntc_type
value TYPE. */
static void static void
add_func_table (hdr_p, load_array, sym, type) add_func_table (mo_header_t *hdr_p, load_all_t *load_array,
mo_header_t *hdr_p; /* pointer to global header */ symbol_info_t *sym, int type)
load_all_t *load_array; /* array of ptrs to load cmds */
symbol_info_t *sym; /* pointer to symbol entry */
int type; /* fntc_type value */
{ {
/* Add a new load command. */ /* Add a new load command. */
int num_cmds = ++hdr_p->moh_n_load_cmds; int num_cmds = ++hdr_p->moh_n_load_cmds;
...@@ -3350,8 +3274,7 @@ add_func_table (hdr_p, load_array, sym, type) ...@@ -3350,8 +3274,7 @@ add_func_table (hdr_p, load_array, sym, type)
/* Print the global header for an OSF/rose object. */ /* Print the global header for an OSF/rose object. */
static void static void
print_header (hdr_ptr) print_header (mo_header_t *hdr_ptr)
mo_header_t *hdr_ptr;
{ {
fprintf (stderr, "\nglobal header:\n"); fprintf (stderr, "\nglobal header:\n");
fprintf (stderr, "\tmoh_magic = 0x%.8lx\n", hdr_ptr->moh_magic); fprintf (stderr, "\tmoh_magic = 0x%.8lx\n", hdr_ptr->moh_magic);
...@@ -3393,10 +3316,7 @@ print_header (hdr_ptr) ...@@ -3393,10 +3316,7 @@ print_header (hdr_ptr)
/* Print a short summary of a load command. */ /* Print a short summary of a load command. */
static void static void
print_load_command (load_hdr, offset, number) print_load_command (load_union_t *load_hdr, size_t offset, int number)
load_union_t *load_hdr;
size_t offset;
int number;
{ {
mo_long_t type = load_hdr->hdr.ldci_cmd_type; mo_long_t type = load_hdr->hdr.ldci_cmd_type;
const char *type_str = (char *) 0; const char *type_str = (char *) 0;
...@@ -3460,8 +3380,7 @@ print_load_command (load_hdr, offset, number) ...@@ -3460,8 +3380,7 @@ print_load_command (load_hdr, offset, number)
/* Fatal error when {en,de}code_mach_o_header fails. */ /* Fatal error when {en,de}code_mach_o_header fails. */
static void static void
bad_header (status) bad_header (int status)
int status;
{ {
switch (status) switch (status)
{ {
...@@ -3477,13 +3396,12 @@ bad_header (status) ...@@ -3477,13 +3396,12 @@ bad_header (status)
} }
/* Read a file into a memory buffer. */ /* Read a file into a memory buffer. The file has filename NAME and is
opened with the file descriptor FD for read or write according to
RW. */
static struct file_info * static struct file_info *
read_file (name, fd, rw) read_file (const char *name, int fd, int rw)
const char *name; /* filename */
int fd; /* file descriptor */
int rw; /* read/write */
{ {
struct stat stat_pkt; struct stat stat_pkt;
struct file_info *p = (struct file_info *) xcalloc (sizeof (struct file_info), 1); struct file_info *p = (struct file_info *) xcalloc (sizeof (struct file_info), 1);
...@@ -3545,8 +3463,7 @@ read_file (name, fd, rw) ...@@ -3545,8 +3463,7 @@ read_file (name, fd, rw)
/* Do anything necessary to write a file back from memory. */ /* Do anything necessary to write a file back from memory. */
static void static void
end_file (ptr) end_file (struct file_info *pt)
struct file_info *ptr; /* file information block */
{ {
#ifdef USE_MMAP #ifdef USE_MMAP
if (ptr->use_mmap) if (ptr->use_mmap)
......
/* Header file for collect/tlink routines. /* Header file for collect/tlink routines.
Copyright (C) 1998 Free Software Foundation, Inc. Copyright (C) 1998, 2003 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -21,17 +21,17 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -21,17 +21,17 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#ifndef GCC_COLLECT2_H #ifndef GCC_COLLECT2_H
#define GCC_COLLECT2_H #define GCC_COLLECT2_H
extern void do_tlink PARAMS ((char **, char **)); extern void do_tlink (char **, char **);
extern void collect_execute PARAMS ((const char *, char **, const char *)); extern void collect_execute (const char *, char **, const char *);
extern void collect_exit PARAMS ((int)) ATTRIBUTE_NORETURN; extern void collect_exit (int) ATTRIBUTE_NORETURN;
extern int collect_wait PARAMS ((const char *)); extern int collect_wait (const char *);
extern void dump_file PARAMS ((const char *)); extern void dump_file (const char *);
extern int file_exists PARAMS ((const char *)); extern int file_exists (const char *);
extern const char *ldout; extern const char *ldout;
extern const char *c_file_name; extern const char *c_file_name;
...@@ -39,12 +39,11 @@ extern struct obstack temporary_obstack; ...@@ -39,12 +39,11 @@ extern struct obstack temporary_obstack;
extern char *temporary_firstobj; extern char *temporary_firstobj;
extern int vflag, debug; extern int vflag, debug;
extern void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN; extern void fancy_abort (void) ATTRIBUTE_NORETURN;
extern void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; extern void error (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void notice PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; extern void notice (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void fatal PARAMS ((const char *, ...)) extern void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; extern void fatal_perror (const char *, ...)
extern void fatal_perror PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN; ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
#endif /* ! GCC_COLLECT2_H */ #endif /* ! GCC_COLLECT2_H */
/* Register conflict graph computation routines. /* Register conflict graph computation routines.
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000, 2003 Free Software Foundation, Inc.
Contributed by CodeSourcery, LLC Contributed by CodeSourcery, LLC
This file is part of GCC. This file is part of GCC.
...@@ -114,17 +114,16 @@ struct conflict_graph_def ...@@ -114,17 +114,16 @@ struct conflict_graph_def
R1 and R2. R1 is assumed to be smaller or equal to R2. */ R1 and R2. R1 is assumed to be smaller or equal to R2. */
#define CONFLICT_HASH_FN(R1, R2) ((R2) * ((R2) - 1) / 2 + (R1)) #define CONFLICT_HASH_FN(R1, R2) ((R2) * ((R2) - 1) / 2 + (R1))
static hashval_t arc_hash PARAMS ((const void *)); static hashval_t arc_hash (const void *);
static int arc_eq PARAMS ((const void *, const void *)); static int arc_eq (const void *, const void *);
static int print_conflict PARAMS ((int, int, void *)); static int print_conflict (int, int, void *);
static void mark_reg PARAMS ((rtx, rtx, void *)); static void mark_reg (rtx, rtx, void *);
/* Callback function to compute the hash value of an arc. Uses /* Callback function to compute the hash value of an arc. Uses
current_graph to locate the graph to which the arc belongs. */ current_graph to locate the graph to which the arc belongs. */
static hashval_t static hashval_t
arc_hash (arcp) arc_hash (const void *arcp)
const void *arcp;
{ {
const_conflict_graph_arc arc = (const_conflict_graph_arc) arcp; const_conflict_graph_arc arc = (const_conflict_graph_arc) arcp;
...@@ -135,9 +134,7 @@ arc_hash (arcp) ...@@ -135,9 +134,7 @@ arc_hash (arcp)
table. */ table. */
static int static int
arc_eq (arcp1, arcp2) arc_eq (const void *arcp1, const void *arcp2)
const void *arcp1;
const void *arcp2;
{ {
const_conflict_graph_arc arc1 = (const_conflict_graph_arc) arcp1; const_conflict_graph_arc arc1 = (const_conflict_graph_arc) arcp1;
const_conflict_graph_arc arc2 = (const_conflict_graph_arc) arcp2; const_conflict_graph_arc arc2 = (const_conflict_graph_arc) arcp2;
...@@ -149,8 +146,7 @@ arc_eq (arcp1, arcp2) ...@@ -149,8 +146,7 @@ arc_eq (arcp1, arcp2)
registers. */ registers. */
conflict_graph conflict_graph
conflict_graph_new (num_regs) conflict_graph_new (int num_regs)
int num_regs;
{ {
conflict_graph graph conflict_graph graph
= (conflict_graph) xmalloc (sizeof (struct conflict_graph_def)); = (conflict_graph) xmalloc (sizeof (struct conflict_graph_def));
...@@ -175,8 +171,7 @@ conflict_graph_new (num_regs) ...@@ -175,8 +171,7 @@ conflict_graph_new (num_regs)
/* Deletes a conflict graph. */ /* Deletes a conflict graph. */
void void
conflict_graph_delete (graph) conflict_graph_delete (conflict_graph graph)
conflict_graph graph;
{ {
obstack_free (&graph->arc_obstack, NULL); obstack_free (&graph->arc_obstack, NULL);
htab_delete (graph->arc_hash_table); htab_delete (graph->arc_hash_table);
...@@ -189,10 +184,7 @@ conflict_graph_delete (graph) ...@@ -189,10 +184,7 @@ conflict_graph_delete (graph)
in GRAPH, in which case it does nothing and returns zero. */ in GRAPH, in which case it does nothing and returns zero. */
int int
conflict_graph_add (graph, reg1, reg2) conflict_graph_add (conflict_graph graph, int reg1, int reg2)
conflict_graph graph;
int reg1;
int reg2;
{ {
int smaller = MIN (reg1, reg2); int smaller = MIN (reg1, reg2);
int larger = MAX (reg1, reg2); int larger = MAX (reg1, reg2);
...@@ -238,10 +230,7 @@ conflict_graph_add (graph, reg1, reg2) ...@@ -238,10 +230,7 @@ conflict_graph_add (graph, reg1, reg2)
and REG2. */ and REG2. */
int int
conflict_graph_conflict_p (graph, reg1, reg2) conflict_graph_conflict_p (conflict_graph graph, int reg1, int reg2)
conflict_graph graph;
int reg1;
int reg2;
{ {
/* Build an arc to search for. */ /* Build an arc to search for. */
struct conflict_graph_arc_def arc; struct conflict_graph_arc_def arc;
...@@ -255,11 +244,8 @@ conflict_graph_conflict_p (graph, reg1, reg2) ...@@ -255,11 +244,8 @@ conflict_graph_conflict_p (graph, reg1, reg2)
passed back to ENUM_FN. */ passed back to ENUM_FN. */
void void
conflict_graph_enum (graph, reg, enum_fn, extra) conflict_graph_enum (conflict_graph graph, int reg,
conflict_graph graph; conflict_graph_enum_fn enum_fn, void *extra)
int reg;
conflict_graph_enum_fn enum_fn;
void *extra;
{ {
conflict_graph_arc arc = graph->neighbor_heads[reg]; conflict_graph_arc arc = graph->neighbor_heads[reg];
while (arc != NULL) while (arc != NULL)
...@@ -282,10 +268,7 @@ conflict_graph_enum (graph, reg, enum_fn, extra) ...@@ -282,10 +268,7 @@ conflict_graph_enum (graph, reg, enum_fn, extra)
conflict to GRAPH between x and TARGET. */ conflict to GRAPH between x and TARGET. */
void void
conflict_graph_merge_regs (graph, target, src) conflict_graph_merge_regs (conflict_graph graph, int target, int src)
conflict_graph graph;
int target;
int src;
{ {
conflict_graph_arc arc = graph->neighbor_heads[src]; conflict_graph_arc arc = graph->neighbor_heads[src];
...@@ -328,10 +311,7 @@ struct print_context ...@@ -328,10 +311,7 @@ struct print_context
/* Callback function when enumerating conflicts during printing. */ /* Callback function when enumerating conflicts during printing. */
static int static int
print_conflict (reg1, reg2, contextp) print_conflict (int reg1, int reg2, void *contextp)
int reg1;
int reg2;
void *contextp;
{ {
struct print_context *context = (struct print_context *) contextp; struct print_context *context = (struct print_context *) contextp;
int reg; int reg;
...@@ -363,9 +343,7 @@ print_conflict (reg1, reg2, contextp) ...@@ -363,9 +343,7 @@ print_conflict (reg1, reg2, contextp)
/* Prints the conflicts in GRAPH to FP. */ /* Prints the conflicts in GRAPH to FP. */
void void
conflict_graph_print (graph, fp) conflict_graph_print (conflict_graph graph, FILE *fp)
conflict_graph graph;
FILE *fp;
{ {
int reg; int reg;
struct print_context context; struct print_context context;
...@@ -394,10 +372,7 @@ conflict_graph_print (graph, fp) ...@@ -394,10 +372,7 @@ conflict_graph_print (graph, fp)
/* Callback function for note_stores. */ /* Callback function for note_stores. */
static void static void
mark_reg (reg, setter, data) mark_reg (rtx reg, rtx setter ATTRIBUTE_UNUSED, void *data)
rtx reg;
rtx setter ATTRIBUTE_UNUSED;
void *data;
{ {
regset set = (regset) data; regset set = (regset) data;
...@@ -441,9 +416,7 @@ mark_reg (reg, setter, data) ...@@ -441,9 +416,7 @@ mark_reg (reg, setter, data)
canonical regs instead. */ canonical regs instead. */
conflict_graph conflict_graph
conflict_graph_compute (regs, p) conflict_graph_compute (regset regs, partition p)
regset regs;
partition p;
{ {
conflict_graph graph = conflict_graph_new (max_reg_num ()); conflict_graph graph = conflict_graph_new (max_reg_num ());
regset_head live_head; regset_head live_head;
......
...@@ -39,8 +39,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -39,8 +39,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
in other cases error is called. */ in other cases error is called. */
tree tree
convert_to_pointer (type, expr) convert_to_pointer (tree type, tree expr)
tree type, expr;
{ {
if (integer_zerop (expr)) if (integer_zerop (expr))
{ {
...@@ -75,8 +74,7 @@ convert_to_pointer (type, expr) ...@@ -75,8 +74,7 @@ convert_to_pointer (type, expr)
/* Avoid any floating point extensions from EXP. */ /* Avoid any floating point extensions from EXP. */
tree tree
strip_float_extensions (exp) strip_float_extensions (tree exp)
tree exp;
{ {
tree sub, expt, subt; tree sub, expt, subt;
...@@ -124,8 +122,7 @@ strip_float_extensions (exp) ...@@ -124,8 +122,7 @@ strip_float_extensions (exp)
in other cases error is called. */ in other cases error is called. */
tree tree
convert_to_real (type, expr) convert_to_real (tree type, tree expr)
tree type, expr;
{ {
enum built_in_function fcode = builtin_mathfn_code (expr); enum built_in_function fcode = builtin_mathfn_code (expr);
tree itype = TREE_TYPE (expr); tree itype = TREE_TYPE (expr);
...@@ -194,9 +191,9 @@ convert_to_real (type, expr) ...@@ -194,9 +191,9 @@ convert_to_real (type, expr)
if (fn) if (fn)
{ {
tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr, tree arg0 = strip_float_extensions (TREE_VALUE (TREE_OPERAND (expr,
1))); 1)));
tree arglist = build_tree_list (NULL_TREE, tree arglist = build_tree_list (NULL_TREE,
fold (convert_to_real (type, arg0))); fold (convert_to_real (type, arg0)));
return build_function_call_expr (fn, arglist); return build_function_call_expr (fn, arglist);
} }
...@@ -285,8 +282,7 @@ convert_to_real (type, expr) ...@@ -285,8 +282,7 @@ convert_to_real (type, expr)
not in use in any existing structure. */ not in use in any existing structure. */
tree tree
convert_to_integer (type, expr) convert_to_integer (tree type, tree expr)
tree type, expr;
{ {
enum tree_code ex_form = TREE_CODE (expr); enum tree_code ex_form = TREE_CODE (expr);
tree intype = TREE_TYPE (expr); tree intype = TREE_TYPE (expr);
...@@ -483,7 +479,7 @@ convert_to_integer (type, expr) ...@@ -483,7 +479,7 @@ convert_to_integer (type, expr)
/* Don't do unsigned arithmetic where signed was wanted, /* Don't do unsigned arithmetic where signed was wanted,
or vice versa. or vice versa.
Exception: if both of the original operands were Exception: if both of the original operands were
unsigned then we can safely do the work as unsigned. unsigned then we can safely do the work as unsigned.
Exception: shift operations take their type solely Exception: shift operations take their type solely
from the first argument. from the first argument.
Exception: the LSHIFT_EXPR case above requires that Exception: the LSHIFT_EXPR case above requires that
...@@ -558,7 +554,7 @@ convert_to_integer (type, expr) ...@@ -558,7 +554,7 @@ convert_to_integer (type, expr)
/* It is sometimes worthwhile to push the narrowing down through /* It is sometimes worthwhile to push the narrowing down through
the conditional and never loses. */ the conditional and never loses. */
return fold (build (COND_EXPR, type, TREE_OPERAND (expr, 0), return fold (build (COND_EXPR, type, TREE_OPERAND (expr, 0),
convert (type, TREE_OPERAND (expr, 1)), convert (type, TREE_OPERAND (expr, 1)),
convert (type, TREE_OPERAND (expr, 2)))); convert (type, TREE_OPERAND (expr, 2))));
default: default:
...@@ -593,11 +589,10 @@ convert_to_integer (type, expr) ...@@ -593,11 +589,10 @@ convert_to_integer (type, expr)
/* Convert EXPR to the complex type TYPE in the usual ways. */ /* Convert EXPR to the complex type TYPE in the usual ways. */
tree tree
convert_to_complex (type, expr) convert_to_complex (tree type, tree expr)
tree type, expr;
{ {
tree subtype = TREE_TYPE (type); tree subtype = TREE_TYPE (type);
switch (TREE_CODE (TREE_TYPE (expr))) switch (TREE_CODE (TREE_TYPE (expr)))
{ {
case REAL_TYPE: case REAL_TYPE:
...@@ -649,8 +644,7 @@ convert_to_complex (type, expr) ...@@ -649,8 +644,7 @@ convert_to_complex (type, expr)
/* Convert EXPR to the vector type TYPE in the usual ways. */ /* Convert EXPR to the vector type TYPE in the usual ways. */
tree tree
convert_to_vector (type, expr) convert_to_vector (tree type, tree expr)
tree type, expr;
{ {
switch (TREE_CODE (TREE_TYPE (expr))) switch (TREE_CODE (TREE_TYPE (expr)))
{ {
......
/* Definition of functions in convert.c. /* Definition of functions in convert.c.
Copyright (C) 1993, 2000 Free Software Foundation, Inc. Copyright (C) 1993, 2000, 2003 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -18,8 +18,8 @@ along with GCC; see the file COPYING. If not, write to the Free ...@@ -18,8 +18,8 @@ along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */ 02111-1307, USA. */
extern tree convert_to_integer PARAMS ((tree, tree)); extern tree convert_to_integer (tree, tree);
extern tree convert_to_pointer PARAMS ((tree, tree)); extern tree convert_to_pointer (tree, tree);
extern tree convert_to_real PARAMS ((tree, tree)); extern tree convert_to_real (tree, tree);
extern tree convert_to_complex PARAMS ((tree, tree)); extern tree convert_to_complex (tree, tree);
extern tree convert_to_vector PARAMS ((tree, tree)); extern tree convert_to_vector (tree, tree);
...@@ -49,8 +49,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -49,8 +49,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
struct function_list struct function_list
{ {
struct function_list *next; /* next function */ struct function_list *next; /* next function */
unsigned ident; /* function ident */ unsigned ident; /* function ident */
unsigned checksum; /* function checksum */ unsigned checksum; /* function checksum */
unsigned n_ctrs[GCOV_COUNTERS];/* number of counters. */ unsigned n_ctrs[GCOV_COUNTERS];/* number of counters. */
}; };
...@@ -61,7 +61,7 @@ typedef struct counts_entry ...@@ -61,7 +61,7 @@ typedef struct counts_entry
/* We hash by */ /* We hash by */
unsigned ident; unsigned ident;
unsigned ctr; unsigned ctr;
/* Store */ /* Store */
unsigned checksum; unsigned checksum;
gcov_type *counts; gcov_type *counts;
...@@ -69,7 +69,7 @@ typedef struct counts_entry ...@@ -69,7 +69,7 @@ typedef struct counts_entry
/* Workspace */ /* Workspace */
struct counts_entry *chain; struct counts_entry *chain;
} counts_entry_t; } counts_entry_t;
static struct function_list *functions_head = 0; static struct function_list *functions_head = 0;
...@@ -104,23 +104,22 @@ static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIO ...@@ -104,23 +104,22 @@ static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIO
static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES; static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES;
/* Forward declarations. */ /* Forward declarations. */
static hashval_t htab_counts_entry_hash PARAMS ((const void *)); static hashval_t htab_counts_entry_hash (const void *);
static int htab_counts_entry_eq PARAMS ((const void *, const void *)); static int htab_counts_entry_eq (const void *, const void *);
static void htab_counts_entry_del PARAMS ((void *)); static void htab_counts_entry_del (void *);
static void read_counts_file PARAMS ((void)); static void read_counts_file (void);
static unsigned compute_checksum PARAMS ((void)); static unsigned compute_checksum (void);
static unsigned checksum_string PARAMS ((unsigned, const char *)); static unsigned checksum_string (unsigned, const char *);
static tree build_fn_info_type PARAMS ((unsigned)); static tree build_fn_info_type (unsigned);
static tree build_fn_info_value PARAMS ((const struct function_list *, tree)); static tree build_fn_info_value (const struct function_list *, tree);
static tree build_ctr_info_type PARAMS ((void)); static tree build_ctr_info_type (void);
static tree build_ctr_info_value PARAMS ((unsigned, tree)); static tree build_ctr_info_value (unsigned, tree);
static tree build_gcov_info PARAMS ((void)); static tree build_gcov_info (void);
static void create_coverage PARAMS ((void)); static void create_coverage (void);
static hashval_t static hashval_t
htab_counts_entry_hash (of) htab_counts_entry_hash (const void *of)
const void *of;
{ {
const counts_entry_t *entry = of; const counts_entry_t *entry = of;
...@@ -128,9 +127,7 @@ htab_counts_entry_hash (of) ...@@ -128,9 +127,7 @@ htab_counts_entry_hash (of)
} }
static int static int
htab_counts_entry_eq (of1, of2) htab_counts_entry_eq (const void *of1, const void *of2)
const void *of1;
const void *of2;
{ {
const counts_entry_t *entry1 = of1; const counts_entry_t *entry1 = of1;
const counts_entry_t *entry2 = of2; const counts_entry_t *entry2 = of2;
...@@ -139,8 +136,7 @@ htab_counts_entry_eq (of1, of2) ...@@ -139,8 +136,7 @@ htab_counts_entry_eq (of1, of2)
} }
static void static void
htab_counts_entry_del (of) htab_counts_entry_del (void *of)
void *of;
{ {
counts_entry_t *entry = of; counts_entry_t *entry = of;
...@@ -151,7 +147,7 @@ htab_counts_entry_del (of) ...@@ -151,7 +147,7 @@ htab_counts_entry_del (of)
/* Read in the counts file, if available. */ /* Read in the counts file, if available. */
static void static void
read_counts_file () read_counts_file (void)
{ {
gcov_unsigned_t fn_ident = 0; gcov_unsigned_t fn_ident = 0;
gcov_unsigned_t version, checksum = -1; gcov_unsigned_t version, checksum = -1;
...@@ -163,7 +159,7 @@ read_counts_file () ...@@ -163,7 +159,7 @@ read_counts_file ()
if (!gcov_open (da_file_name, 1)) if (!gcov_open (da_file_name, 1))
return; return;
if (gcov_read_unsigned () != GCOV_DATA_MAGIC) if (gcov_read_unsigned () != GCOV_DATA_MAGIC)
{ {
warning ("`%s' is not a gcov data file", da_file_name); warning ("`%s' is not a gcov data file", da_file_name);
...@@ -174,7 +170,7 @@ read_counts_file () ...@@ -174,7 +170,7 @@ read_counts_file ()
{ {
char v[4], e[4]; char v[4], e[4];
gcov_unsigned_t required = GCOV_VERSION; gcov_unsigned_t required = GCOV_VERSION;
for (ix = 4; ix--; required >>= 8, version >>= 8) for (ix = 4; ix--; required >>= 8, version >>= 8)
{ {
v[ix] = version; v[ix] = version;
...@@ -185,7 +181,7 @@ read_counts_file () ...@@ -185,7 +181,7 @@ read_counts_file ()
gcov_close (); gcov_close ();
return; return;
} }
counts_hash = htab_create (10, counts_hash = htab_create (10,
htab_counts_entry_hash, htab_counts_entry_eq, htab_counts_entry_hash, htab_counts_entry_eq,
htab_counts_entry_del); htab_counts_entry_del);
...@@ -193,7 +189,7 @@ read_counts_file () ...@@ -193,7 +189,7 @@ read_counts_file ()
{ {
gcov_unsigned_t length; gcov_unsigned_t length;
gcov_position_t offset; gcov_position_t offset;
length = gcov_read_unsigned (); length = gcov_read_unsigned ();
offset = gcov_position (); offset = gcov_position ();
if (tag == GCOV_TAG_FUNCTION) if (tag == GCOV_TAG_FUNCTION)
...@@ -206,7 +202,7 @@ read_counts_file () ...@@ -206,7 +202,7 @@ read_counts_file ()
new function begins a new set of program runs. We new function begins a new set of program runs. We
must unlink the summaried chain. */ must unlink the summaried chain. */
counts_entry_t *entry, *chain; counts_entry_t *entry, *chain;
for (entry = summaried; entry; entry = chain) for (entry = summaried; entry; entry = chain)
{ {
chain = entry->chain; chain = entry->chain;
...@@ -220,13 +216,13 @@ read_counts_file () ...@@ -220,13 +216,13 @@ read_counts_file ()
{ {
counts_entry_t *entry; counts_entry_t *entry;
struct gcov_summary summary; struct gcov_summary summary;
gcov_read_summary (&summary); gcov_read_summary (&summary);
seen_summary = 1; seen_summary = 1;
for (entry = summaried; entry; entry = entry->chain) for (entry = summaried; entry; entry = entry->chain)
{ {
struct gcov_ctr_summary *csum = &summary.ctrs[entry->ctr]; struct gcov_ctr_summary *csum = &summary.ctrs[entry->ctr];
entry->summary.runs += csum->runs; entry->summary.runs += csum->runs;
entry->summary.sum_all += csum->sum_all; entry->summary.sum_all += csum->sum_all;
if (entry->summary.run_max < csum->run_max) if (entry->summary.run_max < csum->run_max)
...@@ -271,8 +267,8 @@ read_counts_file () ...@@ -271,8 +267,8 @@ read_counts_file ()
if (elt.ctr < GCOV_COUNTERS_SUMMABLE if (elt.ctr < GCOV_COUNTERS_SUMMABLE
/* This should always be true for a just allocated entry, /* This should always be true for a just allocated entry,
and always false for an existing one. Check this way, in and always false for an existing one. Check this way, in
case the gcov file is corrupt. */ case the gcov file is corrupt. */
&& (!entry->chain || summaried != entry)) && (!entry->chain || summaried != entry))
{ {
entry->chain = summaried; entry->chain = summaried;
...@@ -293,7 +289,7 @@ read_counts_file () ...@@ -293,7 +289,7 @@ read_counts_file ()
da_file_name); da_file_name);
htab_delete (counts_hash); htab_delete (counts_hash);
} }
gcov_close (); gcov_close ();
} }
...@@ -325,7 +321,7 @@ get_coverage_counts (unsigned counter, unsigned expected, ...@@ -325,7 +321,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
(DECL_ASSEMBLER_NAME (current_function_decl))); (DECL_ASSEMBLER_NAME (current_function_decl)));
return 0; return 0;
} }
if (expected != entry->summary.num if (expected != entry->summary.num
|| compute_checksum () != entry->checksum) || compute_checksum () != entry->checksum)
{ {
...@@ -333,7 +329,7 @@ get_coverage_counts (unsigned counter, unsigned expected, ...@@ -333,7 +329,7 @@ get_coverage_counts (unsigned counter, unsigned expected,
(DECL_ASSEMBLER_NAME (current_function_decl))); (DECL_ASSEMBLER_NAME (current_function_decl)));
return NULL; return NULL;
} }
if (summary) if (summary)
*summary = &entry->summary; *summary = &entry->summary;
...@@ -348,15 +344,15 @@ coverage_counter_alloc (unsigned counter, unsigned num) ...@@ -348,15 +344,15 @@ coverage_counter_alloc (unsigned counter, unsigned num)
{ {
if (no_coverage) if (no_coverage)
return 0; return 0;
if (!num) if (!num)
return 1; return 1;
if (!ctr_labels[counter]) if (!ctr_labels[counter])
{ {
/* Generate and save a copy of this so it can be shared. */ /* Generate and save a copy of this so it can be shared. */
char buf[20]; char buf[20];
ASM_GENERATE_INTERNAL_LABEL (buf, "LPBX", counter + 1); ASM_GENERATE_INTERNAL_LABEL (buf, "LPBX", counter + 1);
ctr_labels[counter] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf)); ctr_labels[counter] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
} }
...@@ -399,21 +395,21 @@ checksum_string (unsigned chksum, const char *string) ...@@ -399,21 +395,21 @@ checksum_string (unsigned chksum, const char *string)
for (ix = 8; ix--; value <<= 1) for (ix = 8; ix--; value <<= 1)
{ {
unsigned feedback; unsigned feedback;
feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0; feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0;
chksum <<= 1; chksum <<= 1;
chksum ^= feedback; chksum ^= feedback;
} }
} }
while (*string++); while (*string++);
return chksum; return chksum;
} }
/* Compute checksum for the current function. We generate a CRC32. */ /* Compute checksum for the current function. We generate a CRC32. */
static unsigned static unsigned
compute_checksum () compute_checksum (void)
{ {
unsigned chksum = DECL_SOURCE_LINE (current_function_decl); unsigned chksum = DECL_SOURCE_LINE (current_function_decl);
...@@ -430,17 +426,17 @@ compute_checksum () ...@@ -430,17 +426,17 @@ compute_checksum ()
should be output. */ should be output. */
int int
coverage_begin_output () coverage_begin_output (void)
{ {
if (no_coverage) if (no_coverage)
return 0; return 0;
if (!bbg_function_announced) if (!bbg_function_announced)
{ {
const char *file = DECL_SOURCE_FILE (current_function_decl); const char *file = DECL_SOURCE_FILE (current_function_decl);
unsigned line = DECL_SOURCE_LINE (current_function_decl); unsigned line = DECL_SOURCE_LINE (current_function_decl);
unsigned long offset; unsigned long offset;
if (!bbg_file_opened) if (!bbg_file_opened)
{ {
if (!gcov_open (bbg_file_name, -1)) if (!gcov_open (bbg_file_name, -1))
...@@ -452,7 +448,7 @@ coverage_begin_output () ...@@ -452,7 +448,7 @@ coverage_begin_output ()
} }
bbg_file_opened = 1; bbg_file_opened = 1;
} }
/* Announce function */ /* Announce function */
offset = gcov_write_tag (GCOV_TAG_FUNCTION); offset = gcov_write_tag (GCOV_TAG_FUNCTION);
gcov_write_unsigned (current_function_funcdef_no + 1); gcov_write_unsigned (current_function_funcdef_no + 1);
...@@ -472,12 +468,12 @@ coverage_begin_output () ...@@ -472,12 +468,12 @@ coverage_begin_output ()
error has occurred. Save function coverage counts. */ error has occurred. Save function coverage counts. */
void void
coverage_end_function () coverage_end_function (void)
{ {
unsigned i; unsigned i;
if (bbg_file_opened > 1 && gcov_is_error ()) if (bbg_file_opened > 1 && gcov_is_error ())
{ {
warning ("error writing `%s'", bbg_file_name); warning ("error writing `%s'", bbg_file_name);
bbg_file_opened = -1; bbg_file_opened = -1;
} }
...@@ -485,12 +481,12 @@ coverage_end_function () ...@@ -485,12 +481,12 @@ coverage_end_function ()
if (fn_ctr_mask) if (fn_ctr_mask)
{ {
struct function_list *item; struct function_list *item;
item = xmalloc (sizeof (struct function_list)); item = xmalloc (sizeof (struct function_list));
*functions_tail = item; *functions_tail = item;
functions_tail = &item->next; functions_tail = &item->next;
item->next = 0; item->next = 0;
item->ident = current_function_funcdef_no + 1; item->ident = current_function_funcdef_no + 1;
item->checksum = compute_checksum (); item->checksum = compute_checksum ();
...@@ -509,13 +505,12 @@ coverage_end_function () ...@@ -509,13 +505,12 @@ coverage_end_function ()
/* Creates the gcov_fn_info RECORD_TYPE. */ /* Creates the gcov_fn_info RECORD_TYPE. */
static tree static tree
build_fn_info_type (counters) build_fn_info_type (unsigned int counters)
unsigned counters;
{ {
tree type = (*lang_hooks.types.make_type) (RECORD_TYPE); tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
tree field, fields; tree field, fields;
tree array_type; tree array_type;
/* ident */ /* ident */
fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node); fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
...@@ -526,7 +521,7 @@ build_fn_info_type (counters) ...@@ -526,7 +521,7 @@ build_fn_info_type (counters)
array_type = build_index_type (build_int_2 (counters - 1, 0)); array_type = build_index_type (build_int_2 (counters - 1, 0));
array_type = build_array_type (unsigned_type_node, array_type); array_type = build_array_type (unsigned_type_node, array_type);
/* counters */ /* counters */
field = build_decl (FIELD_DECL, NULL_TREE, array_type); field = build_decl (FIELD_DECL, NULL_TREE, array_type);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
...@@ -542,51 +537,49 @@ build_fn_info_type (counters) ...@@ -542,51 +537,49 @@ build_fn_info_type (counters)
RECORD_TYPE. */ RECORD_TYPE. */
static tree static tree
build_fn_info_value (function, type) build_fn_info_value (const struct function_list *function, tree type)
const struct function_list *function;
tree type;
{ {
tree value = NULL_TREE; tree value = NULL_TREE;
tree fields = TYPE_FIELDS (type); tree fields = TYPE_FIELDS (type);
unsigned ix; unsigned ix;
tree array_value = NULL_TREE; tree array_value = NULL_TREE;
/* ident */ /* ident */
value = tree_cons (fields, value = tree_cons (fields,
convert (unsigned_intSI_type_node, convert (unsigned_intSI_type_node,
build_int_2 (function->ident, 0)), build_int_2 (function->ident, 0)),
value); value);
fields = TREE_CHAIN (fields); fields = TREE_CHAIN (fields);
/* checksum */ /* checksum */
value = tree_cons (fields, value = tree_cons (fields,
convert (unsigned_intSI_type_node, convert (unsigned_intSI_type_node,
build_int_2 (function->checksum, 0)), build_int_2 (function->checksum, 0)),
value); value);
fields = TREE_CHAIN (fields); fields = TREE_CHAIN (fields);
/* counters */ /* counters */
for (ix = 0; ix != GCOV_COUNTERS; ix++) for (ix = 0; ix != GCOV_COUNTERS; ix++)
if (prg_ctr_mask & (1 << ix)) if (prg_ctr_mask & (1 << ix))
{ {
tree counters = convert (unsigned_type_node, tree counters = convert (unsigned_type_node,
build_int_2 (function->n_ctrs[ix], 0)); build_int_2 (function->n_ctrs[ix], 0));
array_value = tree_cons (NULL_TREE, counters, array_value); array_value = tree_cons (NULL_TREE, counters, array_value);
} }
array_value = build_constructor (TREE_TYPE (fields), nreverse (array_value)); array_value = build_constructor (TREE_TYPE (fields), nreverse (array_value));
value = tree_cons (fields, array_value, value); value = tree_cons (fields, array_value, value);
value = build_constructor (type, nreverse (value)); value = build_constructor (type, nreverse (value));
return value; return value;
} }
/* Creates the gcov_ctr_info RECORD_TYPE. */ /* Creates the gcov_ctr_info RECORD_TYPE. */
static tree static tree
build_ctr_info_type () build_ctr_info_type (void)
{ {
tree type = (*lang_hooks.types.make_type) (RECORD_TYPE); tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
tree field, fields = NULL_TREE; tree field, fields = NULL_TREE;
...@@ -623,9 +616,7 @@ build_ctr_info_type () ...@@ -623,9 +616,7 @@ build_ctr_info_type ()
RECORD_TYPE. */ RECORD_TYPE. */
static tree static tree
build_ctr_info_value (counter, type) build_ctr_info_value (unsigned int counter, tree type)
unsigned counter;
tree type;
{ {
tree value = NULL_TREE; tree value = NULL_TREE;
tree fields = TYPE_FIELDS (type); tree fields = TYPE_FIELDS (type);
...@@ -641,16 +632,16 @@ build_ctr_info_value (counter, type) ...@@ -641,16 +632,16 @@ build_ctr_info_value (counter, type)
if (prg_n_ctrs[counter]) if (prg_n_ctrs[counter])
{ {
tree array_type, array; tree array_type, array;
array_type = build_index_type (build_int_2 (prg_n_ctrs[counter] - 1, 0)); array_type = build_index_type (build_int_2 (prg_n_ctrs[counter] - 1, 0));
array_type = build_array_type (TREE_TYPE (TREE_TYPE (fields)), array_type = build_array_type (TREE_TYPE (TREE_TYPE (fields)),
array_type); array_type);
array = build (VAR_DECL, array_type, NULL_TREE, NULL_TREE); array = build (VAR_DECL, array_type, NULL_TREE, NULL_TREE);
TREE_STATIC (array) = 1; TREE_STATIC (array) = 1;
DECL_NAME (array) = get_identifier (XSTR (ctr_labels[counter], 0)); DECL_NAME (array) = get_identifier (XSTR (ctr_labels[counter], 0));
assemble_variable (array, 0, 0, 0); assemble_variable (array, 0, 0, 0);
value = tree_cons (fields, value = tree_cons (fields,
build1 (ADDR_EXPR, TREE_TYPE (fields), array), build1 (ADDR_EXPR, TREE_TYPE (fields), array),
value); value);
...@@ -671,7 +662,7 @@ build_ctr_info_value (counter, type) ...@@ -671,7 +662,7 @@ build_ctr_info_value (counter, type)
value); value);
value = build_constructor (type, nreverse (value)); value = build_constructor (type, nreverse (value));
return value; return value;
} }
...@@ -679,7 +670,7 @@ build_ctr_info_value (counter, type) ...@@ -679,7 +670,7 @@ build_ctr_info_value (counter, type)
CONSTRUCTOR. */ CONSTRUCTOR. */
static tree static tree
build_gcov_info () build_gcov_info (void)
{ {
unsigned n_ctr_types, ix; unsigned n_ctr_types, ix;
tree type, const_type; tree type, const_type;
...@@ -694,15 +685,15 @@ build_gcov_info () ...@@ -694,15 +685,15 @@ build_gcov_info ()
unsigned n_fns; unsigned n_fns;
const struct function_list *fn; const struct function_list *fn;
tree string_type; tree string_type;
/* Count the number of active counters. */ /* Count the number of active counters. */
for (n_ctr_types = 0, ix = 0; ix != GCOV_COUNTERS; ix++) for (n_ctr_types = 0, ix = 0; ix != GCOV_COUNTERS; ix++)
if (prg_ctr_mask & (1 << ix)) if (prg_ctr_mask & (1 << ix))
n_ctr_types++; n_ctr_types++;
type = (*lang_hooks.types.make_type) (RECORD_TYPE); type = (*lang_hooks.types.make_type) (RECORD_TYPE);
const_type = build_qualified_type (type, TYPE_QUAL_CONST); const_type = build_qualified_type (type, TYPE_QUAL_CONST);
/* Version ident */ /* Version ident */
field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node); field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
...@@ -710,13 +701,13 @@ build_gcov_info () ...@@ -710,13 +701,13 @@ build_gcov_info ()
value = tree_cons (field, convert (unsigned_intSI_type_node, value = tree_cons (field, convert (unsigned_intSI_type_node,
build_int_2 (GCOV_VERSION, 0)), build_int_2 (GCOV_VERSION, 0)),
value); value);
/* next -- NULL */ /* next -- NULL */
field = build_decl (FIELD_DECL, NULL_TREE, build_pointer_type (const_type)); field = build_decl (FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
fields = field; fields = field;
value = tree_cons (field, null_pointer_node, value); value = tree_cons (field, null_pointer_node, value);
/* Filename */ /* Filename */
string_type = build_pointer_type (build_qualified_type (char_type_node, string_type = build_pointer_type (build_qualified_type (char_type_node,
TYPE_QUAL_CONST)); TYPE_QUAL_CONST));
...@@ -736,7 +727,7 @@ build_gcov_info () ...@@ -736,7 +727,7 @@ build_gcov_info ()
build_index_type (build_int_2 (filename_len, 0))); build_index_type (build_int_2 (filename_len, 0)));
value = tree_cons (field, build1 (ADDR_EXPR, string_type, filename_string), value = tree_cons (field, build1 (ADDR_EXPR, string_type, filename_string),
value); value);
/* Build the fn_info type and initializer. */ /* Build the fn_info type and initializer. */
fn_info_type = build_fn_info_type (n_ctr_types); fn_info_type = build_fn_info_type (n_ctr_types);
fn_info_ptr_type = build_pointer_type (build_qualified_type fn_info_ptr_type = build_pointer_type (build_qualified_type
...@@ -751,13 +742,13 @@ build_gcov_info () ...@@ -751,13 +742,13 @@ build_gcov_info ()
array_type = build_index_type (build_int_2 (n_fns - 1, 0)); array_type = build_index_type (build_int_2 (n_fns - 1, 0));
array_type = build_array_type (fn_info_type, array_type); array_type = build_array_type (fn_info_type, array_type);
fn_info_value = build_constructor (array_type, nreverse (fn_info_value)); fn_info_value = build_constructor (array_type, nreverse (fn_info_value));
fn_info_value = build1 (ADDR_EXPR, fn_info_ptr_type, fn_info_value); fn_info_value = build1 (ADDR_EXPR, fn_info_ptr_type, fn_info_value);
} }
else else
fn_info_value = null_pointer_node; fn_info_value = null_pointer_node;
/* number of functions */ /* number of functions */
field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node); field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
...@@ -765,7 +756,7 @@ build_gcov_info () ...@@ -765,7 +756,7 @@ build_gcov_info ()
value = tree_cons (field, value = tree_cons (field,
convert (unsigned_type_node, build_int_2 (n_fns, 0)), convert (unsigned_type_node, build_int_2 (n_fns, 0)),
value); value);
/* fn_info table */ /* fn_info table */
field = build_decl (FIELD_DECL, NULL_TREE, fn_info_ptr_type); field = build_decl (FIELD_DECL, NULL_TREE, fn_info_ptr_type);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
...@@ -780,7 +771,7 @@ build_gcov_info () ...@@ -780,7 +771,7 @@ build_gcov_info ()
convert (unsigned_type_node, convert (unsigned_type_node,
build_int_2 (prg_ctr_mask, 0)), build_int_2 (prg_ctr_mask, 0)),
value); value);
/* counters */ /* counters */
ctr_info_type = build_ctr_info_type (); ctr_info_type = build_ctr_info_type ();
ctr_info_ary_type = build_index_type (build_int_2 (n_ctr_types, 0)); ctr_info_ary_type = build_index_type (build_int_2 (n_ctr_types, 0));
...@@ -797,11 +788,11 @@ build_gcov_info () ...@@ -797,11 +788,11 @@ build_gcov_info ()
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
fields = field; fields = field;
value = tree_cons (field, ctr_info_value, value); value = tree_cons (field, ctr_info_value, value);
finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE); finish_builtin_struct (type, "__gcov_info", fields, NULL_TREE);
value = build_constructor (type, nreverse (value)); value = build_constructor (type, nreverse (value));
return value; return value;
} }
...@@ -810,7 +801,7 @@ build_gcov_info () ...@@ -810,7 +801,7 @@ build_gcov_info ()
gcov-io.h. Write out the constructor to call __gcov_init. */ gcov-io.h. Write out the constructor to call __gcov_init. */
static void static void
create_coverage () create_coverage (void)
{ {
tree gcov_info, gcov_info_value; tree gcov_info, gcov_info_value;
char name[20]; char name[20];
...@@ -819,10 +810,10 @@ create_coverage () ...@@ -819,10 +810,10 @@ create_coverage ()
rtx gcov_info_address; rtx gcov_info_address;
no_coverage = 1; /* Disable any further coverage. */ no_coverage = 1; /* Disable any further coverage. */
if (!prg_ctr_mask) if (!prg_ctr_mask)
return; return;
gcov_info_value = build_gcov_info (); gcov_info_value = build_gcov_info ();
gcov_info = build (VAR_DECL, TREE_TYPE (gcov_info_value), gcov_info = build (VAR_DECL, TREE_TYPE (gcov_info_value),
...@@ -832,7 +823,7 @@ create_coverage () ...@@ -832,7 +823,7 @@ create_coverage ()
TREE_STATIC (gcov_info) = 1; TREE_STATIC (gcov_info) = 1;
ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 0); ASM_GENERATE_INTERNAL_LABEL (name, "LPBX", 0);
DECL_NAME (gcov_info) = get_identifier (name); DECL_NAME (gcov_info) = get_identifier (name);
/* Build structure. */ /* Build structure. */
assemble_variable (gcov_info, 0, 0, 0); assemble_variable (gcov_info, 0, 0, 0);
...@@ -884,8 +875,7 @@ create_coverage () ...@@ -884,8 +875,7 @@ create_coverage ()
of graph file. */ of graph file. */
void void
coverage_init (filename) coverage_init (const char *filename)
const char *filename;
{ {
int len = strlen (filename); int len = strlen (filename);
...@@ -893,7 +883,7 @@ coverage_init (filename) ...@@ -893,7 +883,7 @@ coverage_init (filename)
da_file_name = (char *) xmalloc (len + strlen (GCOV_DATA_SUFFIX) + 1); da_file_name = (char *) xmalloc (len + strlen (GCOV_DATA_SUFFIX) + 1);
strcpy (da_file_name, filename); strcpy (da_file_name, filename);
strcat (da_file_name, GCOV_DATA_SUFFIX); strcat (da_file_name, GCOV_DATA_SUFFIX);
/* Name of bbg file. */ /* Name of bbg file. */
bbg_file_name = (char *) xmalloc (len + strlen (GCOV_GRAPH_SUFFIX) + 1); bbg_file_name = (char *) xmalloc (len + strlen (GCOV_GRAPH_SUFFIX) + 1);
strcpy (bbg_file_name, filename); strcpy (bbg_file_name, filename);
...@@ -906,13 +896,13 @@ coverage_init (filename) ...@@ -906,13 +896,13 @@ coverage_init (filename)
variables and constructor. */ variables and constructor. */
void void
coverage_finish () coverage_finish (void)
{ {
create_coverage (); create_coverage ();
if (bbg_file_opened) if (bbg_file_opened)
{ {
int error = gcov_close (); int error = gcov_close ();
if (error) if (error)
unlink (bbg_file_name); unlink (bbg_file_name);
#if SELF_COVERAGE #if SELF_COVERAGE
......
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