* configure.tgt (arm*-*-netbsd*): This variant is now fully multi-arch.
[deliverable/binutils-gdb.git] / gdb / i387-tdep.c
index 4f180fa8fa7bcff809d52eb7e9b6e0636e912939..2a6f77ce42d4429fd03a6084f9685490484ab6ea 100644 (file)
@@ -1,5 +1,6 @@
 /* Intel 387 floating point stuff.
-   Copyright (C) 1988, 89, 91, 98, 99, 2000 Free Software Foundation, Inc.
+   Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "value.h"
 #include "gdbcore.h"
 #include "floatformat.h"
+#include "regcache.h"
+#include "gdb_assert.h"
+#include "doublest.h"
 
+#include "i386-tdep.h"
 
 /* FIXME: Eliminate the next two functions when we have the time to
    change all the callers.  */
@@ -34,17 +39,13 @@ void i387_to_double (char *from, char *to);
 void double_to_i387 (char *from, char *to);
 
 void
-i387_to_double (from, to)
-     char *from;
-     char *to;
+i387_to_double (char *from, char *to)
 {
   floatformat_to_double (&floatformat_i387_ext, from, (double *) to);
 }
 
 void
-double_to_i387 (from, to)
-     char *from;
-     char *to;
+double_to_i387 (char *from, char *to)
 {
   floatformat_from_double (&floatformat_i387_ext, (double *) from, to);
 }
@@ -60,8 +61,7 @@ static void print_387_control_bits (unsigned int control);
 static void print_387_status_bits (unsigned int status);
 
 static void
-print_387_control_bits (control)
-     unsigned int control;
+print_387_control_bits (unsigned int control)
 {
   switch ((control >> 8) & 3)
     {
@@ -117,8 +117,7 @@ print_387_control_bits (control)
 }
 
 void
-print_387_control_word (control)
-     unsigned int control;
+print_387_control_word (unsigned int control)
 {
   printf_filtered ("control %s:", local_hex_string(control & 0xffff));
   print_387_control_bits (control);
@@ -126,8 +125,7 @@ print_387_control_word (control)
 }
 
 static void
-print_387_status_bits (status)
-     unsigned int status;
+print_387_status_bits (unsigned int status)
 {
   printf_unfiltered (" flags %d%d%d%d; ",
                     (status & 0x4000) != 0,
@@ -149,8 +147,7 @@ print_387_status_bits (status)
 }
 
 void
-print_387_status_word (status)
-     unsigned int status;
+print_387_status_word (unsigned int status)
 {
   printf_filtered ("status %s:", local_hex_string (status & 0xffff));
   print_387_status_bits (status);
@@ -167,21 +164,11 @@ print_i387_value (char *raw)
 {
   DOUBLEST value;
 
-  /* Avoid call to floatformat_to_doublest if possible to preserve as
-     much information as possible.  */
-
-#ifdef HAVE_LONG_DOUBLE
-  if (sizeof (value) == sizeof (long double)
-      && HOST_LONG_DOUBLE_FORMAT == &floatformat_i387_ext)
-    {
-      /* Copy straight over, but take care of the padding.  */
-      memcpy (&value, raw, FPU_REG_RAW_SIZE);
-      memset ((char *) &value + FPU_REG_RAW_SIZE, 0,
-             sizeof (value) - FPU_REG_RAW_SIZE);
-    }
-  else
-#endif
-    floatformat_to_doublest (&floatformat_i387_ext, raw, &value);
+  /* Using extract_typed_floating here might affect the representation
+     of certain numbers such as NaNs, even if GDB is running natively.
+     This is fine since our caller already detects such special
+     numbers and we print the hexadecimal representation anyway.  */
+  value = extract_typed_floating (raw, builtin_type_i387_ext);
 
   /* We try to print 19 digits.  The last digit may or may not contain
      garbage, but we'd better print one too many.  We need enough room
@@ -261,7 +248,7 @@ print_i387_status_word (unsigned int status)
   puts_filtered ("  ");
   printf_filtered (" %s", (status & 0x0080) ? "ES" : "  ");
   puts_filtered ("  ");
-  printf_filtered (" %s", (status & 0x0080) ? "SF" : "  ");
+  printf_filtered (" %s", (status & 0x0040) ? "SF" : "  ");
   puts_filtered ("  ");
   printf_filtered (" %s", (status & 0x0100) ? "C0" : "  ");
   printf_filtered (" %s", (status & 0x0200) ? "C1" : "  ");
This page took 0.025924 seconds and 4 git commands to generate.