OSDN Git Service

Minor reformatting.
[pf3gnuchains/gcc-fork.git] / gcc / mips-tfile.c
index 3dbd4e1..49ae077 100644 (file)
@@ -3,7 +3,7 @@
    in the form of comments (the mips assembler does not support
    assembly access to debug information).
    Copyright (C) 1991, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    Contributed by Michael Meissner (meissner@cygnus.com).
 
 This file is part of GCC.
@@ -637,7 +637,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    so they can't be static.  */
 
 extern void pfatal_with_name (const char *) ATTRIBUTE_NORETURN;
-extern void fancy_abort (void) ATTRIBUTE_NORETURN;
 extern void botch (const char *) ATTRIBUTE_NORETURN;
 
 extern void fatal (const char *format, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
@@ -738,7 +737,7 @@ typedef enum st {
   st_StaticProc        = stStaticProc, /* load time only static procs */
   st_Constant  = stConstant,   /* const */
   st_Str       = stStr,        /* string */
-  st_Number    = stNumber,     /* pure number (ie. 4 NOR 2+2) */
+  st_Number    = stNumber,     /* pure number (i.e. 4 NOR 2+2) */
   st_Expr      = stExpr,       /* 2+2 vs. 4 */
   st_Type      = stType,       /* post-coercion SER */
   st_Max       = stMax         /* max type+1 */
@@ -1637,7 +1636,7 @@ add_varray_page (varray_t *vp)
 
 #ifdef MALLOC_CHECK
   if (vp->object_size > 1)
-    new_links->datum = (page_t *) xcalloc (1, vp->object_size);
+    new_links->datum = xcalloc (1, vp->object_size);
   else
 #endif
     new_links->datum = allocate_page ();
@@ -1747,7 +1746,7 @@ add_string (varray_t *vp, shash_t **hash_tbl, const char *start,
 
 \f
 /* Add a local symbol.  The symbol string starts at STR_START and the
-   first byte after it is makred by STR_END_P1.  The symbol has type
+   first byte after it is marked by STR_END_P1.  The symbol has type
    TYPE and storage class STORAGE and value VALUE.  INDX is an index
    to local/aux. symbols.  */
 
@@ -2353,13 +2352,13 @@ add_procedure (const char *func_start,  /* 1st byte of func name */
 STATIC void
 initialize_init_file (void)
 {
-  memset ((void*) &init_file, 0, sizeof (init_file));
+  memset (&init_file, 0, sizeof (init_file));
 
   init_file.fdr.lang = langC;
   init_file.fdr.fMerge = 1;
   init_file.fdr.glevel = GLEVEL_2;
 
-#ifdef HOST_WORDS_BIG_ENDIAN
+#ifdef WORDS_BIG_ENDIAN
   init_file.fdr.fBigendian = 1;
 #endif
 
@@ -3280,7 +3279,7 @@ parse_def (const char *name_start)
                                        value,
                                        indx);
 
-      /* deal with struct, union, and enum tags.  */
+      /* Deal with struct, union, and enum tags.  */
       if (symbol_type == st_Block)
         {
          /* Create or update the tag information.  */
@@ -3981,12 +3980,10 @@ write_varray (varray_t *vp,    /* virtual array */
     return;
 
   if (debug)
-    {
-      fputs ("\twarray\tvp = ", stderr);
-      fprintf (stderr, HOST_PTR_PRINTF, (void *) vp);
-      fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
-              (unsigned long) offset, vp->num_allocated * vp->object_size, str);
-    }
+    fprintf (stderr, "\twarray\tvp = " HOST_PTR_PRINTF
+            ", offset = %7lu, size = %7lu, %s\n",
+            (void *) vp, (unsigned long) offset,
+            vp->num_allocated * vp->object_size, str);
 
   if (file_offset != (unsigned long) offset
       && fseek (object_stream, (long) offset, SEEK_SET) < 0)
@@ -4023,12 +4020,10 @@ write_object (void)
   off_t offset;
 
   if (debug)
-    {
-      fputs ("\n\twrite\tvp = ", stderr);
-      fprintf (stderr, HOST_PTR_PRINTF, (void *) &symbolic_header);
-      fprintf (stderr, ", offset = %7u, size = %7lu, %s\n",
-              0, (unsigned long) sizeof (symbolic_header), "symbolic header");
-    }
+    fprintf (stderr, "\n\twrite\tvp = " HOST_PTR_PRINTF
+            ", offset = %7u, size = %7lu, %s\n",
+            (void *) &symbolic_header, 0,
+            (unsigned long) sizeof (symbolic_header), "symbolic header");
 
   sys_write = fwrite (&symbolic_header,
                      1,
@@ -4056,13 +4051,10 @@ write_object (void)
        pfatal_with_name (object_name);
 
       if (debug)
-       {
-         fputs ("\twrite\tvp = ", stderr);
-         fprintf (stderr, HOST_PTR_PRINTF, (void *) &orig_linenum);
-         fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
-                  (long) symbolic_header.cbLineOffset,
-                  (long) symbolic_header.cbLine, "Line numbers");
-       }
+       fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
+                ", offset = %7lu, size = %7lu, %s\n",
+                (void *) &orig_linenum, (long) symbolic_header.cbLineOffset,
+                (long) symbolic_header.cbLine, "Line numbers");
 
       sys_write = fwrite (orig_linenum,
                          1,
@@ -4091,13 +4083,10 @@ write_object (void)
        pfatal_with_name (object_name);
 
       if (debug)
-       {
-         fputs ("\twrite\tvp = ", stderr);
-         fprintf (stderr, HOST_PTR_PRINTF, (void *) &orig_opt_syms);
-         fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
-                  (long) symbolic_header.cbOptOffset,
-                  num_write, "Optimizer symbols");
-       }
+       fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
+                ", offset = %7lu, size = %7lu, %s\n",
+                (void *) &orig_opt_syms, (long) symbolic_header.cbOptOffset,
+                num_write, "Optimizer symbols");
 
       sys_write = fwrite (orig_opt_syms,
                          1,
@@ -4183,13 +4172,10 @@ write_object (void)
           file_ptr = file_ptr->next_file)
        {
          if (debug)
-           {
-             fputs ("\twrite\tvp = ", stderr);
-             fprintf (stderr, HOST_PTR_PRINTF, (void *) &file_ptr->fdr);
-             fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
-                      file_offset, (unsigned long) sizeof (FDR),
-                      "File header");
-           }
+           fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
+                    ", offset = %7lu, size = %7lu, %s\n",
+                    (void *) &file_ptr->fdr, file_offset,
+                    (unsigned long) sizeof (FDR), "File header");
 
          sys_write = fwrite (&file_ptr->fdr,
                              1,
@@ -4219,13 +4205,10 @@ write_object (void)
        pfatal_with_name (object_name);
 
       if (debug)
-       {
-         fputs ("\twrite\tvp = ", stderr);
-         fprintf (stderr, HOST_PTR_PRINTF, (void *) &orig_rfds);
-         fprintf (stderr, ", offset = %7lu, size = %7lu, %s\n",
-                  (long) symbolic_header.cbRfdOffset,
-                  num_write, "Relative file descriptors");
-       }
+       fprintf (stderr, "\twrite\tvp = " HOST_PTR_PRINTF
+                ", offset = %7lu, size = %7lu, %s\n",
+                (void *) &orig_rfds, (long) symbolic_header.cbRfdOffset,
+                num_write, "Relative file descriptors");
 
       sys_write = fwrite (orig_rfds,
                          1,
@@ -4273,7 +4256,7 @@ read_seek (Size_t size,           /* # bytes to read */
 #ifndef MALLOC_CHECK
   ptr = allocate_multiple_pages ((size + PAGE_USIZE - 1) / PAGE_USIZE);
 #else
-  ptr = (page_t *) xcalloc (1, size);
+  ptr = xcalloc (1, size);
 #endif
 
   /* If we need to seek, and the distance is nearby, just do some reads,
@@ -4395,67 +4378,67 @@ copy_object (void)
   file_offset =  orig_file_header.f_symptr + sizeof (struct filehdr);
 
   if (orig_sym_hdr.cbLine > 0)                 /* line numbers */
-    orig_linenum = (char *) read_seek ((Size_t) orig_sym_hdr.cbLine,
+    orig_linenum = (char *) read_seek (orig_sym_hdr.cbLine,
                                       orig_sym_hdr.cbLineOffset,
                                       "Line numbers");
 
   if (orig_sym_hdr.ipdMax > 0)                 /* procedure tables */
-    orig_procs = (PDR *) read_seek ((Size_t) orig_sym_hdr.ipdMax * sizeof (PDR),
+    orig_procs = (PDR *) read_seek (orig_sym_hdr.ipdMax * sizeof (PDR),
                                    orig_sym_hdr.cbPdOffset,
                                    "Procedure tables");
 
   if (orig_sym_hdr.isymMax > 0)                        /* local symbols */
-    orig_local_syms = (SYMR *) read_seek ((Size_t) orig_sym_hdr.isymMax * sizeof (SYMR),
+    orig_local_syms = (SYMR *) read_seek (orig_sym_hdr.isymMax * sizeof (SYMR),
                                          orig_sym_hdr.cbSymOffset,
                                          "Local symbols");
 
   if (orig_sym_hdr.iauxMax > 0)                        /* aux symbols */
-    orig_aux_syms = (AUXU *) read_seek ((Size_t) orig_sym_hdr.iauxMax * sizeof (AUXU),
+    orig_aux_syms = (AUXU *) read_seek (orig_sym_hdr.iauxMax * sizeof (AUXU),
                                        orig_sym_hdr.cbAuxOffset,
                                        "Aux. symbols");
 
   if (orig_sym_hdr.issMax > 0)                 /* local strings */
-    orig_local_strs = (char *) read_seek ((Size_t) orig_sym_hdr.issMax,
+    orig_local_strs = (char *) read_seek (orig_sym_hdr.issMax,
                                          orig_sym_hdr.cbSsOffset,
                                          "Local strings");
 
   if (orig_sym_hdr.issExtMax > 0)              /* external strings */
-    orig_ext_strs = (char *) read_seek ((Size_t) orig_sym_hdr.issExtMax,
+    orig_ext_strs = (char *) read_seek (orig_sym_hdr.issExtMax,
                                        orig_sym_hdr.cbSsExtOffset,
                                        "External strings");
 
   if (orig_sym_hdr.ifdMax > 0)                 /* file tables */
-    orig_files = (FDR *) read_seek ((Size_t) orig_sym_hdr.ifdMax * sizeof (FDR),
+    orig_files = (FDR *) read_seek (orig_sym_hdr.ifdMax * sizeof (FDR),
                                    orig_sym_hdr.cbFdOffset,
                                    "File tables");
 
   if (orig_sym_hdr.crfd > 0)                   /* relative file descriptors */
-    orig_rfds = (symint_t *) read_seek ((Size_t) orig_sym_hdr.crfd * sizeof (symint_t),
+    orig_rfds = (symint_t *) read_seek (orig_sym_hdr.crfd * sizeof (symint_t),
                                        orig_sym_hdr.cbRfdOffset,
                                        "Relative file descriptors");
 
   if (orig_sym_hdr.issExtMax > 0)              /* external symbols */
-    orig_ext_syms = (EXTR *) read_seek ((Size_t) orig_sym_hdr.iextMax * sizeof (EXTR),
+    orig_ext_syms = (EXTR *) read_seek (orig_sym_hdr.iextMax * sizeof (EXTR),
                                        orig_sym_hdr.cbExtOffset,
                                        "External symbols");
 
   if (orig_sym_hdr.idnMax > 0)                 /* dense numbers */
     {
-      orig_dense = (DNR *) read_seek ((Size_t) orig_sym_hdr.idnMax * sizeof (DNR),
+      orig_dense = (DNR *) read_seek (orig_sym_hdr.idnMax * sizeof (DNR),
                                      orig_sym_hdr.cbDnOffset,
                                      "Dense numbers");
 
-      add_bytes (&dense_num, (char *) orig_dense, (Size_t) orig_sym_hdr.idnMax);
+      add_bytes (&dense_num, (char *) orig_dense, orig_sym_hdr.idnMax);
     }
 
   if (orig_sym_hdr.ioptMax > 0)                        /* opt symbols */
-    orig_opt_syms = (OPTR *) read_seek ((Size_t) orig_sym_hdr.ioptMax * sizeof (OPTR),
+    orig_opt_syms = (OPTR *) read_seek (orig_sym_hdr.ioptMax * sizeof (OPTR),
                                        orig_sym_hdr.cbOptOffset,
                                        "Optimizer symbols");
 
 
 
-  /* Abort if the symbol table is not last.  */
+  /* The symbol table should be last.  */
   if (max_file_offset != (unsigned long) stat_buf.st_size)
     fatal ("symbol table is not last (symbol table ends at %ld, .o ends at %ld",
           max_file_offset,
@@ -4480,7 +4463,7 @@ copy_object (void)
      (in case there are duplicate filenames, we collapse them into one
      file section, the MIPS assembler may or may not collapse them).  */
 
-  remap_file_number = (int *) alloca (sizeof (int) * orig_sym_hdr.ifdMax);
+  remap_file_number = alloca (sizeof (int) * orig_sym_hdr.ifdMax);
 
   for (fd = delete_ifd; fd < orig_sym_hdr.ifdMax; fd++)
     {
@@ -4759,7 +4742,7 @@ main (int argc, char **argv)
        else
          rename_output = 1;
 
-       /* fall through to 'i' case.  */
+       /* Fall through to 'i' case.  */
 
       case 'i':
        if (obj_in_name == (char *) 0)
@@ -4790,7 +4773,7 @@ main (int argc, char **argv)
   if (version)
     {
       printf (_("mips-tfile (GCC) %s\n"), version_string);
-      fputs (_("Copyright (C) 2003 Free Software Foundation, Inc.\n"), stdout);
+      fputs ("Copyright (C) 2004 Free Software Foundation, Inc.\n", stdout);
       fputs (_("This is free software; see the source for copying conditions.  There is NO\n\
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
             stdout);
@@ -4957,7 +4940,7 @@ pfatal_with_name (const char *msg)
 }
 
 \f
-/* Procedure to abort with an out of bounds error message.  It has
+/* Procedure to die with an out of bounds error message.  It has
    type int, so it can be used with an ?: expression within the
    ORIG_xxx macros, but the function never returns.  */
 
@@ -4988,7 +4971,7 @@ out_of_bounds (symint_t indx,     /* index that is out of bounds */
 STATIC page_t *
 allocate_cluster (Size_t npages)
 {
-  page_t *value = (page_t *) xcalloc (npages, PAGE_USIZE);
+  page_t *value = xcalloc (npages, PAGE_USIZE);
 
   if (debug > 3)
     fprintf (stderr, "\talloc\tnpages = %d, value = 0x%.8x\n", npages, value);
@@ -5016,12 +4999,8 @@ allocate_cluster (Size_t npages)
     pfatal_with_name ("allocate_cluster");
 
   if (debug > 3)
-    {
-      fprintf (stderr, "\talloc\tnpages = %lu, value = ",
-              (unsigned long) npages);
-      fprintf (stderr, HOST_PTR_PRINTF, (void *) ptr);
-      fputs ("\n", stderr);
-    }
+    fprintf (stderr, "\talloc\tnpages = %lu, value = " HOST_PTR_PRINTF "\n",
+            (unsigned long) npages, (void *) ptr);
 
   return ptr;
 }
@@ -5058,7 +5037,7 @@ allocate_multiple_pages (Size_t npages)
   return allocate_cluster (npages);
 
 #else  /* MALLOC_CHECK */
-  return (page_t *) xcalloc (npages, PAGE_SIZE);
+  return xcalloc (npages, PAGE_SIZE);
 
 #endif /* MALLOC_CHECK */
 }
@@ -5109,7 +5088,7 @@ allocate_page (void)
   return cluster_ptr++;
 
 #else  /* MALLOC_CHECK */
-  return (page_t *) xcalloc (1, PAGE_SIZE);
+  return xcalloc (1, PAGE_SIZE);
 
 #endif /* MALLOC_CHECK */
 }
@@ -5145,7 +5124,7 @@ allocate_scope (void)
     }
 
 #else
-  ptr = (scope_t *) xmalloc (sizeof (scope_t));
+  ptr = xmalloc (sizeof (scope_t));
 
 #endif
 
@@ -5195,7 +5174,7 @@ allocate_vlinks (void)
   alloc_counts[ (int) alloc_type_vlinks ].unallocated = unallocated;
 
 #else
-  ptr = (vlinks_t *) xmalloc (sizeof (vlinks_t));
+  ptr = xmalloc (sizeof (vlinks_t));
 
 #endif
 
@@ -5228,7 +5207,7 @@ allocate_shash (void)
   alloc_counts[ (int) alloc_type_shash ].unallocated = unallocated;
 
 #else
-  ptr = (shash_t *) xmalloc (sizeof (shash_t));
+  ptr = xmalloc (sizeof (shash_t));
 
 #endif
 
@@ -5261,7 +5240,7 @@ allocate_thash (void)
   alloc_counts[ (int) alloc_type_thash ].unallocated = unallocated;
 
 #else
-  ptr = (thash_t *) xmalloc (sizeof (thash_t));
+  ptr = xmalloc (sizeof (thash_t));
 
 #endif
 
@@ -5301,7 +5280,7 @@ allocate_tag (void)
     }
 
 #else
-  ptr = (tag_t *) xmalloc (sizeof (tag_t));
+  ptr = xmalloc (sizeof (tag_t));
 
 #endif
 
@@ -5358,7 +5337,7 @@ allocate_forward (void)
     }
 
 #else
-  ptr = (forward_t *) xmalloc (sizeof (forward_t));
+  ptr = xmalloc (sizeof (forward_t));
 
 #endif
 
@@ -5415,7 +5394,7 @@ allocate_thead (void)
     }
 
 #else
-  ptr = (thead_t *) xmalloc (sizeof (thead_t));
+  ptr = xmalloc (sizeof (thead_t));
 
 #endif
 
@@ -5491,13 +5470,12 @@ error (const char *format, ...)
   saber_stop ();
 }
 
-/* More 'friendly' abort that prints the line and file.
-   config.h can #define abort fancy_abort if you like that sort of thing.  */
+/* More 'friendly' abort that prints the line and file.  */
 
 void
-fancy_abort (void)
+fancy_abort (const char *file, int line, const char *func)
 {
-  fatal ("internal abort");
+  fatal ("abort in %s, at %s:%d", func, file, line);
 }
 \f