[v2,1/2] sparc: Use existing macros to avoid code duplication

Message ID 20240115145345.3389246-2-cederman@gaisler.com
State Committed
Commit 3bb1350c3681c5ca330dd92500dc59fba94b37eb
Headers
Series [v2] 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
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. 15, 2024, 2:53 p.m. UTC
  Macros for using inline assembly to access the fp state register exists
in both fenv_private.h and in fpu_control.h. Let fenv_private.h use the
macros from fpu_control.h

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

Comments

Adhemerval Zanella Netto Jan. 16, 2024, 1:59 p.m. UTC | #1
On 15/01/24 11:53, Daniel Cederman wrote:
> Macros for using inline assembly to access the fp state register exists
> in both fenv_private.h and in fpu_control.h. Let fenv_private.h use the
> macros from fpu_control.h
> 
> Signed-off-by: Daniel Cederman <cederman@gaisler.com>

LGTM, thanks.

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

> ---
>  sysdeps/sparc/fpu/fenv_private.h | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/sysdeps/sparc/fpu/fenv_private.h b/sysdeps/sparc/fpu/fenv_private.h
> index da7c7fe332..a31ba3cc7b 100644
> --- a/sysdeps/sparc/fpu/fenv_private.h
> +++ b/sysdeps/sparc/fpu/fenv_private.h
> @@ -2,15 +2,11 @@
>  #define SPARC_FENV_PRIVATE_H 1
>  
>  #include <fenv.h>
> +#include <fpu_control.h>
>  
>  /* For internal use only: access the fp state register.  */
> -#if __WORDSIZE == 64
> -# define __fenv_stfsr(X)   __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (X))
> -# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (X))
> -#else
> -# define __fenv_stfsr(X)   __asm__ __volatile__ ("st %%fsr,%0" : "=m" (X))
> -# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (X))
> -#endif
> +#define __fenv_stfsr(X)   _FPU_GETCW (X)
> +#define __fenv_ldfsr(X)   _FPU_SETCW (X)
>  
>  static __always_inline void
>  libc_feholdexcept (fenv_t *e)
  

Patch

diff --git a/sysdeps/sparc/fpu/fenv_private.h b/sysdeps/sparc/fpu/fenv_private.h
index da7c7fe332..a31ba3cc7b 100644
--- a/sysdeps/sparc/fpu/fenv_private.h
+++ b/sysdeps/sparc/fpu/fenv_private.h
@@ -2,15 +2,11 @@ 
 #define SPARC_FENV_PRIVATE_H 1
 
 #include <fenv.h>
+#include <fpu_control.h>
 
 /* For internal use only: access the fp state register.  */
-#if __WORDSIZE == 64
-# define __fenv_stfsr(X)   __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (X))
-# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (X))
-#else
-# define __fenv_stfsr(X)   __asm__ __volatile__ ("st %%fsr,%0" : "=m" (X))
-# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (X))
-#endif
+#define __fenv_stfsr(X)   _FPU_GETCW (X)
+#define __fenv_ldfsr(X)   _FPU_SETCW (X)
 
 static __always_inline void
 libc_feholdexcept (fenv_t *e)