This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

convert bfd/merge.c to ISO C 90


I've committed the appended patch after testing on i686-linux-gnu,

Andreas

2003-08-31  Andreas Jaeger  <aj@suse.de>

	* merge.c: Update to ISO C90.

============================================================
Index: bfd/merge.c
--- bfd/merge.c	30 Nov 2002 08:39:40 -0000	1.15
+++ bfd/merge.c	31 Aug 2003 10:06:34 -0000
@@ -1,5 +1,5 @@
 /* SEC_MERGE support.
-   Copyright 2001, 2002 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -88,7 +88,7 @@ struct sec_merge_sec_info
   /* The corresponding section.  */
   asection *sec;
   /* Pointer to merge_info pointing to us.  */
-  PTR *psecinfo;
+  void **psecinfo;
   /* A hash table used to hold section content.  */
   struct sec_merge_hash *htab;
   /* First string in this section.  */
@@ -97,35 +97,12 @@ struct sec_merge_sec_info
   unsigned char contents[1];
 };
 
-static struct bfd_hash_entry *sec_merge_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct sec_merge_hash_entry *sec_merge_hash_lookup
-  PARAMS ((struct sec_merge_hash *, const char *, unsigned int, bfd_boolean));
-static struct sec_merge_hash *sec_merge_init
-  PARAMS ((unsigned int, bfd_boolean));
-static struct sec_merge_hash_entry *sec_merge_add
-  PARAMS ((struct sec_merge_hash *, const char *, unsigned int,
-	   struct sec_merge_sec_info *));
-static bfd_boolean sec_merge_emit
-  PARAMS ((bfd *, struct sec_merge_hash_entry *));
-static int cmplengthentry
-  PARAMS ((const PTR, const PTR));
-static int last4_eq
-  PARAMS ((const PTR, const PTR));
-static int last_eq
-  PARAMS ((const PTR, const PTR));
-static bfd_boolean record_section
-  PARAMS ((struct sec_merge_info *, struct sec_merge_sec_info *));
-static void merge_strings
-  PARAMS ((struct sec_merge_info *));
 
 /* Routine to create an entry in a section merge hashtab.  */
 
 static struct bfd_hash_entry *
