Piotr Caban : msvcrt: Import _hypotf implementation from musl.
Alexandre Julliard
julliard at winehq.org
Thu Jun 3 16:23:09 CDT 2021
Module: wine
Branch: master
Commit: d86207c1d7c16042ecc4bc36daa8d2e1b667a793
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d86207c1d7c16042ecc4bc36daa8d2e1b667a793
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Jun 3 16:29:01 2021 +0200
msvcrt: Import _hypotf 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 | 33 +++++++++++++++++++++++++++++++--
dlls/msvcrt/unixlib.c | 9 ---------
dlls/msvcrt/unixlib.h | 1 -
3 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 4d53f51e2f7..a3ebc48d1f7 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -3263,11 +3263,40 @@ double CDECL _hypot(double x, double y)
/*********************************************************************
* _hypotf (MSVCRT.@)
+ *
+ * Copied from musl: src/math/hypotf.c
*/
float CDECL _hypotf(float x, float y)
{
- /* FIXME: errno handling */
- return unix_funcs->hypotf( x, y );
+ UINT32 ux = *(UINT32*)&x, uy = *(UINT32*)&y, ut;
+ float z;
+
+ ux &= -1U >> 1;
+ uy &= -1U >> 1;
+ if (ux < uy) {
+ ut = ux;
+ ux = uy;
+ uy = ut;
+ }
+
+ x = *(float*)&ux;
+ y = *(float*)&uy;
+ if (uy == 0xff << 23)
+ return y;
+ if (ux >= 0xff << 23 || uy == 0 || ux - uy >= 25 << 23)
+ return x + y;
+
+ z = 1;
+ if (ux >= (0x7f + 60) << 23) {
+ z = 0x1p90f;
+ x *= 0x1p-90f;
+ y *= 0x1p-90f;
+ } else if (uy < (0x7f - 60) << 23) {
+ z = 0x1p-90f;
+ x *= 0x1p90f;
+ y *= 0x1p90f;
+ }
+ return z * sqrtf((double)x * x + (double)y * y);
}
/*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index dff51ee8fd4..c52491d3b65 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
}
-/*********************************************************************
- * hypotf
- */
-static float CDECL unix_hypotf(float x, float y)
-{
- return hypotf( x, y );
-}
-
/*********************************************************************
* lgamma
*/
@@ -257,7 +249,6 @@ static const struct unix_funcs funcs =
unix_exp2,
unix_exp2f,
unix_fmaf,
- unix_hypotf,
unix_lgamma,
unix_lgammaf,
unix_log,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 2429bd0556d..8e229ab7014 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 *hypotf)(float x, float y);
double (CDECL *lgamma)(double x);
float (CDECL *lgammaf)(float x);
double (CDECL *log)(double x);
More information about the wine-cvs
mailing list