Piotr Caban : msvcrt: Import y0 implementation from musl.

Alexandre Julliard julliard at winehq.org
Wed Apr 28 16:18:48 CDT 2021


Module: wine
Branch: master
Commit: 8f8fa9182af7a2995940a5e17cf074bc849f2c0f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8f8fa9182af7a2995940a5e17cf074bc849f2c0f

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Apr 28 19:34:23 2021 +0200

msvcrt: Import y0 implementation from musl.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure             |  1 -
 configure.ac          |  1 -
 dlls/msvcrt/math.c    | 54 ++++++++++++++++++++++++++++++++++++++++-----------
 dlls/msvcrt/unixlib.c | 14 -------------
 dlls/msvcrt/unixlib.h |  1 -
 include/config.h.in   |  3 ---
 6 files changed, 43 insertions(+), 31 deletions(-)

diff --git a/configure b/configure
index c53edc9323b..14e4bc87ce9 100755
--- a/configure
+++ b/configure
@@ -19662,7 +19662,6 @@ for ac_func in \
 	tgammaf \
 	trunc \
 	truncf \
-	y0 \
 	y1 \
 	yn
 
diff --git a/configure.ac b/configure.ac
index 04f11623b79..daa7203748c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2706,7 +2706,6 @@ AC_CHECK_FUNCS(\
 	tgammaf \
 	trunc \
 	truncf \
-	y0 \
 	y1 \
 	yn
 )
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 4ffc0d25833..1355eb7998f 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -2696,18 +2696,50 @@ double CDECL _jn(int n, double num)
 /*********************************************************************
  *		_y0 (MSVCRT.@)
  */
-double CDECL _y0(double num)
-{
-  double retval;
+double CDECL _y0(double x)
+{
+    static const double tpi = 6.36619772367581382433e-01,
+        u00  = -7.38042951086872317523e-02,
+        u01  =  1.76666452509181115538e-01,
+        u02  = -1.38185671945596898896e-02,
+        u03  =  3.47453432093683650238e-04,
+        u04  = -3.81407053724364161125e-06,
+        u05  =  1.95590137035022920206e-08,
+        u06  = -3.98205194132103398453e-11,
+        v01  =  1.27304834834123699328e-02,
+        v02  =  7.60068627350353253702e-05,
+        v03  =  2.59150851840457805467e-07,
+        v04  =  4.41110311332675467403e-10;
+
+    double z, u, v;
+    unsigned int ix, lx;
 
-  if (!isfinite(num)) *_errno() = EDOM;
-  retval = unix_funcs->y0( num );
-  if (_fpclass(retval) == _FPCLASS_NINF)
-  {
-    *_errno() = EDOM;
-    retval = NAN;
-  }
-  return retval;
+    ix = *(ULONGLONG*)&x >> 32;
+    lx = *(ULONGLONG*)&x;
+
+    /* y0(nan)=nan, y0(<0)=nan, y0(0)=-inf, y0(inf)=0 */
+    if ((ix << 1 | lx) == 0)
+        return math_error(_OVERFLOW, "_y0", x, 0, -INFINITY);
+    if (isnan(x))
+        return x;
+    if (ix >> 31)
+        return math_error(_DOMAIN, "_y0", x, 0, 0 / (x - x));
+    if (ix >= 0x7ff00000)
+        return 1 / x;
+
+    if (ix >= 0x40000000) {  /* x >= 2 */
+        /* large ulp errors near zeros: 3.958, 7.086,.. */
+        return j0_y0_approx(ix, x, TRUE);
+    }
+
+    if (ix >= 0x3e400000) {  /* x >= 2**-27 */
+        /* large ulp error near the first zero, x ~= 0.89 */
+        z = x * x;
+        u = u00 + z * (u01 + z * (u02 + z * (u03 + z * (u04 + z * (u05 + z * u06)))));
+        v = 1.0 + z * (v01 + z * (v02 + z * (v03 + z * v04)));
+        return u / v + tpi * (j0(x) * log(x));
+    }
+    return u00 + tpi * log(x);
 }
 
 /*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index ed9b971c72a..8be8559337c 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -965,19 +965,6 @@ static float CDECL unix_tgammaf(float x)
 #endif
 }
 
-/*********************************************************************
- *      y0
- */
-static double CDECL unix_y0(double num)
-{
-#ifdef HAVE_Y0
-    return y0(num);
-#else
-    FIXME("not implemented\n");
-    return 0;
-#endif
-}
-
 /*********************************************************************
  *      y1
  */
@@ -1093,7 +1080,6 @@ static const struct unix_funcs funcs =
     unix_tgammaf,
     unix_trunc,
     unix_truncf,
-    unix_y0,
     unix_y1,
     unix_yn
 };
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 0c8182be2d6..6a23637c7e2 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -110,7 +110,6 @@ struct unix_funcs
     float           (CDECL *tgammaf)(float x);
     double          (CDECL *trunc)(double x);
     float           (CDECL *truncf)(float x);
-    double          (CDECL *y0)(double num);
     double          (CDECL *y1)(double num);
     double          (CDECL *yn)(int order, double num);
 };
diff --git a/include/config.h.in b/include/config.h.in
index 18368d52baf..a37ab5383ff 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1172,9 +1172,6 @@
 /* Define if Xrandr has the XRRGetProviderResources function */
 #undef HAVE_XRRGETPROVIDERRESOURCES
 
-/* Define to 1 if you have the `y0' function. */
-#undef HAVE_Y0
-
 /* Define to 1 if you have the `y1' function. */
 #undef HAVE_Y1
 




More information about the wine-cvs mailing list