Ran "indent", for GNU coding style; some code & comments still need fixup.
[deliverable/binutils-gdb.git] / gas / config / atof-ns32k.c
index 9fde9cb3693d2878a0b88ea29a616a81e41643ce..8562b5a6e10cf05ce9cc955091415967dccb8187 100644 (file)
@@ -21,22 +21,22 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include "as.h"
 
-extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */
+extern FLONUM_TYPE generic_floating_point_number;      /* Flonums returned here. */
 
 extern const char EXP_CHARS[];
-                               /* Precision in LittleNums. */
+/* Precision in LittleNums. */
 #define MAX_PRECISION (4)
 #define F_PRECISION (2)
 #define D_PRECISION (4)
 
-                               /* Length in LittleNums of guard bits. */
+/* Length in LittleNums of guard bits. */
 #define GUARD (2)
 
 int                            /* Number of chars in flonum type 'letter'. */
 atof_sizeof (letter)
      char letter;
 {
-  int  return_value;
+  int return_value;
 
   /*
    * Permitting uppercase letters is probably a bad idea.
@@ -60,7 +60,8 @@ atof_sizeof (letter)
   return (return_value);
 }
 
-static unsigned long int mask [] = {
+static unsigned long int mask[] =
+{
   0x00000000,
   0x00000001,
   0x00000003,
@@ -94,48 +95,49 @@ static unsigned long int mask [] = {
   0x3fffffff,
   0x7fffffff,
   0xffffffff
-  };
+};
 \f
 static int bits_left_in_littlenum;
 static int littlenums_left;
-static LITTLENUM_TYPE *        littlenum_pointer;
+static LITTLENUM_TYPE *littlenum_pointer;
 
 static int
 next_bits (number_of_bits)
-     int               number_of_bits;
+     int number_of_bits;
 {
-  int                  return_value;
+  int return_value;
 
-  if(!littlenums_left)
-       return 0;
+  if (!littlenums_left)
+    return 0;
   if (number_of_bits >= bits_left_in_littlenum)
     {
-      return_value  = mask [bits_left_in_littlenum] & *littlenum_pointer;
+      return_value = mask[bits_left_in_littlenum] & *littlenum_pointer;
       number_of_bits -= bits_left_in_littlenum;
       return_value <<= number_of_bits;
-      if(littlenums_left) {
-             bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
-             littlenum_pointer --;
-             --littlenums_left;
-             return_value |= (*littlenum_pointer>>bits_left_in_littlenum) & mask[number_of_bits];
-      }
+      if (littlenums_left)
+       {
+         bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits;
+         littlenum_pointer--;
+         --littlenums_left;
+         return_value |= (*littlenum_pointer >> bits_left_in_littlenum) & mask[number_of_bits];
+       }
     }
   else
     {
       bits_left_in_littlenum -= number_of_bits;
-      return_value = mask [number_of_bits] & (*littlenum_pointer>>bits_left_in_littlenum);
+      return_value = mask[number_of_bits] & (*littlenum_pointer >> bits_left_in_littlenum);
     }
   return (return_value);
 }
 
 static void
 make_invalid_floating_point_number (words)
-     LITTLENUM_TYPE *  words;
+     LITTLENUM_TYPE *words;
 {
-       words[0]= ((unsigned)-1)>>1;    /* Zero the leftmost bit */
-       words[1]= -1;
-       words[2]= -1;
-       words[3]= -1;
+  words[0] = ((unsigned) -1) >> 1;     /* Zero the leftmost bit */
+  words[1] = -1;
+  words[2] = -1;
+  words[3] = -1;
 }
 \f
 /***********************************************************************\
@@ -149,77 +151,81 @@ make_invalid_floating_point_number (words)
 
 char *                         /* Return pointer past text consumed. */
 atof_ns32k (str, what_kind, words)