-sec_merge_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+sec_merge_hash_newfunc (struct bfd_hash_entry *entry,
+			struct bfd_hash_table *table, const char *string)
 {
   struct sec_merge_hash_entry *ret = (struct sec_merge_hash_entry *) entry;
 
@@ -156,11 +133,8 @@ sec_merge_hash_newfunc (entry, table, st
 /* Look up an entry in a section merge hash table.  */
 
 static struct sec_merge_hash_entry *
-sec_merge_hash_lookup (table, string, alignment, create)
-     struct sec_merge_hash *table;
-     const char *string;
-     unsigned int alignment;
-     bfd_boolean create;
+sec_merge_hash_lookup (struct sec_merge_hash *table, const char *string,
+		       unsigned int alignment, bfd_boolean create)
 {
   register const unsigned char *s;
   register unsigned long hash;
@@ -261,9 +235,7 @@ sec_merge_hash_lookup (table, string, al
 /* Create a new hash table.  */
 
 static struct sec_merge_hash *
-sec_merge_init (entsize, strings)
-     unsigned int entsize;
-     bfd_boolean strings;
+sec_merge_init (unsigned int entsize, bfd_boolean strings)
 {
   struct sec_merge_hash *table;
   bfd_size_type amt = sizeof (struct sec_merge_hash);
@@ -291,11 +263,8 @@ sec_merge_init (entsize, strings)
    already present.  */
 
 static struct sec_merge_hash_entry *
-sec_merge_add (tab, str, alignment, secinfo)
-     struct sec_merge_hash *tab;
-     const char *str;
-     unsigned int alignment;
-     struct sec_merge_sec_info *secinfo;
+sec_merge_add (struct sec_merge_hash *tab, const char *str,
+	       unsigned int alignment, struct sec_merge_sec_info *secinfo)
 {
   register struct sec_merge_hash_entry *entry;
 
@@ -318,9 +287,7 @@ sec_merge_add (tab, str, alignment, seci
 }
 
 static bfd_boolean
-sec_merge_emit (abfd, entry)
-     register bfd *abfd;
-     struct sec_merge_hash_entry *entry;
+sec_merge_emit (register bfd *abfd, struct sec_merge_hash_entry *entry)
 {
   struct sec_merge_sec_info *secinfo = entry->secinfo;
   asection *sec = secinfo->sec;
@@ -340,7 +307,7 @@ sec_merge_emit (abfd, entry)
       if (len)
 	{
 	  len = entry->alignment - len;
-	  if (bfd_bwrite ((PTR) pad, (bfd_size_type) len, abfd) != len)
+	  if (bfd_bwrite (pad, (bfd_size_type) len, abfd) != len)
 	    break;
 	  off += len;
 	}
@@ -348,7 +315,7 @@ sec_merge_emit (abfd, entry)
       str = entry->root.string;
       len = entry->len;
 
-      if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
+      if (bfd_bwrite (str, (bfd_size_type) len, abfd) != len)
 	break;
 
       off += len;
@@ -364,11 +331,7 @@ sec_merge_emit (abfd, entry)
    pass of the linker.  */
 
 bfd_boolean
-_bfd_merge_section (abfd, psinfo, sec, psecinfo)
-     bfd *abfd;
-     PTR *psinfo;
-     asection *sec;
-     PTR *psecinfo;
+_bfd_merge_section (bfd *abfd, void **psinfo, asection *sec, void **psecinfo)
 {
   struct sec_merge_info *sinfo;
   struct sec_merge_sec_info *secinfo;
@@ -419,7 +382,7 @@ _bfd_merge_section (abfd, psinfo, sec, p
 	goto error_return;
       sinfo->next = (struct sec_merge_info *) *psinfo;
       sinfo->chain = NULL;
-      *psinfo = (PTR) sinfo;
+      *psinfo = sinfo;
       sinfo->htab = sec_merge_init (sec->entsize, (sec->flags & SEC_STRINGS));
       if (sinfo->htab == NULL)
 	goto error_return;
@@ -460,9 +423,7 @@ _bfd_merge_section (abfd, psinfo, sec, p
 /* Compare two sec_merge_hash_entry structures.  This is called via qsort.  */
 
 static int
-cmplengthentry (a, b)
-     const PTR a;
-     const PTR b;
+cmplengthentry (const void *a, const void *b)
 {
   struct sec_merge_hash_entry * A = *(struct sec_merge_hash_entry **) a;
   struct sec_merge_hash_entry * B = *(struct sec_merge_hash_entry **) b;
@@ -476,9 +437,7 @@ cmplengthentry (a, b)
 }
 
 static int
-last4_eq (a, b)
-     const PTR a;
-     const PTR b;
+last4_eq (const void *a, const void *b)
 {
   struct sec_merge_hash_entry * A = (struct sec_merge_hash_entry *) a;
   struct sec_merge_hash_entry * B = (struct sec_merge_hash_entry *) b;
@@ -504,9 +463,7 @@ last4_eq (a, b)
 }
 
 static int
-last_eq (a, b)
-     const PTR a;
-     const PTR b;
+last_eq (const void *a, const void *b)
 {
   struct sec_merge_hash_entry * A = (struct sec_merge_hash_entry *) a;
   struct sec_merge_hash_entry * B = (struct sec_merge_hash_entry *) b;
@@ -538,9 +495,8 @@ last_eq (a, b)
 
 /* Record one section into the hash table.  */
 static bfd_boolean
-record_section (sinfo, secinfo)
-     struct sec_merge_info *sinfo;
-     struct sec_merge_sec_info *secinfo;
+record_section (struct sec_merge_info *sinfo,
+		struct sec_merge_sec_info *secinfo)
 {
   asection *sec = secinfo->sec;
   struct sec_merge_hash_entry *entry;
@@ -623,8 +579,7 @@ error_return:
 /* This is a helper function for _bfd_merge_sections.  It attempts to
    merge strings matching suffixes of longer strings.  */
 static void
-merge_strings (sinfo)
-     struct sec_merge_info *sinfo;
+merge_strings (struct sec_merge_info *sinfo)
 {
   struct sec_merge_hash_entry **array, **a, **end, *e;
   struct sec_merge_sec_info *secinfo;
@@ -663,7 +618,7 @@ merge_strings (sinfo)
       unsigned int c;
       unsigned int i;
       const unsigned char *s;
-      PTR *p;
+      void **p;
 
       e = *a;
       e->u.entsize = sinfo->htab->entsize;
@@ -692,7 +647,7 @@ merge_strings (sinfo)
 	      continue;
 	    }
 	  else
-	    *p = (PTR) e;
+	    *p = e;
 	}
       s = (const unsigned char *) (e->root.string + e->len - e->u.entsize);
       hash = 0;
@@ -714,7 +669,7 @@ merge_strings (sinfo)
 	  e->alignment = 0;
 	}
       else
-	*p = (PTR) e;
+	*p = e;
     }
 
 alloc_failure:
@@ -770,10 +725,8 @@ alloc_failure:
    with _bfd_merge_section.  */
 
 bfd_boolean
-_bfd_merge_sections (abfd, xsinfo, remove_hook)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR xsinfo;
-     void (*remove_hook) PARAMS((bfd *, asection *));
+_bfd_merge_sections (bfd *abfd ATTRIBUTE_UNUSED, void *xsinfo,
+		     void (*remove_hook) (bfd *, asection *))
 {
   struct sec_merge_info *sinfo;
 
@@ -837,7 +790,7 @@ _bfd_merge_sections (abfd, xsinfo, remov
 	/* Finally shrink all input sections which have not made it into
 	   the hash table at all.  */
 	for (secinfo = sinfo->chain; secinfo; secinfo = secinfo->next)
-  	  if (secinfo->first == NULL)
+	  if (secinfo->first == NULL)
 	    secinfo->sec->_cooked_size = 0;
     }
 
@@ -847,10 +800,7 @@ _bfd_merge_sections (abfd, xsinfo, remov
 /* Write out the merged section.  */
 
 bfd_boolean
-_bfd_write_merged_section (output_bfd, sec, psecinfo)
-     bfd *output_bfd;
-     asection *sec;
-     PTR psecinfo;
+_bfd_write_merged_section (bfd *output_bfd, asection *sec, void *psecinfo)
 {
   struct sec_merge_sec_info *secinfo;
   file_ptr pos;
@@ -875,11 +825,8 @@ _bfd_write_merged_section (output_bfd, s
    section and writes the new section back into *PSEC.  */
 
 bfd_vma
-_bfd_merged_section_offset (output_bfd, psec, psecinfo, offset, addend)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     asection **psec;
-     PTR psecinfo;
-     bfd_vma offset, addend;
+_bfd_merged_section_offset (bfd *output_bfd ATTRIBUTE_UNUSED, asection **psec,
+			    void *psecinfo, bfd_vma offset, bfd_vma addend)
 {
   struct sec_merge_sec_info *secinfo;
   struct sec_merge_hash_entry *entry;

-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SuSE Linux AG, Deutschherrnstr. 15-19, 90429 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]