public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: <libc-ports@sourceware.org>
Subject: Make ARM fesetenv (FE_NOMASK_ENV) detect failure (bug 14866)
Date: Wed, 21 Nov 2012 20:28:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.1211212027330.11924@digraph.polyomino.org.uk> (raw)

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

             reply	other threads:[~2012-11-21 20:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21 20:28 Joseph S. Myers [this message]
2012-11-21 21:57 ` Richard Henderson
2012-11-21 22:09   ` Joseph S. Myers
2012-11-21 22:17     ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1211212027330.11924@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=libc-ports@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).