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

Make ARM fesetenv (FE_NOMASK_ENV) detect failure (bug 14866)


As discussed in the thread starting at
<http://sourceware.org/ml/libc-ports/2012-06/msg00021.html>, ARM VFPv3
and VFPv4 do not support trapping floating-point exceptions, and
fesetenv (FE_NOMASK_ENV) should return nonzero (failure) in such a
case, but does not do so, and as suggested by Richard Henderson and
detailed in
<http://sourceware.org/ml/libc-ports/2012-06/msg00091.html>, this can
be achieved by reading back the relevant bits and seeing if they were
successfully set.  I've applied this patch (tested for both VFPv2 and
VFPv3) to fix this issue in that way.

2012-11-21  Joseph Myers  <joseph@codesourcery.com>

	[BZ #14866]
	* sysdeps/arm/fesetenv.c (__fesetenv): Test whether bits for
	trapping exceptions were successfully set for FE_NOMASK_ENV.

diff --git a/ports/sysdeps/arm/fesetenv.c b/ports/sysdeps/arm/fesetenv.c
index 2fad61d..e92f9f5 100644
--- a/ports/sysdeps/arm/fesetenv.c
+++ b/ports/sysdeps/arm/fesetenv.c
@@ -40,6 +40,16 @@ __fesetenv (const fenv_t *envp)
 
       _FPU_SETCW (temp);
 
+      if (envp == FE_NOMASK_ENV)
+	{
+	  /* VFPv3 and VFPv4 do not support trapping exceptions, so
+	     test whether the relevant bits were set and fail if
+	     not.  */
+	  _FPU_GETCW (temp);
+	  if ((temp & _FPU_IEEE) != _FPU_IEEE)
+	    return 1;
+	}
+
       /* Success.  */
       return 0;
     }

-- 
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]