This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfa/i387] Eliminate HOST_*_FORMAT from i387-tdep.c


Hello,

Very similar to my ARM tweek, this patch replaces a use of 
HOST_LONG_DOUBLE_FORMAT with more generic code.

There isn't a loss of precision since extract_floating() on i386 native 
should still do a memcopy().

	Andrew

(Disclaimers about testing apply, it does compile :-/ ).
2001-06-29  Andrew Cagney  <ac131313@redhat.com>

	* i387-tdep.c: Include "gdb_assert.h".
	(print_i387_value): Use extract_floating to extract the FP value
	from a zero padded local buffer.

Index: i387-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i387-tdep.c,v
retrieving revision 1.9
diff -p -r1.9 i387-tdep.c
*** i387-tdep.c	2001/03/09 16:14:55	1.9
--- i387-tdep.c	2001/06/29 16:39:04
***************
*** 27,32 ****
--- 27,33 ----
  #include "gdbcore.h"
  #include "floatformat.h"
  #include "regcache.h"
+ #include "gdb_assert.h"
  
  
  /* FIXME: Eliminate the next two functions when we have the time to
*************** static void
*** 160,181 ****
  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);
  
    /* 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
--- 161,177 ----
  print_i387_value (char *raw)
  {
    DOUBLEST value;
+   int len = TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT;
+   char *tmp = alloca (len);
  
!   /* Take care of the padding.  FP reg is 80 bits.  The same value in
!      memory is 96 bits. */
!   gdb_assert (FPU_REG_RAW_SIZE < len);
!   memcpy (&tmp, raw, FPU_REG_RAW_SIZE);
!   memset (&tmp + FPU_REG_RAW_SIZE, 0, len - FPU_REG_RAW_SIZE);
!   
!   /* Pull the value out. */
!   value = extract_floating (tmp, len);
  
    /* 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]