Alexandre Julliard : msvcrt: Import fabs() from musl.

Alexandre Julliard julliard at winehq.org
Tue Nov 17 15:04:07 CST 2020


Module: wine
Branch: master
Commit: 44e122e04e2f37ef11cded89ab3a8fd2369b2b03
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=44e122e04e2f37ef11cded89ab3a8fd2369b2b03

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Nov 17 09:58:19 2020 +0100

msvcrt: Import fabs() from musl.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/math.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 069a2f7f387..f5e933fc188 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -717,10 +717,14 @@ float CDECL MSVCRT_ceilf( float x )
 
 /*********************************************************************
  *      fabsf (MSVCRT.@)
+ *
+ * Copied from musl: src/math/fabsf.c
  */
 float CDECL MSVCRT_fabsf( float x )
 {
-  return fabsf(x);
+    union { float f; UINT32 i; } u = { x };
+    u.i &= 0x7fffffff;
+    return u.f;
 }
 
 /*********************************************************************
@@ -1610,10 +1614,14 @@ float CDECL MSVCRT_fmaf( float x, float y, float z )
 
 /*********************************************************************
  *		fabs (MSVCRT.@)
+ *
+ * Copied from musl: src/math/fabsf.c
  */
 double CDECL MSVCRT_fabs( double x )
 {
-  return fabs(x);
+    union { double f; UINT64 i; } u = { x };
+    u.i &= ~0ull >> 1;
+    return u.f;
 }
 
 /*********************************************************************




More information about the wine-cvs mailing list