OSDN Git Service

* include/bits/basic_string.tcc (_Rep::_S_create): Call
[pf3gnuchains/gcc-fork.git] / libiberty / floatformat.c
index 8f0d789..0bbb8ed 100644 (file)
@@ -1,5 +1,5 @@
 /* IEEE floating point support routines, for GDB, the GNU Debugger.
-   Copyright 1991, 1994, 1999, 2000, 2003, 2005
+   Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006
    Free Software Foundation, Inc.
 
 This file is part of GDB.
@@ -31,6 +31,11 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 #include <string.h>
 #endif
 
+/* On some platforms, <float.h> provides DBL_QNAN.  */
+#ifdef STDC_HEADERS
+#include <float.h>
+#endif
+
 #include "ansidecl.h"
 #include "libiberty.h"
 #include "floatformat.h"
@@ -44,8 +49,12 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 #endif
 
 #ifndef NAN
+#ifdef DBL_QNAN
+#define NAN DBL_QNAN
+#else
 #define NAN (0.0 / 0.0)
 #endif
+#endif
 
 static unsigned long get_field (const unsigned char *,
                                 enum floatformat_byteorders,
@@ -108,6 +117,30 @@ const struct floatformat floatformat_ieee_double_littlebyte_bigword =
   floatformat_always_valid
 };
 
+/* floatformat for VAX.  Not quite IEEE, but close enough.  */
+
+const struct floatformat floatformat_vax_f =
+{
+  floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23,
+  floatformat_intbit_no,
+  "floatformat_vax_f",
+  floatformat_always_valid
+};
+const struct floatformat floatformat_vax_d =
+{
+  floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55,
+  floatformat_intbit_no,
+  "floatformat_vax_d",
+  floatformat_always_valid
+};
+const struct floatformat floatformat_vax_g =
+{
+  floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52,
+  floatformat_intbit_no,
+  "floatformat_vax_g",
+  floatformat_always_valid
+};
+
 static int floatformat_i387_ext_is_valid (const struct floatformat *fmt,
                                          const void *from);
 
@@ -119,7 +152,7 @@ floatformat_i387_ext_is_valid (const struct floatformat *fmt, const void *from)
      nor ~0, the intbit must also be set.  Only if the exponent is
      zero can it be zero, and then it must be zero.  */
   unsigned long exponent, int_bit;
-  const unsigned char *ufrom = from;
+  const unsigned char *ufrom = (const unsigned char *) from;
 
   exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
                        fmt->exp_start, fmt->exp_len);
@@ -271,7 +304,7 @@ void
 floatformat_to_double (const struct floatformat *fmt,
                        const void *from, double *to)
 {
-  const unsigned char *ufrom = from;
+  const unsigned char *ufrom = (const unsigned char *) from;
   double dto;
   long exponent;
   unsigned long mant;
@@ -361,7 +394,7 @@ floatformat_to_double (const struct floatformat *fmt,
 
       /* Handle denormalized numbers.  FIXME: What should we do for
         non-IEEE formats?  */
-      if (exponent == 0 && mant != 0)
+      if (special_exponent && exponent == 0 && mant != 0)
        dto += ldexp ((double)mant,
                      (- fmt->exp_bias
                       - mant_bits
@@ -447,7 +480,7 @@ floatformat_from_double (const struct floatformat *fmt,
   double mant;
   unsigned int mant_bits, mant_off;
   int mant_bits_left;
-  unsigned char *uto = to;
+  unsigned char *uto = (unsigned char *) to;
 
   dfrom = *from;
   memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);