[PATCH^3] C90fy gas/config/tc-vax.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH^3] C90fy gas/config/tc-vax.c

Jan-Benedict Glaw
Hi!

Fighting the growing patch queue, here's the first one. This one
converts gas/config/tc-vax.c to C90. No functional changes. Comments?

This patch is used for probably more than two years for the
vax-linux-{gnu,uclibc} targets (with some more patches, basically only
configury) and doesn't cause regressions.

gas/:
2005-12-13  Jan-Benedict Glaw  <[hidden email]>

        * config/tc-vax.c: C90fy.                                                                

diff -Nurp src-binutils-fresh/gas/config/tc-vax.c src-binutils-hacked/gas/config/tc-vax.c
--- src-binutils-fresh/gas/config/tc-vax.c 2005-08-13 13:37:12.000000000 +0200
+++ src-binutils-hacked/gas/config/tc-vax.c 2005-09-12 20:04:50.000000000 +0200
@@ -279,7 +279,7 @@ static void vip PARAMS ((struct vit *, c
 static int vax_reg_parse PARAMS ((char, char, char, char));
 
 void
-md_begin ()
+md_begin (void)
 {
   const char *errtxt;
   FLONUM_TYPE *fP;
@@ -300,10 +300,7 @@ md_begin ()
 }
 
 void
-md_number_to_chars (con, value, nbytes)
-     char con[];
-     valueT value;
-     int nbytes;
+md_number_to_chars (char con[], valueT value, int nbytes)
 {
   number_to_chars_littleendian (con, value, nbytes);
 }
@@ -330,10 +327,12 @@ md_apply_fix (fixP, valueP, seg)
     fixP->fx_done = 1;
 }
 
+/* Convert a number from VAX byte order (little endian)
+   into host byte order.
+   con is the buffer to convert,
+   nbytes is the length of the given buffer.  */
 long
-md_chars_to_number (con, nbytes)
-     unsigned char con[]; /* Low order byte 1st.  */
-     int nbytes; /* Number of bytes in the input.  */
+md_chars_to_number (unsigned char con[], int nbytes)
 {
   long retval;
   for (retval = 0, con += nbytes - 1; nbytes--; con--)
@@ -354,10 +353,10 @@ md_chars_to_number (con, nbytes)
  */
 
 static int
-bignum_copy (register LITTLENUM_TYPE *in,
-     register int in_length, /* in sizeof(littlenum)s */
-     register LITTLENUM_TYPE *out,
-     register int out_length /* in sizeof(littlenum)s */)
+bignum_copy (LITTLENUM_TYPE *in,
+     int in_length, /* in sizeof(littlenum)s */
+     LITTLENUM_TYPE *out,
+     int out_length /* in sizeof(littlenum)s */)
 {
   int significant_littlenums_dropped;
 
@@ -398,11 +397,10 @@ bignum_copy (register LITTLENUM_TYPE *in
   return (significant_littlenums_dropped);
 }
 
-/* vax:md_assemble() emit frags for 1 instruction */
+/* vax:md_assemble() emit frags for 1 instruction given in textual form.  */
 
 void
-md_assemble (instruction_string)
-     char *instruction_string; /* A string: assemble 1 instruction.  */
+md_assemble (char *instruction_string)
 {
   /* Non-zero if operand expression's segment is not known yet.  */
   int is_undefined;
@@ -1268,9 +1266,7 @@ md_assemble (instruction_string)
    Return the correct fr_subtype in the frag and the growth beyond
    fr_fix.  */
 int
-md_estimate_size_before_relax (fragP, segment)
-     fragS *fragP;
-     segT segment;
+md_estimate_size_before_relax (fragS *fragP, segT segment)
 {
   if (RELAX_LENGTH (fragP->fr_subtype) == STATE_UNDF)
     {
@@ -1425,10 +1421,8 @@ md_estimate_size_before_relax (fragP, se
  * Caller will turn frag into a ".space 0".
  */
 void
-md_convert_frag (headers, seg, fragP)
-     bfd *headers ATTRIBUTE_UNUSED;
-     segT seg ATTRIBUTE_UNUSED;
-     fragS *fragP;
+md_convert_frag (bfd *headers ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED,
+ fragS *fragP)
 {
   char *addressP; /* -> _var to change.  */
   char *opcodeP; /* -> opcode char(s) to change.  */
@@ -1577,9 +1571,7 @@ md_convert_frag (headers, seg, fragP)
    bit 0 as pcrel.  */
 #ifdef comment
 void
-md_ri_to_chars (the_bytes, ri)
-     char *the_bytes;
-     struct reloc_info_generic ri;
+md_ri_to_chars (char *the_bytes, struct reloc_info_generic ri)
 {
   /* this is easy */
   md_number_to_chars (the_bytes, ri.r_address, sizeof (ri.r_address));
@@ -1737,13 +1729,13 @@ static const short int vax_operand_width
  *
  */
 #if (VIT_OPCODE_SYNTHETIC != 0x80000000)
-You have just broken the encoding below, which assumes the sign bit
-  means 'I am an imaginary instruction'.
+#error "You have just broken the encoding below, which assumes the sign bit " \
+  "means 'I am an imaginary instruction'."
 #endif
 
 #if (VIT_OPCODE_SPECIAL != 0x40000000)
-  You have just broken the encoding below, which assumes the 0x40 M bit means
-  'I am not to be "optimised" the way normal branches are'.
+#error "You have just broken the encoding below, which assumes the 0x40 " \
+  "M bit means 'I am not to be "optimised" the way normal branches are'."
 #endif
 
 static const struct vot
@@ -1812,9 +1804,10 @@ static const struct vot
  */
 
 static const char *
-vip_begin (synthetic_too, immediate, indirect, displen)
-     int synthetic_too; /* 1 means include jXXX op-codes.  */
-     const char *immediate, *indirect, *displen;
+vip_begin (int synthetic_too,
+   const char *immediate, /* 1 means include jXXX op-codes.  */
+   const char *indirect,
+   const char *displen)
 {
   const struct vot *vP; /* scan votstrs */
   const char *retval = 0; /* error text */
@@ -1860,9 +1853,8 @@ vip_begin (synthetic_too, immediate, ind
  */
 
 static void
-vip (vitP, instring)
-     struct vit *vitP; /* We build an exploded instruction here.  */
-     char *instring; /* Text of a vax instruction: we modify.  */
+vip (struct vit *vitP, /* We build an exploded instruction here.  */
+     char *instring) /* Text of a vax instruction: we modify.  */
 {
   /* How to bit-encode this opcode.  */
   struct vot_wot *vwP;
@@ -2087,7 +2079,7 @@ main ()
  * R4
  * R5
  * R6
- * R7
+ * R7
  * R8
  * R9
  * R10
@@ -2100,18 +2092,19 @@ main ()
  */
 
 #include "safe-ctype.h"
-#define AP (12)
-#define FP (13)
-#define SP (14)
-#define PC (15)
-
-int /* return -1 or 0:15 */
-vax_reg_parse (c1, c2, c3, c4) /* 3 chars of register name */
-     char c1, c2, c3, c4; /* c3 == 0 if 2-character reg name */
-{
-  int retval; /* return -1:15 */
+#define AP 12
+#define FP 13
+#define SP 14
+#define PC 15
+
+/* Returns the register number of something like '%r15' or 'ap', supplied
+   in four single chars. Returns -1 if the register isn't recognized,
+   0..15 otherwise.  */
 
-  retval = -1;
+int
+vax_reg_parse (char c1, char c2, char c3, char c4)
+{
+  int retval = -1; /* return -1:15 */
 
 #ifdef OBJ_ELF
   if (c1 != '%') /* register prefixes are mandatory for ELF */
@@ -2172,7 +2165,7 @@ vax_reg_parse (c1, c2, c3, c4) /* 3 char
     retval = PC;
   else
     retval = -1;
-  return (retval);
+  return retval;
 }
 
 /*
@@ -2195,7 +2188,7 @@ vax_reg_parse (c1, c2, c3, c4) /* 3 char
  */
 
 /*
- *   B u g s
+ * B u g s
  *
  * Arg block.
  *
@@ -2327,9 +2320,7 @@ vip_metacharacters[256] =
 static char vip_metacharacters[256];
 
 static void
-vip_op_1 (bit, syms)
-     int bit;
-     const char *syms;
+vip_op_1 (int bit, const char *syms)
 {
   unsigned char t;
 
@@ -2339,10 +2330,8 @@ vip_op_1 (bit, syms)
 
 /* Can be called any time.  More arguments may appear in future.  */
 static void
-vip_op_defaults (immediate, indirect, displen)
-     const char *immediate;
-     const char *indirect;
-     const char *displen;
+vip_op_defaults (const char *immediate, const char *indirect,
+ const char *displen)
 {
   vip_op_1 (VIP_IMMEDIATE, immediate);
   vip_op_1 (VIP_INDIRECT, indirect);
@@ -2410,15 +2399,12 @@ vip_op_defaults (immediate, indirect, di
  * Again, I dare not explain it: just trace ALL the code!
  */
 
+/* Dissect user-input 'optext' (which is something like "@B^foo@bar(AP)[FP]:")
+   using the vop in vopP. vopP's vop_access and vop_width. We fill _ndx, _reg,
+   _mode, _short, _warn, _error, _expr_begin, _expr_end and _nbytes.  */
+
 static void
-vip_op (optext, vopP)
-     /* user's input string e.g.: "@B^foo@bar(AP)[FP]:" */
-     char *optext;
-     /* Input fields: vop_access, vop_width.
- Output fields: _ndx, _reg, _mode, _short, _warn,
- _error _expr_begin, _expr_end, _nbytes.
- vop_nbytes : number of bytes in a datum.  */
-     struct vop *vopP;
+vip_op (char *optext, struct vop *vopP)
 {
   /* track operand text forward */
   char *p;
@@ -3113,7 +3099,8 @@ char my_immediate[200];
 char my_indirect[200];
 char my_displen[200];
 
-main ()
+int
+main (int argc, char *argv[])
 {
   printf ("enter immediate symbols eg enter #   ");
   gets (my_immediate);
@@ -3199,9 +3186,8 @@ main ()
     }
 }
 
-mumble (text, value)
-     char *text;
-     int value;
+void
+mumble (char *text, intvalue)
 {
   printf ("%s:", text);
   if (value >= 0)
@@ -3219,12 +3205,10 @@ int md_short_jump_size = 3;
 int md_long_jump_size = 6;
 
 void
-md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol)
-     char *ptr;
-     addressT from_addr;
-     addressT to_addr ATTRIBUTE_UNUSED;
-     fragS *frag ATTRIBUTE_UNUSED;
-     symbolS *to_symbol ATTRIBUTE_UNUSED;
+md_create_short_jump (char *ptr, addressT from_addr,
+      addressT to_addr ATTRIBUTE_UNUSED,
+      fragS *frag ATTRIBUTE_UNUSED,
+      symbolS *to_symbol ATTRIBUTE_UNUSED)
 {
   valueT offset;
 
@@ -3238,12 +3222,8 @@ md_create_short_jump (ptr, from_addr, to
 }
 
 void
-md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol)
-     char *ptr;
-     addressT from_addr ATTRIBUTE_UNUSED;
-     addressT to_addr;
-     fragS *frag;
-     symbolS *to_symbol;
+md_create_long_jump (char *ptr, addressT from_addr ATTRIBUTE_UNUSED,
+     addressT to_addr, fragS *frag, symbolS *to_symbol)
 {
   valueT offset;
 
@@ -3264,16 +3244,14 @@ const char *md_shortopts = "d:STt:V";
 struct option md_longopts[] = {
 #ifdef OBJ_ELF
 #define OPTION_PIC (OPTION_MD_BASE)
-  {"pic", no_argument, NULL, OPTION_PIC},
+  { "pic", no_argument, NULL, OPTION_PIC, },
 #endif
-  {NULL, no_argument, NULL, 0}
+  { NULL, no_argument, NULL, 0, },
 };
 size_t md_longopts_size = sizeof (md_longopts);
 
 int
-md_parse_option (c, arg)
-     int c;
-     char *arg;
+md_parse_option (int c, char *arg)
 {
   switch (c)
     {
@@ -3348,8 +3326,7 @@ md_parse_option (c, arg)
 }
 
 void
-md_show_usage (stream)
-     FILE *stream;
+md_show_usage (FILE *stream)
 {
   fprintf (stream, _("\
 VAX options:\n\
@@ -3374,17 +3351,14 @@ VMS options:\n\
 /* We have no need to default values of symbols.  */
 
 symbolS *
-md_undefined_symbol (name)
-     char *name ATTRIBUTE_UNUSED;
+md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
 {
   return 0;
 }
 
 /* Round up a section size to the appropriate boundary.  */
 valueT
-md_section_align (segment, size)
-     segT segment ATTRIBUTE_UNUSED;
-     valueT size;
+md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
 {
   return size; /* Byte alignment is fine */
 }
@@ -3393,16 +3367,13 @@ md_section_align (segment, size)
    On the vax, they're relative to the address of the offset, plus
    its size. */
 long
-md_pcrel_from (fixP)
-     fixS *fixP;
+md_pcrel_from (fixS *fixP)
 {
   return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
 }
 
 arelent *
-tc_gen_reloc (section, fixp)
-     asection *section ATTRIBUTE_UNUSED;
-     fixS *fixp;
+tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
   bfd_reloc_code_real_type code;


MfG, JBG

--
Jan-Benedict Glaw       [hidden email]    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));

signature.asc (196 bytes) Download Attachment