-     char *            str;    /* Text to convert to binary. */
-     char              what_kind; /* 'd', 'f', 'g', 'h' */
-     LITTLENUM_TYPE *  words;  /* Build the binary here. */
+     char *str;                        /* Text to convert to binary. */
+     char what_kind;           /* 'd', 'f', 'g', 'h' */
+     LITTLENUM_TYPE *words;    /* Build the binary here. */
 {
-       FLONUM_TYPE     f;
-       LITTLENUM_TYPE  bits [MAX_PRECISION + MAX_PRECISION + GUARD];
-                               /* Extra bits for zeroed low-order bits. */
-                               /* The 1st MAX_PRECISION are zeroed, */
-                               /* the last contain flonum bits. */
-       char *          return_value;
-       int             precision; /* Number of 16-bit words in the format. */
-       long int        exponent_bits;
-
-       long int        exponent_1;
-       long int        exponent_2;
-       long int        exponent_3;
-       long int        exponent_4;
-       int             exponent_skippage;
-       LITTLENUM_TYPE  word1;
-       LITTLENUM_TYPE *        lp;
-
-       return_value = str;
-       f.low   = bits + MAX_PRECISION;
-       f.high  = NULL;
-       f.leader        = NULL;
-       f.exponent      = NULL;
-       f.sign  = '\0';
-
-                               /* Use more LittleNums than seems */
-                               /* necessary: the highest flonum may have */
-                               /* 15 leading 0 bits, so could be useless. */
-
-       bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION);
-
-       switch(what_kind) {
-       case 'f':
-               precision = F_PRECISION;
-               exponent_bits = 8;
-               break;
-
-       case 'd':
-               precision = D_PRECISION;
-               exponent_bits = 11;
-               break;
-
-       default:
-               make_invalid_floating_point_number (words);
-               return NULL;
-       }
+  FLONUM_TYPE f;
+  LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD];
+  /* Extra bits for zeroed low-order bits. */
+  /* The 1st MAX_PRECISION are zeroed, */
+  /* the last contain flonum bits. */
+  char *return_value;
+  int precision;               /* Number of 16-bit words in the format. */
+  long int exponent_bits;
+
+  long int exponent_1;
+  long int exponent_2;
+  long int exponent_3;
+  long int exponent_4;
+  int exponent_skippage;
+  LITTLENUM_TYPE word1;
+  LITTLENUM_TYPE *lp;
+
+  return_value = str;
+  f.low = bits + MAX_PRECISION;
+  f.high = NULL;
+  f.leader = NULL;
+  f.exponent = NULL;
+  f.sign = '\0';
+
+  /* Use more LittleNums than seems */
+  /* necessary: the highest flonum may have */
+  /* 15 leading 0 bits, so could be useless. */
+
+  bzero (bits, sizeof (LITTLENUM_TYPE) * MAX_PRECISION);
+
+  switch (what_kind)
+    {
+    case 'f':
+      precision = F_PRECISION;
+      exponent_bits = 8;
+      break;
 
-       f.high = f.low + precision - 1 + GUARD;
+    case 'd':
+      precision = D_PRECISION;
+      exponent_bits = 11;
+      break;
 
-       if (atof_generic (& return_value, ".", EXP_CHARS, & f)) {
-               as_warn("Error converting floating point number (Exponent overflow?)");
-               make_invalid_floating_point_number (words);
-               return NULL;
-       }
+    default:
+      make_invalid_floating_point_number (words);
+      return NULL;
+    }
 
-       if (f.low > f.leader) {
-               /* 0.0e0 seen. */
-               bzero (words, sizeof(LITTLENUM_TYPE) * precision);
-               return return_value;
-       }
+  f.high = f.low + precision - 1 + GUARD;
 
