Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Improve comments about returning floats in i386-tdep.c
@ 2001-07-12 11:52 Mark Kettenis
  2001-07-12 23:58 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Kettenis @ 2001-07-12 11:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: eliz

Since it's a bit tricky, more comments don't hurt.

Is this better Eli?

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* i386-tdep.c (i386_extract_return_value): Undo 2001-07-11 changes
	to comment.
	(i386_store_return_value): Improve comments about storing
	floating-point return values.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.32
diff -u -p -r1.32 i386-tdep.c
--- i386-tdep.c 2001/07/11 08:43:41 1.32
+++ i386-tdep.c 2001/07/12 18:47:39
@@ -803,8 +803,7 @@ i386_extract_return_value (struct type *
 	  return;
 	}
 
-      /* Floating-point return values can be found in %st(0).
-         FIXME: Does %st(0) always correspond to FP0?  */
+      /* Floating-point return values can be found in %st(0).  */
       if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT
 	  && TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext)
 	{
@@ -870,7 +869,10 @@ i386_store_return_value (struct type *ty
 	  return;
 	}
 
-      /* Floating-point return values can be found in %st(0).  */
+      /* Returning floating-point values is a bit tricky.  Apart from
+         storing the return value in %st(0), we have to simulate the
+         state of the FPU at function return point.  */
+
       if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT
 	  && TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext)
 	{
@@ -884,7 +886,7 @@ i386_store_return_value (struct type *ty
 	  DOUBLEST val;
 
 	  /* Convert the value found in VALBUF to the extended
-             floating point format used by the FPU.  This is probably
+             floating-point format used by the FPU.  This is probably
              not exactly how it would happen on the target itself, but
              it is the best we can do.  */
 	  val = extract_floating (valbuf, TYPE_LENGTH (type));
@@ -893,14 +895,17 @@ i386_store_return_value (struct type *ty
 				FPU_REG_RAW_SIZE);
 	}
 
-      /* Set the top of the floating point register stack to 7.  That
-         makes sure that FP0 (which we set above) is indeed %st(0).
-         FIXME: Perhaps we should completely reset the status word?  */
+      /* Set the top of the floating-point register stack to 7.  The
+         actual value doesn't really matter, but 7 is what a normal
+         function return would end up with if the program started out
+         with a freshly initialized FPU.  */
       fstat = read_register (FSTAT_REGNUM);
       fstat |= (7 << 11);
       write_register (FSTAT_REGNUM, fstat);
 
-      /* Mark %st(1) through %st(7) as empty.  */
+      /* Mark %st(1) through %st(7) as empty.  Since we set the top of
+         the floating-point register stack to 7, the appropriate value
+         for the tag word is 0x3fff.  */
       write_register (FTAG_REGNUM, 0x3fff);
     }
   else


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Improve comments about returning floats in i386-tdep.c
  2001-07-12 11:52 [PATCH] Improve comments about returning floats in i386-tdep.c Mark Kettenis
@ 2001-07-12 23:58 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2001-07-12 23:58 UTC (permalink / raw)
  To: kettenis; +Cc: gdb-patches

> Date: Thu, 12 Jul 2001 20:51:51 +0200
> From: Mark Kettenis <kettenis@wins.uva.nl>
> 
> Since it's a bit tricky, more comments don't hurt.
> 
> Is this better Eli?

Yes, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-12 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-12 11:52 [PATCH] Improve comments about returning floats in i386-tdep.c Mark Kettenis
2001-07-12 23:58 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox