msvcrt: Import tanhf 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
3171dccbef
commit
bb9f97c4d1
|
@ -1512,9 +1512,43 @@ float CDECL tanf( float x )
|
|||
*/
|
||||
float CDECL tanhf( float x )
|
||||
{
|
||||
float ret = unix_funcs->tanhf(x);
|
||||
if (!isfinite(x)) return math_error(_DOMAIN, "tanhf", x, 0, ret);
|
||||
return ret;
|
||||
UINT32 ui = *(UINT32*)&x;
|
||||
int sign;
|
||||
float t;
|
||||
|
||||
/* x = |x| */
|
||||
sign = ui >> 31;
|
||||
ui &= 0x7fffffff;
|
||||
x = *(float*)&ui;
|
||||
|
||||
if (ui > 0x3f0c9f54) {
|
||||
/* |x| > log(3)/2 ~= 0.5493 or nan */
|
||||
if (ui > 0x41200000) {
|
||||
#if _MSVCR_VER < 140
|
||||
if (isnan(x))
|
||||
return math_error(_DOMAIN, "tanhf", x, 0, x);
|
||||
#endif
|
||||
/* |x| > 10 */
|
||||
fp_barrierf(x + 0x1p120f);
|
||||
t = 1 + 0 / x;
|
||||
} else {
|
||||
t = __expm1f(2 * x);
|
||||
t = 1 - 2 / (t + 2);
|
||||
}
|
||||
} else if (ui > 0x3e82c578) {
|
||||
/* |x| > log(5/3)/2 ~= 0.2554 */
|
||||
t = __expm1f(2 * x);
|
||||
t = t / (t + 2);
|
||||
} else if (ui >= 0x00800000) {
|
||||
/* |x| >= 0x1p-126 */
|
||||
t = __expm1f(-2 * x);
|
||||
t = -t / (t + 2);
|
||||
} else {
|
||||
/* |x| is subnormal */
|
||||
fp_barrierf(x * x);
|
||||
t = x;
|
||||
}
|
||||
return sign ? -t : t;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
|
@ -268,14 +268,6 @@ static float CDECL unix_powf( float x, float y )
|
|||
return powf( x, y );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* tanhf
|
||||
*/
|
||||
static float CDECL unix_tanhf( float x )
|
||||
{
|
||||
return tanhf( x );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* tgamma
|
||||
*/
|
||||
|
@ -327,7 +319,6 @@ static const struct unix_funcs funcs =
|
|||
unix_log2f,
|
||||
unix_pow,
|
||||
unix_powf,
|
||||
unix_tanhf,
|
||||
unix_tgamma,
|
||||
unix_tgammaf,
|
||||
};
|
||||
|
|
|
@ -46,7 +46,6 @@ struct unix_funcs
|
|||
float (CDECL *log2f)(float x);
|
||||
double (CDECL *pow)(double x, double y);
|
||||
float (CDECL *powf)(float x, float y);
|
||||
float (CDECL *tanhf)(float x);
|
||||
double (CDECL *tgamma)(double x);
|
||||
float (CDECL *tgammaf)(float x);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue