* lin-lwp.c (stop_wait_callback): Remove bogus assertions in the
[deliverable/binutils-gdb.git] / gdb / i387-tdep.c
index 0bb16319abe0ca639d14a0d80b56caa6fe10de9f..88b65a44814e37f041423bd4463c74739145ea68 100644 (file)
@@ -1,5 +1,5 @@
 /* Intel 387 floating point stuff.
-   Copyright (C) 1988, 1989, 1991, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1988, 89, 91, 98, 99, 2000 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 /* FIXME: Eliminate the next two functions when we have the time to
    change all the callers.  */
 
-void i387_to_double PARAMS ((char *from, char *to));
-void double_to_i387 PARAMS ((char *from, char *to));
+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);
 }
@@ -56,12 +52,11 @@ double_to_i387 (from, to)
    use the generic implementation based on the new register file
    layout.  */
 
-static void print_387_control_bits PARAMS ((unsigned int control));
-static void print_387_status_bits PARAMS ((unsigned int status));
+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 +112,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 +120,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 +142,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);
@@ -166,8 +158,22 @@ static void
 print_i387_value (char *raw)
 {
   DOUBLEST value;
-  
-  floatformat_to_doublest (&floatformat_i387_ext, raw, &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);
 
   /* 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
@@ -387,51 +393,3 @@ i387_float_info (void)
   printf_filtered ("Opcode:              %s\n",
                   local_hex_string_custom (fop ? (fop | 0xd800) : 0, "04"));
 }
-
-\f
-/* FIXME: The functions on this page are used to provide `long double'
-   support for Linux.  However, the approach does not seem to be the
-   right one, and we are planning to solve this in a way that should
-   work for all i386 targets.  These functions will disappear in the
-   near future, so please don't use them.  */
-#ifdef LD_I387
-int
-i387_extract_floating (PTR addr, int len, DOUBLEST *dretptr)
-{
-  if (len == TARGET_LONG_DOUBLE_BIT / 8)
-    {
-      if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
-       {
-         DOUBLEST retval;
-
-         memcpy (dretptr, addr, sizeof (retval));
-       }
-      else
-       floatformat_to_doublest (TARGET_LONG_DOUBLE_FORMAT, addr, dretptr);
-
-      return 1;
-    }
-  else
-    return 0;
-}
-
-int
-i387_store_floating (PTR addr, int len, DOUBLEST val)
-{
-  if (len == TARGET_LONG_DOUBLE_BIT / 8)
-    {
-      /* This `if' may be totally stupid.  I just put it in here to be
-        absolutely sure I'm preserving the semantics of the code I'm
-        frobbing, while I try to maintain portability boundaries; I
-        don't actually know exactly what it's doing.  -JimB, May 1999 */
-      if (HOST_LONG_DOUBLE_FORMAT == TARGET_LONG_DOUBLE_FORMAT)
-       memcpy (addr, &val, sizeof (val));
-      else
-       floatformat_from_doublest (TARGET_LONG_DOUBLE_FORMAT, &val, addr);
-
-      return 1;
-    }
-  else
-    return 0;
-}
-#endif /* LD_I387 */
This page took 0.024555 seconds and 4 git commands to generate.