This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: e500 port: fix fpu_control.h constant values


On Thu, 26 Sep 2013, Joseph S. Myers wrote:

> e500 port testing shows that the values in the e500 case in
> fpu_control.h, which I took originally from the fpu_control.h in
> Aldy's SPE add-on, don't actually correspond correctly to bits in
> SPEFSCR.  I've no idea where the values in the SPE add-on originated,
> but this patch corrects various values to match the architecture
> documentation.
> 
> (Note: the _FPU_DEFAULT value is the one needed for correct operation;
> without exceptions enabled at the hardware level, you get such things
> as flush-to-zero of denormal operands causing libm functions to go
> into infinite loops, so can't run the testsuite.  I'll prepare a
> kernel patch to make the kernel actually use that as the default
> value; in the absence of such a kernel fix, glibc would need support
> for disabling the present assumption that the initial control word
> setting is _FPU_DEFAULT and __setfpucw doesn't need calling on startup
> unless __fpu_control has a different value.)

Please consider this patch as superseding the previous one.  The
default SPEFSCR value in the kernel is actually 0x3c (all traps
enabled except for "inexact"), and while I'm still debugging some
problems, I believe this should suffice as long as fesetround makes
sure to enable traps for "inexact" when setting a rounding mode other
than round-to-nearest or round-to-zero.

2013-09-27  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/powerpc/fpu_control.h [__NO_FPRS__ && !_SOFT_FLOAT]
	(_FPU_MASK_OM): Define as 0x04.
	[__NO_FPRS__ && !_SOFT_FLOAT] (_FPU_MASK_UM): Define as 0x08.
	[__NO_FPRS__ && !_SOFT_FLOAT] (_FPU_RESERVED): Define as
	0x00c10080.
	[__NO_FPRS__ && !_SOFT_FLOAT] (_FPU_DEFAULT): Define as
	0x0000003c.
	[__NO_FPRS__ && !_SOFT_FLOAT] (_FPU_IEEE): Define as _FPU_DEFAULT.

diff --git a/sysdeps/powerpc/fpu_control.h b/sysdeps/powerpc/fpu_control.h
index c61a2e1..d4f0613 100644
--- a/sysdeps/powerpc/fpu_control.h
+++ b/sysdeps/powerpc/fpu_control.h
@@ -38,20 +38,18 @@ extern fpu_control_t __fpu_control;
 
 /* masking of interrupts */
 # define _FPU_MASK_ZM  0x10 /* zero divide */
-# define _FPU_MASK_OM  0x40 /* overflow */
-# define _FPU_MASK_UM  0x80 /* underflow */
+# define _FPU_MASK_OM  0x04 /* overflow */
+# define _FPU_MASK_UM  0x08 /* underflow */
 # define _FPU_MASK_XM  0x40 /* inexact */
 # define _FPU_MASK_IM  0x20 /* invalid operation */
 
-# define _FPU_RESERVED 0xff3fff7f /* These bits are reserved and not changed. */
-
-/* The fdlibm code requires no interrupts for exceptions.  */
-# define _FPU_DEFAULT  0x00000000 /* Default value.  */
+# define _FPU_RESERVED 0x00c10080 /* These bits are reserved and not changed. */
 
-/* IEEE:  same as above, but (some) exceptions;
-   we leave the 'inexact' exception off.
- */
-# define _FPU_IEEE     0x000003c0
+/* Correct IEEE semantics require traps to be enabled at the hardware
+   level; the kernel then does the emulation and determines whether
+   generation of signals from those traps was enabled using prctl.  */
+# define _FPU_DEFAULT  0x0000003c /* Default value.  */
+# define _FPU_IEEE     _FPU_DEFAULT
 
 /* Type of the control word.  */
 typedef unsigned int fpu_control_t;

-- 
Joseph S. Myers
joseph@codesourcery.com


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