-       if(f.sign!='+' && f.sign!='-') {
-               make_invalid_floating_point_number(words);
-               return NULL;
-       }
+  if (atof_generic (&return_value, ".", EXP_CHARS, &f))
+    {
+      as_warn ("Error converting floating point number (Exponent overflow?)");
+      make_invalid_floating_point_number (words);
+      return NULL;
+    }
+
+  if (f.low > f.leader)
+    {
+      /* 0.0e0 seen. */
+      bzero (words, sizeof (LITTLENUM_TYPE) * precision);
+      return return_value;
+    }
+
+  if (f.sign != '+' && f.sign != '-')
+    {
+      make_invalid_floating_point_number (words);
+      return NULL;
+    }
 
 
-               /*
+  /*
                 * All vaxen floating_point formats (so far) have:
                 * Bit 15 is sign bit.
                 * Bits 14:n are excess-whatever exponent.
@@ -230,51 +236,53 @@ atof_ns32k (str, what_kind, words)
                 * So we need: number of bits of exponent, number of bits of
                 * mantissa.
                 */
-       bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
-       littlenum_pointer = f.leader;
-       littlenums_left = 1 + f.leader-f.low;
-       /* Seek (and forget) 1st significant bit */
-       for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
-               ;
-       exponent_1 = f.exponent + f.leader + 1 - f.low;
-       /* Radix LITTLENUM_RADIX, point just higher than f.leader. */
-       exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
-       /* Radix 2. */
-       exponent_3 = exponent_2 - exponent_skippage;
-       /* Forget leading zeros, forget 1st bit. */
-       exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
-       /* Offset exponent. */
-
-       if (exponent_4 & ~ mask [exponent_bits]) {
-                       /*
+  bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
+  littlenum_pointer = f.leader;
+  littlenums_left = 1 + f.leader - f.low;
+  /* Seek (and forget) 1st significant bit */
+  for (exponent_skippage = 0; !next_bits (1); exponent_skippage++)
+    ;
+  exponent_1 = f.exponent + f.leader + 1 - f.low;
+  /* Radix LITTLENUM_RADIX, point just higher than f.leader. */
+  exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
+  /* Radix 2. */
+  exponent_3 = exponent_2 - exponent_skippage;
+  /* Forget leading zeros, forget 1st bit. */
+  exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
+  /* Offset exponent. */
+
+  if (exponent_4 & ~mask[exponent_bits])
+    {
+      /*
                         * Exponent overflow. Lose immediately.
                         */
 
-                       /*
+      /*
                         * We leave return_value alone: admit we read the
                         * number, but return a floating exception
                         * because we can't encode the number.
                         */
 
-               as_warn("Exponent overflow in floating-point number");
-               make_invalid_floating_point_number (words);
-               return return_value;
-       }
-       lp = words;
+      as_warn ("Exponent overflow in floating-point number");
+      make_invalid_floating_point_number (words);
+      return return_value;
+    }
+  lp = words;
 
-       /* Word 1. Sign, exponent and perhaps high bits. */
-       /* Assume 2's complement integers. */
-       word1 = ((exponent_4 & mask [exponent_bits]) << (15 - exponent_bits)) |
- ((f.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
-       * lp ++ = word1;
+  /* Word 1. Sign, exponent and perhaps high bits. */
+  /* Assume 2's complement integers. */
+  word1 = ((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) |
   ((f.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
+  *lp++ = word1;
 
-       /* The rest of the words are just mantissa bits. */
-       for (; lp < words + precision; lp++)
-               * lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
+  /* The rest of the words are just mantissa bits. */
+  for (; lp < words + precision; lp++)
+    *lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
 
-       if (next_bits (1)) {
-               unsigned long int       carry;
-                       /*
+  if (next_bits (1))
+    {
+      unsigned long int carry;
+      /*
                         * Since the NEXT bit is a 1, round UP the mantissa.
                         * The cunning design of these hidden-1 floats permits
                         * us to let the mantissa overflow into the exponent, and
@@ -284,53 +292,56 @@ atof_ns32k (str, what_kind, words)
                         */
 
 
-/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
+      /* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
        Please allow at least 1 more bit in carry than is in a LITTLENUM.
        We need that extra bit to hold a carry during a LITTLENUM carry
        propagation. Another extra bit (kept 0) will assure us that we
        don't get a sticky sign bit after shifting right, and that
        permits us to propagate the carry without any masking of bits.
 #endif */
-               for (carry = 1, lp --; carry && (lp >= words); lp --) {
-                       carry = * lp + carry;
-                       * lp = carry;
-                       carry >>= LITTLENUM_NUMBER_OF_BITS;
-               }
-               if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
-                       /* We leave return_value alone: admit we read the
+      for (carry = 1, lp--; carry && (lp >= words); lp--)
+       {
+         carry = *lp + carry;
+         *lp = carry;
+         carry >>= LITTLENUM_NUMBER_OF_BITS;
+       }
+      if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)))
+       {
+         /* We leave return_value alone: admit we read the
                         * number, but return a floating exception
                         * because we can't encode the number.
                         */
-                       make_invalid_floating_point_number (words);
-                       return return_value;
-               }
+         make_invalid_floating_point_number (words);
+         return return_value;
        }
-       return (return_value);
+    }
+  return (return_value);
 }
 
 /* This is really identical to atof_ns32k except for some details */
 
-gen_to_words(words,precision,exponent_bits)
-LITTLENUM_TYPE *words;
-long int       exponent_bits;
+gen_to_words (words, precision, exponent_bits)
+     LITTLENUM_TYPE *words;
+     long int exponent_bits;
 {
-       int return_value=0;
-
-       long int        exponent_1;
-       long int        exponent_2;
-       long int        exponent_3;
-       long int        exponent_4;
-       int             exponent_skippage;
-       LITTLENUM_TYPE  word1;
-       LITTLENUM_TYPE *        lp;
-
-       if (generic_floating_point_number.low > generic_floating_point_number.leader) {
-               /* 0.0e0 seen. */
-               bzero (words, sizeof(LITTLENUM_TYPE) * precision);
-               return return_value;
-       }
+  int return_value = 0;
 
-               /*
+  long int exponent_1;
+  long int exponent_2;
+  long int exponent_3;
+  long int exponent_4;
+  int exponent_skippage;
+  LITTLENUM_TYPE word1;
+  LITTLENUM_TYPE *lp;
+
+  if (generic_floating_point_number.low > generic_floating_point_number.leader)
+    {
+      /* 0.0e0 seen. */
+      bzero (words, sizeof (LITTLENUM_TYPE) * precision);
+      return return_value;
+    }
+
+  /*
                 * All vaxen floating_point formats (so far) have:
                 * Bit 15 is sign bit.
                 * Bits 14:n are excess-whatever exponent.
@@ -341,51 +352,53 @@ long int  exponent_bits;
                 * So we need: number of bits of exponent, number of bits of
                 * mantissa.
                 */
-       bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
-       littlenum_pointer = generic_floating_point_number.leader;
-       littlenums_left = 1+generic_floating_point_number.leader - generic_floating_point_number.low;
-       /* Seek (and forget) 1st significant bit */
-       for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++)
-               ;
-       exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader + 1 -
- generic_floating_point_number.low;
-       /* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */
-       exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
-       /* Radix 2. */
-       exponent_3 = exponent_2 - exponent_skippage;
-       /* Forget leading zeros, forget 1st bit. */
-       exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
-       /* Offset exponent. */
-
-       if (exponent_4 & ~ mask [exponent_bits]) {
-                       /*
+  bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS;
+  littlenum_pointer = generic_floating_point_number.leader;
+  littlenums_left = 1 + generic_floating_point_number.leader - generic_floating_point_number.low;
+  /* Seek (and forget) 1st significant bit */
+  for (exponent_skippage = 0; !next_bits (1); exponent_skippage++)
+    ;
+  exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader + 1 -
+    generic_floating_point_number.low;
+  /* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */
+  exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS;
+  /* Radix 2. */
+  exponent_3 = exponent_2 - exponent_skippage;
+  /* Forget leading zeros, forget 1st bit. */
+  exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2);
+  /* Offset exponent. */
+
+  if (exponent_4 & ~mask[exponent_bits])
+    {
+      /*
                         * Exponent overflow. Lose immediately.
                         */
 
-                       /*
+      /*
                         * We leave return_value alone: admit we read the
                         * number, but return a floating exception
                         * because we can't encode the number.
                         */
 
-               make_invalid_floating_point_number (words);
-               return return_value;
-       }
-       lp = words;
+      make_invalid_floating_point_number (words);
+      return return_value;
+    }
+  lp = words;
 
