public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Daniel Cederman <cederman@gaisler.com>
To: libc-alpha@sourceware.org
Cc: daniel@gaisler.com, andreas@gaisler.com
Subject: [PATCH] sparc: Force calculation that raises exception
Date: Fri, 12 Jan 2024 10:26:25 +0100	[thread overview]
Message-ID: <20240112092628.2464455-3-cederman@gaisler.com> (raw)
In-Reply-To: <20240112092628.2464455-1-cederman@gaisler.com>

Read out the FPU control word to force the calculation to complete and
raise the exception.

With this change the math/test-fenv test pass for LEON.

Signed-off-by: Daniel Cederman <cederman@gaisler.com>
---
 sysdeps/sparc/fpu/fraiseexcpt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sysdeps/sparc/fpu/fraiseexcpt.c b/sysdeps/sparc/fpu/fraiseexcpt.c
index 26a7720ec9..43176cf6a3 100644
--- a/sysdeps/sparc/fpu/fraiseexcpt.c
+++ b/sysdeps/sparc/fpu/fraiseexcpt.c
@@ -20,6 +20,7 @@
 #include <float.h>
 #include <math.h>
 #include <shlib-compat.h>
+#include <fpu_control.h>
 
 int
 __feraiseexcept (int excepts)
@@ -30,6 +31,7 @@ __feraiseexcept (int excepts)
     0.0, 1.0, DBL_MAX, DBL_MIN, M_PI
   };
   double d;
+  fpu_control_t cw;
 
   /* Raise exceptions represented by EXPECTS.  But we must raise only
      one signal at a time.  It is important the if the overflow/underflow
@@ -43,6 +45,7 @@ __feraiseexcept (int excepts)
       __asm ("" : "=e" (d) : "0" (c.zero));
       d /= c.zero;
       __asm __volatile ("" : : "e" (d));
+      _FPU_GETCW(cw);
     }
 
   /* Next: division by zero.  */
@@ -51,6 +54,7 @@ __feraiseexcept (int excepts)
       __asm ("" : "=e" (d) : "0" (c.one));
       d /= c.zero;
       __asm __volatile ("" : : "e" (d));
+      _FPU_GETCW(cw);
     }
 
   /* Next: overflow.  */
@@ -59,6 +63,7 @@ __feraiseexcept (int excepts)
       __asm ("" : "=e" (d) : "0" (c.max));
       d *= d;
       __asm __volatile ("" : : "e" (d));
+      _FPU_GETCW(cw);
     }
 
   /* Next: underflow.  */
@@ -67,6 +72,7 @@ __feraiseexcept (int excepts)
       __asm ("" : "=e" (d) : "0" (c.min));
       d *= d;
       __asm __volatile ("" : : "e" (d));
+      _FPU_GETCW(cw);
     }
 
   /* Last: inexact.  */
@@ -75,6 +81,7 @@ __feraiseexcept (int excepts)
       __asm ("" : "=e" (d) : "0" (c.one));
       d /= c.pi;
       __asm __volatile ("" : : "e" (d));
+      _FPU_GETCW(cw);
     }
 
   /* Success.  */
-- 
2.40.1


  parent reply	other threads:[~2024-01-12  9:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  9:26 [PATCH] sparc: Do not test preservation of NaN payloads for LEON Daniel Cederman
2024-01-12  9:26 ` [PATCH] sparc: Prevent stfsr from directly following floating-point instruction Daniel Cederman
2024-01-12 14:38   ` Adhemerval Zanella Netto
2024-01-15  9:37     ` Daniel Cederman
2024-01-12  9:26 ` Daniel Cederman [this message]
2024-01-12 16:45   ` [PATCH] sparc: Force calculation that raises exception Adhemerval Zanella Netto
2024-01-15  9:41     ` Daniel Cederman
2024-01-15 11:47       ` Adhemerval Zanella Netto
2024-01-12  9:26 ` [PATCH] sparc: Treat the version field in the FPU control word as reserved Daniel Cederman
2024-01-12 17:42   ` Adhemerval Zanella Netto
2024-02-15  9:31     ` Daniel Cederman
2024-02-19 14:55       ` Adhemerval Zanella Netto
2024-01-12  9:26 ` [PATCH] sparc: Fix llrint and llround missing exceptions on SPARC32 Daniel Cederman
2024-01-12 18:05   ` Adhemerval Zanella Netto
2024-01-15 14:38     ` Daniel Cederman
2024-01-15 17:52       ` Adhemerval Zanella Netto
2024-01-12  9:26 ` [PATCH] sparc: Remove unwind information from signal return stub functions Daniel Cederman
2024-01-15 13:41   ` Adhemerval Zanella Netto
2024-01-15 14:22     ` Daniel Cederman
2024-01-15 16:57       ` Adhemerval Zanella Netto
2024-01-16 15:37 ` [PATCH] sparc: Do not test preservation of NaN payloads for LEON Adhemerval Zanella Netto

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=20240112092628.2464455-3-cederman@gaisler.com \
    --to=cederman@gaisler.com \
    --cc=andreas@gaisler.com \
    --cc=daniel@gaisler.com \
    --cc=libc-alpha@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).