public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3] sparc: Force calculation that raises exception
@ 2024-01-16 15:16 Daniel Cederman
  2024-01-17 11:27 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Cederman @ 2024-01-16 15:16 UTC (permalink / raw)
  To: libc-alpha; +Cc: daniel, andreas

Use the math_force_eval() macro to force the calculation to complete and
raise the exception.

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

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

diff --git a/sysdeps/sparc/fpu/fraiseexcpt.c b/sysdeps/sparc/fpu/fraiseexcpt.c
index 26a7720ec9..642666c12a 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 <math-barriers.h>
 
 int
 __feraiseexcept (int excepts)
@@ -42,7 +43,7 @@ __feraiseexcept (int excepts)
       /* One example of an invalid operation is 0/0.  */
       __asm ("" : "=e" (d) : "0" (c.zero));
       d /= c.zero;
-      __asm __volatile ("" : : "e" (d));
+      math_force_eval (d);
     }
 
   /* Next: division by zero.  */
@@ -50,7 +51,7 @@ __feraiseexcept (int excepts)
     {
       __asm ("" : "=e" (d) : "0" (c.one));
       d /= c.zero;
-      __asm __volatile ("" : : "e" (d));
+      math_force_eval (d);
     }
 
   /* Next: overflow.  */
@@ -58,7 +59,7 @@ __feraiseexcept (int excepts)
     {
       __asm ("" : "=e" (d) : "0" (c.max));
       d *= d;
-      __asm __volatile ("" : : "e" (d));
+      math_force_eval (d);
     }
 
   /* Next: underflow.  */
@@ -66,7 +67,7 @@ __feraiseexcept (int excepts)
     {
       __asm ("" : "=e" (d) : "0" (c.min));
       d *= d;
-      __asm __volatile ("" : : "e" (d));
+      math_force_eval (d);
     }
 
   /* Last: inexact.  */
@@ -74,7 +75,7 @@ __feraiseexcept (int excepts)
     {
       __asm ("" : "=e" (d) : "0" (c.one));
       d /= c.pi;
-      __asm __volatile ("" : : "e" (d));
+      math_force_eval (d);
     }
 
   /* Success.  */
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] sparc: Force calculation that raises exception
  2024-01-16 15:16 [PATCH v3] sparc: Force calculation that raises exception Daniel Cederman
@ 2024-01-17 11:27 ` Adhemerval Zanella Netto
  0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella Netto @ 2024-01-17 11:27 UTC (permalink / raw)
  To: Daniel Cederman, libc-alpha; +Cc: daniel, andreas



On 16/01/24 12:16, Daniel Cederman wrote:
> Use the math_force_eval() macro to force the calculation to complete and
> raise the exception.
> 
> With this change the math/test-fenv test pass.
> 
> Signed-off-by: Daniel Cederman <cederman@gaisler.com>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/sparc/fpu/fraiseexcpt.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/sysdeps/sparc/fpu/fraiseexcpt.c b/sysdeps/sparc/fpu/fraiseexcpt.c
> index 26a7720ec9..642666c12a 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 <math-barriers.h>
>  
>  int
>  __feraiseexcept (int excepts)
> @@ -42,7 +43,7 @@ __feraiseexcept (int excepts)
>        /* One example of an invalid operation is 0/0.  */
>        __asm ("" : "=e" (d) : "0" (c.zero));
>        d /= c.zero;
> -      __asm __volatile ("" : : "e" (d));
> +      math_force_eval (d);
>      }
>  
>    /* Next: division by zero.  */
> @@ -50,7 +51,7 @@ __feraiseexcept (int excepts)
>      {
>        __asm ("" : "=e" (d) : "0" (c.one));
>        d /= c.zero;
> -      __asm __volatile ("" : : "e" (d));
> +      math_force_eval (d);
>      }
>  
>    /* Next: overflow.  */
> @@ -58,7 +59,7 @@ __feraiseexcept (int excepts)
>      {
>        __asm ("" : "=e" (d) : "0" (c.max));
>        d *= d;
> -      __asm __volatile ("" : : "e" (d));
> +      math_force_eval (d);
>      }
>  
>    /* Next: underflow.  */
> @@ -66,7 +67,7 @@ __feraiseexcept (int excepts)
>      {
>        __asm ("" : "=e" (d) : "0" (c.min));
>        d *= d;
> -      __asm __volatile ("" : : "e" (d));
> +      math_force_eval (d);
>      }
>  
>    /* Last: inexact.  */
> @@ -74,7 +75,7 @@ __feraiseexcept (int excepts)
>      {
>        __asm ("" : "=e" (d) : "0" (c.one));
>        d /= c.pi;
> -      __asm __volatile ("" : : "e" (d));
> +      math_force_eval (d);
>      }
>  
>    /* Success.  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-17 11:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 15:16 [PATCH v3] sparc: Force calculation that raises exception Daniel Cederman
2024-01-17 11:27 ` Adhemerval Zanella Netto

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).