[powerpc] fegetexcept: utilize function instead of duplicating code

Message ID 1559743868-6873-1-git-send-email-pc@us.ibm.com
State Committed
Headers

Commit Message

Paul A. Clarke June 5, 2019, 2:11 p.m. UTC
  From: "Paul A. Clarke" <pc@us.ibm.com>

fegetexcept() included code which exactly duplicates the code in
fenv_reg_to_exceptions().  Replace with a call to that function.

2019-06-05  Paul A. Clarke  <pc@us.ibm.com>

	* sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Replace code
	with call to equivalent function.
---
 sysdeps/powerpc/fpu/fegetexcept.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
  

Comments

Adhemerval Zanella Netto June 5, 2019, 5:55 p.m. UTC | #1
On 05/06/2019 11:11, Paul A. Clarke wrote:
> From: "Paul A. Clarke" <pc@us.ibm.com>
> 
> fegetexcept() included code which exactly duplicates the code in
> fenv_reg_to_exceptions().  Replace with a call to that function.
> 
> 2019-06-05  Paul A. Clarke  <pc@us.ibm.com>
> 
> 	* sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Replace code
> 	with call to equivalent function.

LGTM.

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

> ---
>  sysdeps/powerpc/fpu/fegetexcept.c | 14 +-------------
>  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> diff --git a/sysdeps/powerpc/fpu/fegetexcept.c b/sysdeps/powerpc/fpu/fegetexcept.c
> index daa8812..2173d77 100644
> --- a/sysdeps/powerpc/fpu/fegetexcept.c
> +++ b/sysdeps/powerpc/fpu/fegetexcept.c
> @@ -23,21 +23,9 @@ int
>  __fegetexcept (void)
>  {
>    fenv_union_t fe;
> -  int result = 0;
>  
>    fe.fenv = fegetenv_register ();
>  
> -  if (fe.l & (1 << (31 - FPSCR_XE)))
> -      result |= FE_INEXACT;
> -  if (fe.l & (1 << (31 - FPSCR_ZE)))
> -      result |= FE_DIVBYZERO;
> -  if (fe.l & (1 << (31 - FPSCR_UE)))
> -      result |= FE_UNDERFLOW;
> -  if (fe.l & (1 << (31 - FPSCR_OE)))
> -      result |= FE_OVERFLOW;
> -  if (fe.l & (1 << (31 - FPSCR_VE)))
> -      result |= FE_INVALID;
> -
> -  return result;
> +  return fenv_reg_to_exceptions (fe.l);
>  }
>  weak_alias (__fegetexcept, fegetexcept)
>
  

Patch

diff --git a/sysdeps/powerpc/fpu/fegetexcept.c b/sysdeps/powerpc/fpu/fegetexcept.c
index daa8812..2173d77 100644
--- a/sysdeps/powerpc/fpu/fegetexcept.c
+++ b/sysdeps/powerpc/fpu/fegetexcept.c
@@ -23,21 +23,9 @@  int
 __fegetexcept (void)
 {
   fenv_union_t fe;
-  int result = 0;
 
   fe.fenv = fegetenv_register ();
 
-  if (fe.l & (1 << (31 - FPSCR_XE)))
-      result |= FE_INEXACT;
-  if (fe.l & (1 << (31 - FPSCR_ZE)))
-      result |= FE_DIVBYZERO;
-  if (fe.l & (1 << (31 - FPSCR_UE)))
-      result |= FE_UNDERFLOW;
-  if (fe.l & (1 << (31 - FPSCR_OE)))
-      result |= FE_OVERFLOW;
-  if (fe.l & (1 << (31 - FPSCR_VE)))
-      result |= FE_INVALID;
-
-  return result;
+  return fenv_reg_to_exceptions (fe.l);
 }
 weak_alias (__fegetexcept, fegetexcept)