winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
April 2023
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
817 discussions
Start a n
N
ew thread
Alexandre Julliard : msvcrt: Use the log1p()/log1pf() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: 714874ba469ece719c6fcf5e7ee9aee47e03bae2 URL:
https://gitlab.winehq.org/wine/wine/-/commit/714874ba469ece719c6fcf5e7ee9ae…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Apr 4 17:59:33 2023 +0200 msvcrt: Use the log1p()/log1pf() implementation from the bundled musl library. --- dlls/msvcrt/math.c | 144 -------------------------------------------- libs/musl/src/math/log1p.c | 6 +- libs/musl/src/math/log1pf.c | 5 +- 3 files changed, 9 insertions(+), 146 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 60d85bc7be7..0f9a415d88c 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -5496,150 +5496,6 @@ void __cdecl __libm_sse2_sqrt_precise(void) #if _MSVCR_VER>=120 -/********************************************************************* - * log1p (MSVCR120.@) - * - * Copied from musl: src/math/log1p.c - */ -double CDECL log1p(double x) -{ - static const double ln2_hi = 6.93147180369123816490e-01, - ln2_lo = 1.90821492927058770002e-10, - Lg1 = 6.666666666666735130e-01, - Lg2 = 3.999999999940941908e-01, - Lg3 = 2.857142874366239149e-01, - Lg4 = 2.222219843214978396e-01, - Lg5 = 1.818357216161805012e-01, - Lg6 = 1.531383769920937332e-01, - Lg7 = 1.479819860511658591e-01; - - union {double f; UINT64 i;} u = {x}; - double hfsq, f, c, s, z, R, w, t1, t2, dk; - UINT32 hx, hu; - int k; - - hx = u.i >> 32; - k = 1; - if (hx < 0x3fda827a || hx >> 31) { /* 1+x < sqrt(2)+ */ - if (hx >= 0xbff00000) { /* x <= -1.0 */ - if (x == -1) { - *_errno() = ERANGE; - return x / 0.0; /* og1p(-1) = -inf */ - } - *_errno() = EDOM; - return (x-x) / 0.0; /* log1p(x<-1) = NaN */ - } - if (hx << 1 < 0x3ca00000 << 1) { /* |x| < 2**-53 */ - fp_barrier(x + 0x1p120f); - /* underflow if subnormal */ - if ((hx & 0x7ff00000) == 0) - fp_barrierf(x); - return x; - } - if (hx <= 0xbfd2bec4) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */ - k = 0; - c = 0; - f = x; - } - } else if (hx >= 0x7ff00000) - return x; - if (k) { - u.f = 1 + x; - hu = u.i >> 32; - hu += 0x3ff00000 - 0x3fe6a09e; - k = (int)(hu >> 20) - 0x3ff; - /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ - if (k < 54) { - c = k >= 2 ? 1 - (u.f - x) : x - (u.f - 1); - c /= u.f; - } else - c = 0; - /* reduce u into [sqrt(2)/2, sqrt(2)] */ - hu = (hu & 0x000fffff) + 0x3fe6a09e; - u.i = (UINT64)hu << 32 | (u.i & 0xffffffff); - f = u.f - 1; - } - hfsq = 0.5 * f * f; - s = f / (2.0 + f); - z = s * s; - w = z * z; - t1 = w * (Lg2 + w * (Lg4 + w * Lg6)); - t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7))); - R = t2 + t1; - dk = k; - return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; -} - -/********************************************************************* - * log1pf (MSVCR120.@) - * - * Copied from musl: src/math/log1pf.c - */ -float CDECL log1pf(float x) -{ - static const float ln2_hi = 6.9313812256e-01, - ln2_lo = 9.0580006145e-06, - Lg1 = 0xaaaaaa.0p-24, - Lg2 = 0xccce13.0p-25, - Lg3 = 0x91e9ee.0p-25, - Lg4 = 0xf89e26.0p-26; - - union {float f; UINT32 i;} u = {x}; - float hfsq, f, c, s, z, R, w, t1, t2, dk; - UINT32 ix, iu; - int k; - - ix = u.i; - k = 1; - if (ix < 0x3ed413d0 || ix >> 31) { /* 1+x < sqrt(2)+ */ - if (ix >= 0xbf800000) { /* x <= -1.0 */ - if (x == -1) { - *_errno() = ERANGE; - return x / 0.0f; /* log1p(-1)=+inf */ - } - *_errno() = EDOM; - return (x - x) / 0.0f; /* log1p(x<-1)=NaN */ - } - if (ix<<1 < 0x33800000<<1) { /* |x| < 2**-24 */ - /* underflow if subnormal */ - if ((ix & 0x7f800000) == 0) - fp_barrierf(x * x); - return x; - } - if (ix <= 0xbe95f619) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */ - k = 0; - c = 0; - f = x; - } - } else if (ix >= 0x7f800000) - return x; - if (k) { - u.f = 1 + x; - iu = u.i; - iu += 0x3f800000 - 0x3f3504f3; - k = (int)(iu >> 23) - 0x7f; - /* correction term ~ log(1+x)-log(u), avoid underflow in c/u */ - if (k < 25) { - c = k >= 2 ? 1 - (u.f - x) : x - (u.f - 1); - c /= u.f; - } else - c = 0; - /* reduce u into [sqrt(2)/2, sqrt(2)] */ - iu = (iu & 0x007fffff) + 0x3f3504f3; - u.i = iu; - f = u.f - 1; - } - s = f / (2.0f + f); - z = s * s; - w = z * z; - t1= w * (Lg2 + w * Lg4); - t2= z * (Lg1 + w * Lg3); - R = t2 + t1; - hfsq = 0.5f * f * f; - dk = k; - return s * (hfsq + R) + (dk * ln2_lo + c) - hfsq + f + dk * ln2_hi; -} - /********************************************************************* * log2 (MSVCR120.@) * diff --git a/libs/musl/src/math/log1p.c b/libs/musl/src/math/log1p.c index 9376b13ed6a..e206f17ad5e 100644 --- a/libs/musl/src/math/log1p.c +++ b/libs/musl/src/math/log1p.c @@ -77,11 +77,15 @@ double __cdecl log1p(double x) k = 1; if (hx < 0x3fda827a || hx>>31) { /* 1+x < sqrt(2)+ */ if (hx >= 0xbff00000) { /* x <= -1.0 */ - if (x == -1) + if (x == -1) { + errno = ERANGE; return x/0.0; /* log1p(-1) = -inf */ + } + errno = EDOM; return (x-x)/0.0; /* log1p(x<-1) = NaN */ } if (hx<<1 < 0x3ca00000<<1) { /* |x| < 2**-53 */ + fp_barrier(x + 0x1p120f); /* underflow if subnormal */ if ((hx&0x7ff00000) == 0) FORCE_EVAL((float)x); diff --git a/libs/musl/src/math/log1pf.c b/libs/musl/src/math/log1pf.c index e2cda58438b..9637f672e20 100644 --- a/libs/musl/src/math/log1pf.c +++ b/libs/musl/src/math/log1pf.c @@ -32,8 +32,11 @@ float __cdecl log1pf(float x) k = 1; if (ix < 0x3ed413d0 || ix>>31) { /* 1+x < sqrt(2)+ */ if (ix >= 0xbf800000) { /* x <= -1.0 */ - if (x == -1) + if (x == -1) { + errno = ERANGE; return x/0.0f; /* log1p(-1)=+inf */ + } + errno = EDOM; return (x-x)/0.0f; /* log1p(x<-1)=NaN */ } if (ix<<1 < 0x33800000<<1) { /* |x| < 2**-24 */
1
0
0
0
Alexandre Julliard : msvcrt: Use the exp2()/exp2f() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: ca0643875961ef62c76e0b9cbd0433002a948d9b URL:
https://gitlab.winehq.org/wine/wine/-/commit/ca0643875961ef62c76e0b9cbd0433…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Apr 4 17:49:05 2023 +0200 msvcrt: Use the exp2()/exp2f() implementation from the bundled musl library. --- dlls/msvcrt/math.c | 169 --------------------------------------------- libs/musl/src/math/exp2.c | 17 +++-- libs/musl/src/math/exp2f.c | 12 ++-- 3 files changed, 21 insertions(+), 177 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 25cf2e05ccd..60d85bc7be7 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -488,7 +488,6 @@ static double __round(double x) return *(double*)&llx; } -#if !defined(__i386__) || _MSVCR_VER >= 120 #ifndef __i386__ /* Copied from musl: src/math/__sindf.c */ static float __sindf(double x) @@ -525,7 +524,6 @@ static float __cosdf(double x) return 1 + C0 * z; return 1.0 + z * (C0 + z * (C1 + z * (C2 + z * (C3 + z * C4)))); } -#endif static const UINT64 exp2f_T[] = { 0x3ff0000000000000ULL, 0x3fefd9b0d3158574ULL, 0x3fefb5586cf9890fULL, 0x3fef9301d0125b51ULL, @@ -5498,173 +5496,6 @@ void __cdecl __libm_sse2_sqrt_precise(void) #if _MSVCR_VER>=120 -/********************************************************************* - * exp2 (MSVCR120.@) - * - * Copied from musl: src/math/exp2.c - */ -double CDECL exp2(double x) -{ - static const double C[] = { - 0x1.62e42fefa39efp-1, - 0x1.ebfbdff82c424p-3, - 0x1.c6b08d70cf4b5p-5, - 0x1.3b2abd24650ccp-7, - 0x1.5d7e09b4e3a84p-10 - }; - - UINT32 abstop; - UINT64 ki, idx, top, sbits; - double kd, r, r2, scale, tail, tmp; - - abstop = (*(UINT64*)&x >> 52) & 0x7ff; - if (abstop - 0x3c9 >= 0x408 - 0x3c9) { - if (abstop - 0x3c9 >= 0x80000000) { - /* Avoid spurious underflow for tiny x. */ - /* Note: 0 is common input. */ - return 1.0 + x; - } - if (abstop >= 409) { - if (*(UINT64*)&x == 0xfff0000000000000ull) - return 0.0; - if (abstop >= 0x7ff) - return 1.0 + x; - if (!(*(UINT64*)&x >> 63)) { - *_errno() = ERANGE; - return fp_barrier(DBL_MAX) * DBL_MAX; - } - else if (x <= -2147483648.0) { - fp_barrier(x + 0x1p120f); - return 0; - } - else if (*(UINT64*)&x >= 0xc090cc0000000000ull) { - *_errno() = ERANGE; - fp_barrier(x + 0x1p120f); - return 0; - } - } - if (2 * *(UINT64*)&x > 2 * 0x408d000000000000ull) - /* Large x is special cased below. */ - abstop = 0; - } - - /* exp2(x) = 2^(k/N) * 2^r, with 2^r in [2^(-1/2N),2^(1/2N)]. */ - /* x = k/N + r, with int k and r in [-1/2N, 1/2N]. */ - kd = fp_barrier(x + 0x1.8p52 / (1 << 7)); - ki = *(UINT64*)&kd; /* k. */ - kd -= 0x1.8p52 / (1 << 7); /* k/N for int k. */ - r = x - kd; - /* 2^(k/N) ~= scale * (1 + tail). */ - idx = 2 * (ki % (1 << 7)); - top = ki << (52 - 7); - tail = *(double*)&exp_T[idx]; - /* This is only a valid scale when -1023*N < k < 1024*N. */ - sbits = exp_T[idx + 1] + top; - /* exp2(x) = 2^(k/N) * 2^r ~= scale + scale * (tail + 2^r - 1). */ - /* Evaluation is optimized assuming superscalar pipelined execution. */ - r2 = r * r; - /* Without fma the worst case error is 0.5/N ulp larger. */ - /* Worst case error is less than 0.5+0.86/N+(abs poly error * 2^53) ulp. */ - tmp = tail + r * C[0] + r2 * (C[1] + r * C[2]) + r2 * r2 * (C[3] + r * C[4]); - if (abstop == 0) - { - /* Handle cases that may overflow or underflow when computing the result that - is scale*(1+TMP) without intermediate rounding. The bit representation of - scale is in SBITS, however it has a computed exponent that may have - overflown into the sign bit so that needs to be adjusted before using it as - a double. (int32_t)KI is the k used in the argument reduction and exponent - adjustment of scale, positive k here means the result may overflow and - negative k means the result may underflow. */ - double scale, y; - - if ((ki & 0x80000000) == 0) { - /* k > 0, the exponent of scale might have overflowed by 1. */ - sbits -= 1ull << 52; - scale = *(double*)&sbits; - y = 2 * (scale + scale * tmp); - return y; - } - /* k < 0, need special care in the subnormal range. */ - sbits += 1022ull << 52; - scale = *(double*)&sbits; - y = scale + scale * tmp; - if (y < 1.0) { - /* Round y to the right precision before scaling it into the subnormal - range to avoid double rounding that can cause 0.5+E/2 ulp error where - E is the worst-case ulp error outside the subnormal range. So this - is only useful if the goal is better than 1 ulp worst-case error. */ - double hi, lo; - lo = scale - y + scale * tmp; - hi = 1.0 + y; - lo = 1.0 - hi + y + lo; - y = hi + lo - 1.0; - /* Avoid -0.0 with downward rounding. */ - if (y == 0.0) - y = 0.0; - /* The underflow exception needs to be signaled explicitly. */ - fp_barrier(fp_barrier(0x1p-1022) * 0x1p-1022); - } - y = 0x1p-1022 * y; - return y; - } - scale = *(double*)&sbits; - /* Note: tmp == 0 or |tmp| > 2^-65 and scale > 2^-928, so there - is no spurious underflow here even without fma. */ - return scale + scale * tmp; -} - -/********************************************************************* - * exp2f (MSVCR120.@) - * - * Copied from musl: src/math/exp2f.c - */ -float CDECL exp2f(float x) -{ - static const double C[] = { - 0x1.c6af84b912394p-5, 0x1.ebfce50fac4f3p-3, 0x1.62e42ff0c52d6p-1 - }; - static const double shift = 0x1.8p+52 / (1 << 5); - - double kd, xd, z, r, r2, y, s; - UINT32 abstop; - UINT64 ki, t; - - xd = x; - abstop = (*(UINT32*)&x >> 20) & 0x7ff; - if (abstop >= 0x430) { - /* |x| >= 128 or x is nan. */ - if (*(UINT32*)&x == 0xff800000) - return 0.0f; - if (abstop >= 0x7f8) - return x + x; - if (x > 0.0f) { - *_errno() = ERANGE; - return fp_barrierf(x * FLT_MAX); - } - if (x <= -150.0f) { - fp_barrierf(x - 0x1p120); - return 0; - } - } - - /* x = k/N + r with r in [-1/(2N), 1/(2N)] and int k, N = 1 << 5. */ - kd = xd + shift; - ki = *(UINT64*)&kd; - kd -= shift; /* k/(1<<5) for int k. */ - r = xd - kd; - - /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ - t = exp2f_T[ki % (1 << 5)]; - t += ki << (52 - 5); - s = *(double*)&t; - z = C[0] * r + C[1]; - r2 = r * r; - y = C[2] * r + 1; - y = z * r2 + y; - y = y * s; - return y; -} - /********************************************************************* * log1p (MSVCR120.@) * diff --git a/libs/musl/src/math/exp2.c b/libs/musl/src/math/exp2.c index 618289a4185..47c557ce22a 100644 --- a/libs/musl/src/math/exp2.c +++ b/libs/musl/src/math/exp2.c @@ -84,10 +84,19 @@ double __cdecl exp2(double x) return 0.0; if (abstop >= top12(INFINITY)) return 1.0 + x; - if (!(asuint64(x) >> 63)) - return __math_oflow(0); - else if (asuint64(x) >= asuint64(-1075.0)) - return __math_uflow(0); + if (!(asuint64(x) >> 63)) { + errno = ERANGE; + return fp_barrier(DBL_MAX) * DBL_MAX; + } + else if (x <= -2147483648.0) { + fp_barrier(x + 0x1p120f); + return 0; + } + else if (asuint64(x) >= asuint64(-1075.0)) { + errno = ERANGE; + fp_barrier(x + 0x1p120f); + return 0; + } } if (2 * asuint64(x) > 2 * asuint64(928.0)) /* Large x is special cased below. */ diff --git a/libs/musl/src/math/exp2f.c b/libs/musl/src/math/exp2f.c index 28670a800a1..e87265df0d9 100644 --- a/libs/musl/src/math/exp2f.c +++ b/libs/musl/src/math/exp2f.c @@ -44,10 +44,14 @@ float __cdecl exp2f(float x) return 0.0f; if (abstop >= top12(INFINITY)) return x + x; - if (x > 0.0f) - return __math_oflowf(0); - if (x <= -150.0f) - return __math_uflowf(0); + if (x > 0.0f) { + errno = ERANGE; + return fp_barrierf(x * FLT_MAX); + } + if (x <= -150.0f) { + fp_barrierf(x - 0x1p120); + return 0; + } } /* x = k/N + r with r in [-1/(2N), 1/(2N)] and int k. */
1
0
0
0
Alexandre Julliard : msvcrt: Use the atan2()/atan2f() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: 6148bf503ba32e65364d96efa3e46183940d41f9 URL:
https://gitlab.winehq.org/wine/wine/-/commit/6148bf503ba32e65364d96efa3e461…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Apr 4 15:00:21 2023 +0200 msvcrt: Use the atan2()/atan2f() implementation from the bundled musl library. --- dlls/msvcrt/math.c | 144 ----------------------------------------------------- 1 file changed, 144 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 5efdc6fc12e..25cf2e05ccd 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -797,77 +797,6 @@ float CDECL atanf( float x ) return sign ? -z : z; } -/********************************************************************* - * atan2f (MSVCRT.@) - * - * Copied from musl: src/math/atan2f.c - */ -float CDECL atan2f( float y, float x ) -{ - static const float pi = 3.1415927410e+00, - pi_lo = -8.7422776573e-08; - - float z; - unsigned int m, ix, iy; - - if (isnan(x) || isnan(y)) - return x + y; - ix = *(unsigned int*)&x; - iy = *(unsigned int*)&y; - if (ix == 0x3f800000) /* x=1.0 */ - return atanf(y); - m = ((iy >> 31) & 1) | ((ix >> 30) & 2); /* 2*sign(x)+sign(y) */ - ix &= 0x7fffffff; - iy &= 0x7fffffff; - - /* when y = 0 */ - if (iy == 0) { - switch (m) { - case 0: - case 1: return y; /* atan(+-0,+anything)=+-0 */ - case 2: return pi; /* atan(+0,-anything) = pi */ - case 3: return -pi; /* atan(-0,-anything) =-pi */ - } - } - /* when x = 0 */ - if (ix == 0) - return m & 1 ? -pi / 2 : pi / 2; - /* when x is INF */ - if (ix == 0x7f800000) { - if (iy == 0x7f800000) { - switch (m) { - case 0: return pi / 4; /* atan(+INF,+INF) */ - case 1: return -pi / 4; /* atan(-INF,+INF) */ - case 2: return 3 * pi / 4; /*atan(+INF,-INF)*/ - case 3: return -3 * pi / 4; /*atan(-INF,-INF)*/ - } - } else { - switch (m) { - case 0: return 0.0f; /* atan(+...,+INF) */ - case 1: return -0.0f; /* atan(-...,+INF) */ - case 2: return pi; /* atan(+...,-INF) */ - case 3: return -pi; /* atan(-...,-INF) */ - } - } - } - /* |y/x| > 0x1p26 */ - if (ix + (26 << 23) < iy || iy == 0x7f800000) - return m & 1 ? -pi / 2 : pi / 2; - - /* z = atan(|y/x|) with correct underflow */ - if ((m & 2) && iy + (26 << 23) < ix) /*|y/x| < 0x1p-26, x < 0 */ - z = 0.0; - else - z = atanf(fabsf(y / x)); - switch (m) { - case 0: return z; /* atan(+,+) */ - case 1: return -z; /* atan(-,+) */ - case 2: return pi - (z - pi_lo); /* atan(+,-) */ - default: /* case 3 */ - return (z - pi_lo) - pi; /* atan(-,-) */ - } -} - /* Copied from musl: src/math/__rem_pio2f.c */ static int __rem_pio2f(float x, double *y) { @@ -1822,79 +1751,6 @@ double CDECL atan( double x ) return sign ? -z : z; } -/********************************************************************* - * atan2 (MSVCRT.@) - * - * Copied from musl: src/math/atan2.c - */ -double CDECL atan2( double y, double x ) -{ - static const double pi = 3.1415926535897931160E+00, - pi_lo = 1.2246467991473531772E-16; - - double z; - unsigned int m, lx, ly, ix, iy; - - if (isnan(x) || isnan(y)) - return x+y; - ix = *(ULONGLONG*)&x >> 32; - lx = *(ULONGLONG*)&x; - iy = *(ULONGLONG*)&y >> 32; - ly = *(ULONGLONG*)&y; - if (((ix - 0x3ff00000) | lx) == 0) /* x = 1.0 */ - return atan(y); - m = ((iy >> 31) & 1) | ((ix >> 30) & 2); /* 2*sign(x)+sign(y) */ - ix = ix & 0x7fffffff; - iy = iy & 0x7fffffff; - - /* when y = 0 */ - if ((iy | ly) == 0) { - switch(m) { - case 0: - case 1: return y; /* atan(+-0,+anything)=+-0 */ - case 2: return pi; /* atan(+0,-anything) = pi */ - case 3: return -pi; /* atan(-0,-anything) =-pi */ - } - } - /* when x = 0 */ - if ((ix | lx) == 0) - return m & 1 ? -pi / 2 : pi / 2; - /* when x is INF */ - if (ix == 0x7ff00000) { - if (iy == 0x7ff00000) { - switch(m) { - case 0: return pi / 4; /* atan(+INF,+INF) */ - case 1: return -pi / 4; /* atan(-INF,+INF) */ - case 2: return 3 * pi / 4; /* atan(+INF,-INF) */ - case 3: return -3 * pi / 4; /* atan(-INF,-INF) */ - } - } else { - switch(m) { - case 0: return 0.0; /* atan(+...,+INF) */ - case 1: return -0.0; /* atan(-...,+INF) */ - case 2: return pi; /* atan(+...,-INF) */ - case 3: return -pi; /* atan(-...,-INF) */ - } - } - } - /* |y/x| > 0x1p64 */ - if (ix + (64 << 20) < iy || iy == 0x7ff00000) - return m & 1 ? -pi / 2 : pi / 2; - - /* z = atan(|y/x|) without spurious underflow */ - if ((m & 2) && iy + (64 << 20) < ix) /* |y/x| < 0x1p-64, x<0 */ - z = 0; - else - z = atan(fabs(y / x)); - switch (m) { - case 0: return z; /* atan(+,+) */ - case 1: return -z; /* atan(-,+) */ - case 2: return pi - (z - pi_lo); /* atan(+,-) */ - default: /* case 3 */ - return (z - pi_lo) - pi; /* atan(-,-) */ - } -} - /* Copied from musl: src/math/rint.c */ static double __rint(double x) {
1
0
0
0
Alexandre Julliard : msvcrt: Use the sinh() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: 03bdd6d52dd2a5ad5ec35b3bd92431acf0bd8055 URL:
https://gitlab.winehq.org/wine/wine/-/commit/03bdd6d52dd2a5ad5ec35b3bd92431…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 3 17:43:51 2023 +0200 msvcrt: Use the sinh() implementation from the bundled musl library. With the changes from 11166aa01e7d17f8535977f648c0b5e098d43bd9. --- dlls/msvcrt/math.c | 40 ---------------------------------------- libs/musl/src/math/sinh.c | 5 +++++ 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 8bce6727ac4..5efdc6fc12e 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -2153,8 +2153,6 @@ double CDECL cos( double x ) } } -extern double __expo2(double x, double sign); - /* Copied from musl: src/math/exp_data.c */ static const UINT64 exp_T[] = { 0x0ULL, 0x3ff0000000000000ULL, @@ -2860,44 +2858,6 @@ double CDECL sin( double x ) } } -/********************************************************************* - * sinh (MSVCRT.@) - */ -double CDECL sinh( double x ) -{ - UINT64 ux = *(UINT64*)&x; - UINT64 sign = ux & 0x8000000000000000ULL; - UINT32 w; - double t, h, absx; - - h = 0.5; - if (ux >> 63) - h = -h; - /* |x| */ - ux &= (UINT64)-1 / 2; - absx = *(double*)&ux; - w = ux >> 32; - - /* |x| < log(DBL_MAX) */ - if (w < 0x40862e42) { - t = expm1(absx); - if (w < 0x3ff00000) { - if (w < 0x3ff00000 - (26 << 20)) - return x; - return h * (2 * t - t * t / (t + 1)); - } - return h * (t + t / (t + 1)); - } - - /* |x| > log(DBL_MAX) or nan */ - /* note: the result is stored to handle overflow */ - if (ux > 0x7ff0000000000000ULL) - *(UINT64*)&t = ux | sign | 0x0008000000000000ULL; - else - t = __expo2(absx, 2 * h); - return t; -} - static BOOL sqrt_validate( double *x, BOOL update_sw ) { short c = _dclass(*x); diff --git a/libs/musl/src/math/sinh.c b/libs/musl/src/math/sinh.c index af3ef8493b1..2d05ba80860 100644 --- a/libs/musl/src/math/sinh.c +++ b/libs/musl/src/math/sinh.c @@ -7,6 +7,7 @@ double __cdecl sinh(double x) { union {double f; uint64_t i;} u = {.f = x}; + uint64_t sign = u.i & 0x8000000000000000ULL; uint32_t w; double t, h, absx; @@ -34,6 +35,10 @@ double __cdecl sinh(double x) /* |x| > log(DBL_MAX) or nan */ /* note: the result is stored to handle overflow */ + if (w > 0x7ff00000) { + u.i |= sign | 0x0008000000000000ULL; + return u.f; + } t = __expo2(absx, 2*h); return t; }
1
0
0
0
Alexandre Julliard : msvcrt: Use the cosh() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: 9fd9ebcb7a4a093990a8103cce6415b6e97299d7 URL:
https://gitlab.winehq.org/wine/wine/-/commit/9fd9ebcb7a4a093990a8103cce6415…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 3 17:43:30 2023 +0200 msvcrt: Use the cosh() implementation from the bundled musl library. With the changes from 60d178b410ba943c6c39b2ccf1deaec264d7d21a. --- dlls/msvcrt/math.c | 43 ------------------------------------------- libs/musl/src/math/cosh.c | 5 +++++ 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 9741100b2b9..8bce6727ac4 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -2155,49 +2155,6 @@ double CDECL cos( double x ) extern double __expo2(double x, double sign); -/********************************************************************* - * cosh (MSVCRT.@) - * - * Copied from musl: src/math/cosh.c - */ -double CDECL cosh( double x ) -{ - UINT64 ux = *(UINT64*)&x; - UINT64 sign = ux & 0x8000000000000000ULL; - UINT32 w; - double t; - - /* |x| */ - ux &= (uint64_t)-1 / 2; - x = *(double*)&ux; - w = ux >> 32; - - /* |x| < log(2) */ - if (w < 0x3fe62e42) { - if (w < 0x3ff00000 - (26 << 20)) { - fp_barrier(x + 0x1p120f); - return 1; - } - t = expm1(x); - return 1 + t * t / (2 * (1 + t)); - } - - /* |x| < log(DBL_MAX) */ - if (w < 0x40862e42) { - t = exp(x); - /* note: if x>log(0x1p26) then the 1/t is not needed */ - return 0.5 * (t + 1 / t); - } - - /* |x| > log(DBL_MAX) or nan */ - /* note: the result is stored to handle overflow */ - if (ux > 0x7ff0000000000000ULL) - *(UINT64*)&t = ux | sign | 0x0008000000000000ULL; - else - t = __expo2(x, 1.0); - return t; -} - /* Copied from musl: src/math/exp_data.c */ static const UINT64 exp_T[] = { 0x0ULL, 0x3ff0000000000000ULL, diff --git a/libs/musl/src/math/cosh.c b/libs/musl/src/math/cosh.c index 384d9d8beac..8ab9417d2c2 100644 --- a/libs/musl/src/math/cosh.c +++ b/libs/musl/src/math/cosh.c @@ -7,6 +7,7 @@ double __cdecl cosh(double x) { union {double f; uint64_t i;} u = {.f = x}; + uint64_t sign = u.i & 0x8000000000000000ULL; uint32_t w; double t; @@ -35,6 +36,10 @@ double __cdecl cosh(double x) /* |x| > log(DBL_MAX) or nan */ /* note: the result is stored to handle overflow */ + if (w > 0x7ff00000) { + u.i |= sign | 0x0008000000000000ULL; + return u.f; + } t = __expo2(x, 1.0); return t; }
1
0
0
0
Alexandre Julliard : msvcrt: Use the sinhf() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: 66bef6db20f72e88a38c4b264e13639015d7817d URL:
https://gitlab.winehq.org/wine/wine/-/commit/66bef6db20f72e88a38c4b264e1363…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 3 17:43:10 2023 +0200 msvcrt: Use the sinhf() implementation from the bundled musl library. With the changes from 4fd9daea4a79d0826c9e5ab6466291043e40d579. --- dlls/msvcrt/math.c | 36 ------------------------------------ libs/musl/src/math/sinhf.c | 5 +++++ 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 1c6fd5d7d70..9741100b2b9 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -983,8 +983,6 @@ float CDECL cosf( float x ) } } -extern float __expo2f(float x, float sign); - /********************************************************************* * expf (MSVCRT.@) */ @@ -1277,40 +1275,6 @@ float CDECL sinf( float x ) } } -/********************************************************************* - * sinhf (MSVCRT.@) - */ -float CDECL sinhf( float x ) -{ - UINT32 ui = *(UINT32*)&x; - float t, h, absx; - - h = 0.5; - if (ui >> 31) - h = -h; - /* |x| */ - ui &= 0x7fffffff; - absx = *(float*)&ui; - - /* |x| < log(FLT_MAX) */ - if (ui < 0x42b17217) { - t = expm1f(absx); - if (ui < 0x3f800000) { - if (ui < 0x3f800000 - (12 << 23)) - return x; - return h * (2 * t - t * t / (t + 1)); - } - return h * (t + t / (t + 1)); - } - - /* |x| > logf(FLT_MAX) or nan */ - if (ui > 0x7f800000) - *(DWORD*)&t = *(DWORD*)&x | 0x400000; - else - t = __expo2f(absx, 2 * h); - return t; -} - static BOOL sqrtf_validate( float *x ) { short c = _fdclass(*x); diff --git a/libs/musl/src/math/sinhf.c b/libs/musl/src/math/sinhf.c index a9abf634e85..60bca2b5a36 100644 --- a/libs/musl/src/math/sinhf.c +++ b/libs/musl/src/math/sinhf.c @@ -3,6 +3,7 @@ float __cdecl sinhf(float x) { union {float f; uint32_t i;} u = {.f = x}; + uint32_t sign = u.i & 0x80000000; uint32_t w; float t, h, absx; @@ -26,6 +27,10 @@ float __cdecl sinhf(float x) } /* |x| > logf(FLT_MAX) or nan */ + if (w > 0x7f800000) { + u.i = w | sign | 0x400000; + return u.f; + } t = __expo2f(absx, 2*h); return t; }
1
0
0
0
Alexandre Julliard : msvcrt: Use the coshf() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: 248a17377cd535afed8ae611ce7d8401815e3629 URL:
https://gitlab.winehq.org/wine/wine/-/commit/248a17377cd535afed8ae611ce7d84…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 3 17:41:52 2023 +0200 msvcrt: Use the coshf() implementation from the bundled musl library. With the changes from 361143252bf23b6f29eead49a3715fdd6d552e8a. --- dlls/msvcrt/math.c | 39 --------------------------------------- libs/musl/src/math/coshf.c | 5 +++++ 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index f368790f3d4..1c6fd5d7d70 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -985,45 +985,6 @@ float CDECL cosf( float x ) extern float __expo2f(float x, float sign); -/********************************************************************* - * coshf (MSVCRT.@) - * - * Copied from musl: src/math/coshf.c - */ -float CDECL coshf( float x ) -{ - UINT32 ui = *(UINT32*)&x; - UINT32 sign = ui & 0x80000000; - float t; - - /* |x| */ - ui &= 0x7fffffff; - x = *(float*)&ui; - - /* |x| < log(2) */ - if (ui < 0x3f317217) { - if (ui < 0x3f800000 - (12 << 23)) { - fp_barrierf(x + 0x1p120f); - return 1; - } - t = expm1f(x); - return 1 + t * t / (2 * (1 + t)); - } - - /* |x| < log(FLT_MAX) */ - if (ui < 0x42b17217) { - t = expf(x); - return 0.5f * (t + 1 / t); - } - - /* |x| > log(FLT_MAX) or nan */ - if (ui > 0x7f800000) - *(UINT32*)&t = ui | sign | 0x400000; - else - t = __expo2f(x, 1.0f); - return t; -} - /********************************************************************* * expf (MSVCRT.@) */ diff --git a/libs/musl/src/math/coshf.c b/libs/musl/src/math/coshf.c index 2fc004682da..44f29113559 100644 --- a/libs/musl/src/math/coshf.c +++ b/libs/musl/src/math/coshf.c @@ -3,6 +3,7 @@ float __cdecl coshf(float x) { union {float f; uint32_t i;} u = {.f = x}; + uint32_t sign = u.i & 0x80000000; uint32_t w; float t; @@ -28,6 +29,10 @@ float __cdecl coshf(float x) } /* |x| > log(FLT_MAX) or nan */ + if (w > 0x7f800000) { + u.i |= sign | 0x400000; + return u.f; + } t = __expo2f(x, 1.0f); return t; }
1
0
0
0
Alexandre Julliard : msvcrt: Use the __expo2()/__expo2f() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: bbc8c347356e19c39572061f295818d29f341ec4 URL:
https://gitlab.winehq.org/wine/wine/-/commit/bbc8c347356e19c39572061f295818…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Apr 3 17:39:15 2023 +0200 msvcrt: Use the __expo2()/__expo2f() implementation from the bundled musl library. --- dlls/msvcrt/math.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 425eccb9c9e..f368790f3d4 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -983,16 +983,7 @@ float CDECL cosf( float x ) } } -/* Copied from musl: src/math/__expo2f.c */ -static float __expo2f(float x, float sign) -{ - static const int k = 235; - static const float kln2 = 0x1.45c778p+7f; - float scale; - - *(UINT32*)&scale = (UINT32)(0x7f + k/2) << 23; - return expf(x - kln2) * (sign * scale) * scale; -} +extern float __expo2f(float x, float sign); /********************************************************************* * coshf (MSVCRT.@) @@ -2237,15 +2228,7 @@ double CDECL cos( double x ) } } -static double __expo2(double x, double sign) -{ - static const int k = 2043; - static const double kln2 = 0x1.62066151add8bp+10; - double scale; - - *(UINT64*)&scale = (UINT64)(0x3ff + k / 2) << 52; - return exp(x - kln2) * (sign * scale) * scale; -} +extern double __expo2(double x, double sign); /********************************************************************* * cosh (MSVCRT.@)
1
0
0
0
Alexandre Julliard : msvcrt: Use the log10()/log10f() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: c53bd233f0bc79eb5260f8da79781b8892443163 URL:
https://gitlab.winehq.org/wine/wine/-/commit/c53bd233f0bc79eb5260f8da79781b…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Apr 4 16:32:31 2023 +0200 msvcrt: Use the log10()/log10f() implementation from the bundled musl library. --- dlls/msvcrt/math.c | 146 -------------------------------------------- libs/musl/src/math/log10.c | 8 ++- libs/musl/src/math/log10f.c | 6 +- 3 files changed, 9 insertions(+), 151 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index c35d997ef52..425eccb9c9e 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -1084,69 +1084,6 @@ float CDECL expf( float x ) return y; } -/********************************************************************* - * log10f (MSVCRT.@) - */ -float CDECL log10f( float x ) -{ - static const float ivln10hi = 4.3432617188e-01, - ivln10lo = -3.1689971365e-05, - log10_2hi = 3.0102920532e-01, - log10_2lo = 7.9034151668e-07, - Lg1 = 0xaaaaaa.0p-24, - Lg2 = 0xccce13.0p-25, - Lg3 = 0x91e9ee.0p-25, - Lg4 = 0xf89e26.0p-26; - - union {float f; UINT32 i;} u = {x}; - float hfsq, f, s, z, R, w, t1, t2, dk, hi, lo; - UINT32 ix; - int k; - - ix = u.i; - k = 0; - if (ix < 0x00800000 || ix >> 31) { /* x < 2**-126 */ - if (ix << 1 == 0) - return math_error(_SING, "log10f", x, 0, -1 / (x * x)); - if ((ix & ~(1u << 31)) > 0x7f800000) - return x; - if (ix >> 31) - return math_error(_DOMAIN, "log10f", x, 0, (x - x) / (x - x)); - /* subnormal number, scale up x */ - k -= 25; - x *= 0x1p25f; - u.f = x; - ix = u.i; - } else if (ix >= 0x7f800000) { - return x; - } else if (ix == 0x3f800000) - return 0; - - /* reduce x into [sqrt(2)/2, sqrt(2)] */ - ix += 0x3f800000 - 0x3f3504f3; - k += (int)(ix >> 23) - 0x7f; - ix = (ix & 0x007fffff) + 0x3f3504f3; - u.i = ix; - x = u.f; - - f = x - 1.0f; - s = f / (2.0f + f); - z = s * s; - w = z * z; - t1= w * (Lg2 + w * Lg4); - t2= z * (Lg1 + w * Lg3); - R = t2 + t1; - hfsq = 0.5f * f * f; - - hi = f - hfsq; - u.f = hi; - u.i &= 0xfffff000; - hi = u.f; - lo = f - hi - hfsq + s * (hfsq + R); - dk = k; - return dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi + hi * ivln10hi + dk * log10_2hi; -} - /* Subnormal input is normalized so ix has negative biased exponent. Output is multiplied by POWF_SCALE (where 1 << 5). */ static double powf_log2(UINT32 ix) @@ -2599,89 +2536,6 @@ double CDECL exp( double x ) return scale + scale * tmp; } -/********************************************************************* - * log10 (MSVCRT.@) - */ -double CDECL log10( double x ) -{ - static const double ivln10hi = 4.34294481878168880939e-01, - ivln10lo = 2.50829467116452752298e-11, - log10_2hi = 3.01029995663611771306e-01, - log10_2lo = 3.69423907715893078616e-13, - Lg1 = 6.666666666666735130e-01, - Lg2 = 3.999999999940941908e-01, - Lg3 = 2.857142874366239149e-01, - Lg4 = 2.222219843214978396e-01, - Lg5 = 1.818357216161805012e-01, - Lg6 = 1.531383769920937332e-01, - Lg7 = 1.479819860511658591e-01; - - union {double f; UINT64 i;} u = {x}; - double hfsq, f, s, z, R, w, t1, t2, dk, y, hi, lo, val_hi, val_lo; - UINT32 hx; - int k; - - hx = u.i >> 32; - k = 0; - if (hx < 0x00100000 || hx >> 31) { - if (u.i << 1 == 0) - return math_error(_SING, "log10", x, 0, -1 / (x * x)); - if ((u.i & ~(1ULL << 63)) > 0x7ff0000000000000ULL) - return x; - if (hx >> 31) - return math_error(_DOMAIN, "log10", x, 0, (x - x) / (x - x)); - /* subnormal number, scale x up */ - k -= 54; - x *= 0x1p54; - u.f = x; - hx = u.i >> 32; - } else if (hx >= 0x7ff00000) { - return x; - } else if (hx == 0x3ff00000 && u.i<<32 == 0) - return 0; - - /* reduce x into [sqrt(2)/2, sqrt(2)] */ - hx += 0x3ff00000 - 0x3fe6a09e; - k += (int)(hx >> 20) - 0x3ff; - hx = (hx & 0x000fffff) + 0x3fe6a09e; - u.i = (UINT64)hx << 32 | (u.i & 0xffffffff); - x = u.f; - - f = x - 1.0; - hfsq = 0.5 * f * f; - s = f / (2.0 + f); - z = s * s; - w = z * z; - t1 = w * (Lg2 + w * (Lg4 + w * Lg6)); - t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7))); - R = t2 + t1; - - /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */ - hi = f - hfsq; - u.f = hi; - u.i &= (UINT64)-1 << 32; - hi = u.f; - lo = f - hi - hfsq + s * (hfsq + R); - - /* val_hi+val_lo ~ log10(1+f) + k*log10(2) */ - val_hi = hi * ivln10hi; - dk = k; - y = dk * log10_2hi; - val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi; - - /* - * Extra precision in for adding y is not strictly needed - * since there is no very large cancellation near x = sqrt(2) or - * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs - * with some parallelism and it reduces the error for many args. - */ - w = y + val_hi; - val_lo += (y - w) + val_hi; - val_hi = w; - - return val_lo + val_hi; -} - /* Compute y+TAIL = log(x) where the rounded result is y and TAIL has about additional 15 bits precision. IX is the bit representation of x, but normalized in the subnormal range using the sign bit for the exponent. */ diff --git a/libs/musl/src/math/log10.c b/libs/musl/src/math/log10.c index df7d591c292..6ec431bfe22 100644 --- a/libs/musl/src/math/log10.c +++ b/libs/musl/src/math/log10.c @@ -45,9 +45,11 @@ double __cdecl log10(double x) k = 0; if (hx < 0x00100000 || hx>>31) { if (u.i<<1 == 0) - return -1/(x*x); /* log(+-0)=-inf */ - if (hx>>31) - return (x-x)/0.0; /* log(-#) = NaN */ + return math_error(_SING, "log10", x, 0, -1 / (x * x)); + if ((u.i & ~(1ULL << 63)) > 0x7ff0000000000000ULL) + return x; + if (hx >> 31) + return math_error(_DOMAIN, "log10", x, 0, (x - x) / (x - x)); /* subnormal number, scale x up */ k -= 54; x *= 0x1p54; diff --git a/libs/musl/src/math/log10f.c b/libs/musl/src/math/log10f.c index 64cf8c85be0..0233e2ff332 100644 --- a/libs/musl/src/math/log10f.c +++ b/libs/musl/src/math/log10f.c @@ -39,9 +39,11 @@ float __cdecl log10f(float x) k = 0; if (ix < 0x00800000 || ix>>31) { /* x < 2**-126 */ if (ix<<1 == 0) - return -1/(x*x); /* log(+-0)=-inf */ + return math_error(_SING, "log10f", x, 0, -1 / (x * x)); + if ((ix & ~(1u << 31)) > 0x7f800000) + return x; if (ix>>31) - return (x-x)/0.0f; /* log(-#) = NaN */ + return math_error(_DOMAIN, "log10f", x, 0, (x - x) / (x - x)); /* subnormal number, scale up x */ k -= 25; x *= 0x1p25f;
1
0
0
0
Alexandre Julliard : msvcrt: Use the log()/logf() implementation from the bundled musl library.
by Alexandre Julliard
06 Apr '23
06 Apr '23
Module: wine Branch: master Commit: f0c700502a7adc34c7f83d5d9650947363f59034 URL:
https://gitlab.winehq.org/wine/wine/-/commit/f0c700502a7adc34c7f83d5d965094…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Apr 4 16:32:12 2023 +0200 msvcrt: Use the log()/logf() implementation from the bundled musl library. --- dlls/msvcrt/math.c | 454 ---------------------------------------------- libs/musl/src/math/log.c | 8 +- libs/musl/src/math/logf.c | 8 +- 3 files changed, 10 insertions(+), 460 deletions(-)
1
0
0
0
← Newer
1
...
61
62
63
64
65
66
67
...
82
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Results per page:
10
25
50
100
200