Piotr Caban : msvcrt: Import frexp implementation from musl.

Alexandre Julliard julliard at winehq.org
Thu Jun 3 16:23:09 CDT 2021


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Jun  3 16:28:52 2021 +0200

msvcrt: Import frexp implementation from musl.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/math.c    | 22 ++++++++++++++++++++--
 dlls/msvcrt/unixlib.c |  9 ---------
 dlls/msvcrt/unixlib.h |  1 -
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 596361c6729..50a3d820275 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -3494,10 +3494,28 @@ double CDECL fabs( double x )
 
 /*********************************************************************
  *		frexp (MSVCRT.@)
+ *
+ * Copied from musl: src/math/frexp.c
  */
-double CDECL frexp( double x, int *exp )
+double CDECL frexp( double x, int *e )
 {
-  return unix_funcs->frexp( x, exp );
+    UINT64 ux = *(UINT64*)&x;
+    int ee = ux >> 52 & 0x7ff;
+
+    if (!ee) {
+        if (x) {
+            x = frexp(x * 0x1p64, e);
+            *e -= 64;
+        } else *e = 0;
+        return x;
+    } else if (ee == 0x7ff) {
+        return x;
+    }
+
+    *e = ee - 0x3fe;
+    ux &= 0x800fffffffffffffull;
+    ux |= 0x3fe0000000000000ull;
+    return *(double*)&ux;
 }
 
 /*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index 25ebcac1736..87b118f475d 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -94,14 +94,6 @@ static float CDECL unix_fmaf( float x, float y, float z )
 #endif
 }
 
-/*********************************************************************
- *      frexp
- */
-static double CDECL unix_frexp( double x, int *exp )
-{
-    return frexp( x, exp );
-}
-
 /*********************************************************************
  *      frexpf
  */
@@ -281,7 +273,6 @@ static const struct unix_funcs funcs =
     unix_exp2,
     unix_exp2f,
     unix_fmaf,
-    unix_frexp,
     unix_frexpf,
     unix_hypot,
     unix_hypotf,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 202f8da44cd..787393b47b8 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -28,7 +28,6 @@ struct unix_funcs
     double          (CDECL *exp2)(double x);
     float           (CDECL *exp2f)(float x);
     float           (CDECL *fmaf)(float x, float y, float z);
-    double          (CDECL *frexp)(double x, int *exp);
     float           (CDECL *frexpf)(float x, int *exp);
     double          (CDECL *hypot)(double x, double y);
     float           (CDECL *hypotf)(float x, float y);




More information about the wine-cvs mailing list