Piotr Caban : msvcrt: Import yn implementation from musl.
Alexandre Julliard
julliard at winehq.org
Thu Apr 29 16:38:32 CDT 2021
Module: wine
Branch: master
Commit: 30200117d2c3b0fd500deb375f58bafdb529fe6c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=30200117d2c3b0fd500deb375f58bafdb529fe6c
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Apr 29 17:06:25 2021 +0200
msvcrt: Import yn implementation from musl.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
configure | 3 +--
configure.ac | 3 +--
dlls/msvcrt/math.c | 72 ++++++++++++++++++++++++++++++++++++++++++++-------
dlls/msvcrt/unixlib.c | 16 +-----------
dlls/msvcrt/unixlib.h | 1 -
include/config.h.in | 3 ---
6 files changed, 65 insertions(+), 33 deletions(-)
diff --git a/configure b/configure
index 33e79ad04a4..429d97ebfdc 100755
--- a/configure
+++ b/configure
@@ -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`
diff --git a/configure.ac b/configure.ac
index 550da301100..e9dde0f9781 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2703,8 +2703,7 @@ AC_CHECK_FUNCS(\
tgamma \
tgammaf \
trunc \
- truncf \
- yn
+ truncf
)
LIBS="$ac_save_LIBS"
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 019fb836c07..5a0c0874ee5 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -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
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index c5e62613940..d62110c0006 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -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 )
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 48fc075d530..5f1f79d5e4b 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -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 */
diff --git a/include/config.h.in b/include/config.h.in
index 197d5c4b5f7..11f29fcf8bc 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -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
More information about the wine-cvs
mailing list