msvcrt: Import yn implementation from musl.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-04-29 17:06:25 +02:00 committed by Alexandre Julliard
parent 0a105999a2
commit 30200117d2
6 changed files with 65 additions and 33 deletions

3
configure vendored
View File

@ -19660,8 +19660,7 @@ for ac_func in \
tgamma \
tgammaf \
trunc \
truncf \
yn
truncf
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`

View File

@ -2703,8 +2703,7 @@ AC_CHECK_FUNCS(\
tgamma \
tgammaf \
trunc \
truncf \
yn
truncf
)
LIBS="$ac_save_LIBS"

View File

@ -3135,19 +3135,71 @@ double CDECL _y1(double x)
/*********************************************************************
* _yn (MSVCRT.@)
*
* Copied from musl: src/math/jn.c
*/
double CDECL _yn(int order, double num)
double CDECL _yn(int n, double x)
{
double retval;
static const double invsqrtpi = 5.64189583547756279280e-01;
if (!isfinite(num)) *_errno() = EDOM;
retval = unix_funcs->yn( order, num );
if (_fpclass(retval) == _FPCLASS_NINF)
{
*_errno() = EDOM;
retval = NAN;
}
return retval;
unsigned int ix, lx, ib;
int nm1, sign, i;
double a, b, temp;
ix = *(ULONGLONG*)&x >> 32;
lx = *(ULONGLONG*)&x;
sign = ix >> 31;
ix &= 0x7fffffff;
if ((ix | (lx | -lx) >> 31) > 0x7ff00000) /* nan */
return x;
if (sign && (ix | lx) != 0) /* x < 0 */
return math_error(_DOMAIN, "_y1", x, 0, 0 / (x - x));
if (ix == 0x7ff00000)
return 0.0;
if (n == 0)
return y0(x);
if (n < 0) {
nm1 = -(n + 1);
sign = n & 1;
} else {
nm1 = n - 1;
sign = 0;
}
if (nm1 == 0)
return sign ? -y1(x) : y1(x);
if (ix >= 0x52d00000) { /* x > 2**302 */
switch(nm1 & 3) {
case 0:
temp = -sin(x) - cos(x);
break;
case 1:
temp = -sin(x) + cos(x);
break;
case 2:
temp = sin(x) + cos(x);
break;
default:
temp = sin(x) - cos(x);
break;
}
b = invsqrtpi * temp / sqrt(x);
} else {
a = y0(x);
b = y1(x);
/* quit if b is -inf */
ib = *(ULONGLONG*)&b >> 32;
for (i = 0; i < nm1 && ib != 0xfff00000;) {
i++;
temp = b;
b = (2.0 * i / x) * b - a;
ib = *(ULONGLONG*)&b >> 32;
a = temp;
}
}
return sign ? -b : b;
}
#if _MSVCR_VER>=120

View File

@ -939,19 +939,6 @@ static float CDECL unix_tgammaf(float x)
#endif
}
/*********************************************************************
* yn
*/
static double CDECL unix_yn(int order, double num)
{
#ifdef HAVE_YN
return yn(order,num);
#else
FIXME("not implemented\n");
return 0;
#endif
}
static const struct unix_funcs funcs =
{
unix_acosh,
@ -1038,8 +1025,7 @@ static const struct unix_funcs funcs =
unix_tgamma,
unix_tgammaf,
unix_trunc,
unix_truncf,
unix_yn
unix_truncf
};
NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )

View File

@ -108,7 +108,6 @@ struct unix_funcs
float (CDECL *tgammaf)(float x);
double (CDECL *trunc)(double x);
float (CDECL *truncf)(float x);
double (CDECL *yn)(int order, double num);
};
#endif /* __UNIXLIB_H */

View File

@ -1166,9 +1166,6 @@
/* Define if Xrandr has the XRRGetProviderResources function */
#undef HAVE_XRRGETPROVIDERRESOURCES
/* Define to 1 if you have the `yn' function. */
#undef HAVE_YN
/* Define to 1 if you have the `_spawnvp' function. */
#undef HAVE__SPAWNVP