msvcrt: Import _hypotf implementation from musl.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e55d341c17
commit
d86207c1d7
|
@ -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);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue