[36/40] sim/sh: Use fabs instead of abs

Message ID 1c1dc37d64784ff8fec4ab3e322f6b84693d8b92.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Commit ffa2d048221147bad30dde3cfbcb535a824b203d
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  Clang generates a warning if abs function is called with a floating point
argument ("-Wabsolute-value").  On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).

After careful investigation, it is concluded that replacing abs with fabs
is completely safe.
---
 sim/sh/interp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 2:17 p.m. UTC | #1
lgtm
-mike
  
Tsukasa OI Oct. 24, 2022, 10:56 a.m. UTC | #2
On 2022/10/23 23:17, Mike Frysinger wrote:
> lgtm
> -mike

I'll leave it for Andrew (PATCH 01/10) and I will withdraw following
patches from my patchset:

-   PATCH 03/40
-   PATCH 15/40
-   PATCH 16/40 (wrote by Andrew)
-   PATCH 28/40
-   PATCH 30/40
-   PATCH 36/40

Because this patchset (intended to be a RFC PATCH) is a mere copy of my
working branch, I need to sync with Andrew's work.

Thanks,
Tsukasa
  

Patch

diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index fb92d9f4480..38f3f945a35 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -1401,7 +1401,7 @@  fsca_s (int in, double (*f) (double))
   lower = result - error;
   frac = frexp (lower, &exp);
   lower = ldexp (ceil (ldexp (frac, 24)), exp - 24);
-  return abs (upper - result) >= abs (lower - result) ? upper : lower;
+  return fabs (upper - result) >= fabs (lower - result) ? upper : lower;
 }
 
 static float