[v3] sparc: Force calculation that raises exception

Message ID 20240116151641.3583965-1-cederman@gaisler.com
State Committed
Commit 45f7ea26c1d9145a9e024b8646592d405fb285e0
Headers
Series [v3] sparc: Force calculation that raises exception |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

Daniel Cederman Jan. 16, 2024, 3:16 p.m. UTC
  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(-)
  

Comments

Adhemerval Zanella Netto Jan. 17, 2024, 11:27 a.m. UTC | #1
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.  */
  

Patch

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.  */