Module: wine Branch: master Commit: 411b6f58426f86623bc21dcd98c848b45286abee URL: https://source.winehq.org/git/wine.git/?a=commit;h=411b6f58426f86623bc21dcd9...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Jun 3 16:28:56 2021 +0200
msvcrt: Import frexpf implementation from musl.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@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 50a3d820275..edc5f6363d3 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -1611,10 +1611,28 @@ float CDECL floorf( float x )
/********************************************************************* * frexpf (MSVCRT.@) + * + * Copied from musl: src/math/frexpf.c */ -float CDECL frexpf( float x, int *exp ) +float CDECL frexpf( float x, int *e ) { - return unix_funcs->frexpf( x, exp ); + UINT32 ux = *(UINT32*)&x; + int ee = ux >> 23 & 0xff; + + if (!ee) { + if (x) { + x = frexpf(x * 0x1p64, e); + *e -= 64; + } else *e = 0; + return x; + } else if (ee == 0xff) { + return x; + } + + *e = ee - 0x7e; + ux &= 0x807ffffful; + ux |= 0x3f000000ul; + return *(float*)&ux; }
/********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index 87b118f475d..742244bb287 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 }
-/********************************************************************* - * frexpf - */ -static float CDECL unix_frexpf( float x, int *exp ) -{ - return frexpf( x, exp ); -} - /********************************************************************* * hypot */ @@ -273,7 +265,6 @@ static const struct unix_funcs funcs = unix_exp2, unix_exp2f, unix_fmaf, - unix_frexpf, unix_hypot, unix_hypotf, unix_lgamma, diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h index 787393b47b8..9e44c49b691 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); - float (CDECL *frexpf)(float x, int *exp); double (CDECL *hypot)(double x, double y); float (CDECL *hypotf)(float x, float y); double (CDECL *lgamma)(double x);