-       /* Word 1. Sign, exponent and perhaps high bits. */
-       /* Assume 2's complement integers. */
-       word1 = ((exponent_4 & mask [exponent_bits]) << (15 - exponent_bits)) |
- ((generic_floating_point_number.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
-       * lp ++ = word1;
+  /* Word 1. Sign, exponent and perhaps high bits. */
+  /* Assume 2's complement integers. */
+  word1 = ((exponent_4 & mask[exponent_bits]) << (15 - exponent_bits)) |
   ((generic_floating_point_number.sign == '+') ? 0 : 0x8000) | next_bits (15 - exponent_bits);
+  *lp++ = word1;
 
-       /* The rest of the words are just mantissa bits. */
-       for (; lp < words + precision; lp++)
-               * lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
+  /* The rest of the words are just mantissa bits. */
+  for (; lp < words + precision; lp++)
+    *lp = next_bits (LITTLENUM_NUMBER_OF_BITS);
 
-       if (next_bits (1)) {
-               unsigned long int       carry;
-                       /*
+  if (next_bits (1))
+    {
+      unsigned long int carry;
+      /*
                         * Since the NEXT bit is a 1, round UP the mantissa.
                         * The cunning design of these hidden-1 floats permits
                         * us to let the mantissa overflow into the exponent, and
@@ -395,42 +408,45 @@ long int  exponent_bits;
                         */
 
 
-/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
+      /* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2)
        Please allow at least 1 more bit in carry than is in a LITTLENUM.
        We need that extra bit to hold a carry during a LITTLENUM carry
        propagation. Another extra bit (kept 0) will assure us that we
        don't get a sticky sign bit after shifting right, and that
        permits us to propagate the carry without any masking of bits.
 #endif */
-               for (carry = 1, lp --; carry && (lp >= words); lp --) {
-                       carry = * lp + carry;
-                       * lp = carry;
-                       carry >>= LITTLENUM_NUMBER_OF_BITS;
-               }
-               if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) {
-                       /* We leave return_value alone: admit we read the
+      for (carry = 1, lp--; carry && (lp >= words); lp--)
+       {
+         carry = *lp + carry;
+         *lp = carry;
+         carry >>= LITTLENUM_NUMBER_OF_BITS;
+       }
+      if ((word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)))
+       {
+         /* We leave return_value alone: admit we read the
                         * number, but return a floating exception
                         * because we can't encode the number.
                         */
-                       make_invalid_floating_point_number (words);
-                       return return_value;
-               }
+         make_invalid_floating_point_number (words);
+         return return_value;
        }
-       return (return_value);
+    }
+  return (return_value);
 }
 
 /* This routine is a real kludge.  Someone really should do it better, but
    I'm too lazy, and I don't understand this stuff all too well anyway
    (JF)
  */
-void int_to_gen(x)
-long x;
+void
+int_to_gen (x)
+     long x;
 {
-       char buf[20];
-       char *bufp;
+  char buf[20];
+  char *bufp;
 
-       sprintf(buf,"%ld",x);
-       bufp= &buf[0];
-       if(atof_generic(&bufp,".", EXP_CHARS, &generic_floating_point_number))
-               as_warn("Error converting number to floating point (Exponent overflow?)");
+  sprintf (buf, "%ld", x);
+  bufp = &buf[0];
+  if (atof_generic (&bufp, ".", EXP_CHARS, &generic_floating_point_number))
+    as_warn ("Error converting number to floating point (Exponent overflow?)");
 }
This page took 0.032007 seconds and 4 git commands to generate.