This is the mail archive of the libc-alpha@sources.redhat.com 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]

[PATCH] ppc fegetexceptflag(), Add maskling of fenv.


Ulrich Drepper writes:

> Geoff Keating wrote:
> > On powerpc, the representation is defined to be in the format of the
> > FP environment register with bits other than those specified by
> > 'excepts' having undefined values.
>
> Exactly.  Indicated by flags, and nothing else.

As long as they use the definitions from sysdeps/powerpc/bits/fenv.h masking will work for powerpc and any additional instruction path is trivial.

> > and these are the only routines that interpret a fexcept_t.  So
> > there's no way a conforming program can tell that fegetexceptflag is
> > returning more information than requested.
>
> Of course there is.
> ...
>
>  fegetexceptflag (&ex, FE_INVALID);
>  fesetexceptflag (&ex, FE_ALL_EXCEPT);
>  r = fetestexcept (FE_DIVBYZERO);
>
> r must always be zero afterwards.  This is what the other archs do and
> ppc must follow.

The following patch adds the masking to bring PPC into compliance.

2003-12-04  Steven Munroe  <sjmunroe@us.ibm.com>

	* sysdeps/powerpc/fpu/fgetexcptflg.c (__fegetexceptflag): Add masking of fenv.
	* sysdeps/powerpc/nofpu/fgetexcptflg.c (__fegetexceptflag): Add masking of 
	fenv.

diff -urN libc23-cvstip-20031202/sysdeps/powerpc/fpu/fgetexcptflg.c libc23/sysdeps/powerpc/fpu/fgetexcptflg.c
--- libc23-cvstip-20031202/sysdeps/powerpc/fpu/fgetexcptflg.c	2001-07-05 23:56:02.000000000 -0500
+++ libc23/sysdeps/powerpc/fpu/fgetexcptflg.c	2003-12-03 14:31:35.000000000 -0600
@@ -29,7 +29,7 @@
   u.fenv = fegetenv_register ();
 
   /* Return (all of) it.  */
-  *flagp = u.l[1];
+  *flagp = u.l[1] & excepts & FE_ALL_EXCEPT;
 
   /* Success.  */
   return 0;
diff -urN libc23-cvstip-20031202/sysdeps/powerpc/nofpu/fgetexcptflg.c libc23/sysdeps/powerpc/nofpu/fgetexcptflg.c
--- libc23-cvstip-20031202/sysdeps/powerpc/nofpu/fgetexcptflg.c	2002-10-19 15:06:29.000000000 -0500
+++ libc23/sysdeps/powerpc/nofpu/fgetexcptflg.c	2003-12-03 14:31:42.000000000 -0600
@@ -24,7 +24,7 @@
 
 __fegetexceptflag (fexcept_t *flagp, int excepts)
 {
-  *flagp = (fexcept_t) __sim_exceptions;
+  *flagp = (fexcept_t) __sim_exceptions  & excepts & FE_ALL_EXCEPT;
 
   return 0;
 }

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