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
June 2021
----- 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
811 discussions
Start a n
N
ew thread
Piotr Caban : msvcrt: Import powf implementation from musl.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 7bb574eafd3a3ca61ced2f22e69a96b6bf848193 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7bb574eafd3a3ca61ced2f22…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Thu Jun 10 19:04:44 2021 +0200 msvcrt: Import powf implementation from musl. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/math.c | 177 ++++++++++++++++++++++++++++++++++++++++++++++++-- dlls/msvcrt/unixlib.c | 9 --- dlls/msvcrt/unixlib.h | 1 - 3 files changed, 171 insertions(+), 16 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index eaaeb9bec12..04597744548 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -1424,17 +1424,182 @@ float CDECL log10f( float x ) 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) +{ + static const struct { + double invc, logc; + } T[] = { + { 0x1.661ec79f8f3bep+0, -0x1.efec65b963019p-2 * (1 << 5) }, + { 0x1.571ed4aaf883dp+0, -0x1.b0b6832d4fca4p-2 * (1 << 5) }, + { 0x1.49539f0f010bp+0, -0x1.7418b0a1fb77bp-2 * (1 << 5) }, + { 0x1.3c995b0b80385p+0, -0x1.39de91a6dcf7bp-2 * (1 << 5) }, + { 0x1.30d190c8864a5p+0, -0x1.01d9bf3f2b631p-2 * (1 << 5) }, + { 0x1.25e227b0b8eap+0, -0x1.97c1d1b3b7afp-3 * (1 << 5) }, + { 0x1.1bb4a4a1a343fp+0, -0x1.2f9e393af3c9fp-3 * (1 << 5) }, + { 0x1.12358f08ae5bap+0, -0x1.960cbbf788d5cp-4 * (1 << 5) }, + { 0x1.0953f419900a7p+0, -0x1.a6f9db6475fcep-5 * (1 << 5) }, + { 0x1p+0, 0x0p+0 * (1 << 4) }, + { 0x1.e608cfd9a47acp-1, 0x1.338ca9f24f53dp-4 * (1 << 5) }, + { 0x1.ca4b31f026aap-1, 0x1.476a9543891bap-3 * (1 << 5) }, + { 0x1.b2036576afce6p-1, 0x1.e840b4ac4e4d2p-3 * (1 << 5) }, + { 0x1.9c2d163a1aa2dp-1, 0x1.40645f0c6651cp-2 * (1 << 5) }, + { 0x1.886e6037841edp-1, 0x1.88e9c2c1b9ff8p-2 * (1 << 5) }, + { 0x1.767dcf5534862p-1, 0x1.ce0a44eb17bccp-2 * (1 << 5) } + }; + static const double A[] = { + 0x1.27616c9496e0bp-2 * (1 << 5), -0x1.71969a075c67ap-2 * (1 << 5), + 0x1.ec70a6ca7baddp-2 * (1 << 5), -0x1.7154748bef6c8p-1 * (1 << 5), + 0x1.71547652ab82bp0 * (1 << 5) + }; + + double z, r, r2, r4, p, q, y, y0, invc, logc; + UINT32 iz, top, tmp; + int k, i; + + /* x = 2^k z; where z is in range [OFF,2*OFF] and exact. + The range is split into N subintervals. + The ith subinterval contains z and c is near its center. */ + tmp = ix - 0x3f330000; + i = (tmp >> (23 - 4)) % (1 << 4); + top = tmp & 0xff800000; + iz = ix - top; + k = (INT32)top >> (23 - 5); /* arithmetic shift */ + invc = T[i].invc; + logc = T[i].logc; + z = *(float*)&iz; + + /* log2(x) = log1p(z/c-1)/ln2 + log2(c) + k */ + r = z * invc - 1; + y0 = logc + (double)k; + + /* Pipelined polynomial evaluation to approximate log1p(r)/ln2. */ + r2 = r * r; + y = A[0] * r + A[1]; + p = A[2] * r + A[3]; + r4 = r2 * r2; + q = A[4] * r + y0; + q = p * r2 + q; + y = y * r4 + q; + return y; +} + +/* The output of log2 and thus the input of exp2 is either scaled by N + (in case of fast toint intrinsics) or not. The unscaled xd must be + in [-1021,1023], sign_bias sets the sign of the result. */ +static float powf_exp2(double xd, UINT32 sign_bias) +{ + static const double C[] = { + 0x1.c6af84b912394p-5 / (1 << 5) / (1 << 5) / (1 << 5), + 0x1.ebfce50fac4f3p-3 / (1 << 5) / (1 << 5), + 0x1.62e42ff0c52d6p-1 / (1 << 5) + }; + + UINT64 ki, ski, t; + double kd, z, r, r2, y, s; + + /* N*x = k + r with r in [-1/2, 1/2] */ + kd = __round(xd); /* k */ + ki = kd; + 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)]; + ski = ki + sign_bias; + t += ski << (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; +} + +/* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is + the bit representation of a non-zero finite floating-point value. */ +static int powf_checkint(UINT32 iy) +{ + int e = iy >> 23 & 0xff; + if (e < 0x7f) + return 0; + if (e > 0x7f + 23) + return 2; + if (iy & ((1 << (0x7f + 23 - e)) - 1)) + return 0; + if (iy & (1 << (0x7f + 23 - e))) + return 1; + return 2; +} + /********************************************************************* * powf (MSVCRT.@) + * + * Copied from musl: src/math/powf.c src/math/powf_data.c */ float CDECL powf( float x, float y ) { - float z = unix_funcs->powf(x,y); - if (x < 0 && y != floorf(y)) return math_error(_DOMAIN, "powf", x, y, z); - if (!x && isfinite(y) && y < 0) return math_error(_SING, "powf", x, y, z); - if (isfinite(x) && isfinite(y) && !isfinite(z)) return math_error(_OVERFLOW, "powf", x, y, z); - if (x && isfinite(x) && isfinite(y) && !z) return math_error(_UNDERFLOW, "powf", x, y, z); - return z; + UINT32 sign_bias = 0; + UINT32 ix, iy; + double logx, ylogx; + + ix = *(UINT32*)&x; + iy = *(UINT32*)&y; + if (ix - 0x00800000 >= 0x7f800000 - 0x00800000 || + 2 * iy - 1 >= 2u * 0x7f800000 - 1) { + /* Either (x < 0x1p-126 or inf or nan) or (y is 0 or inf or nan). */ + if (2 * iy - 1 >= 2u * 0x7f800000 - 1) { + if (2 * iy == 0) + return 1.0f; + if (ix == 0x3f800000) + return 1.0f; + if (2 * ix > 2u * 0x7f800000 || 2 * iy > 2u * 0x7f800000) + return x + y; + if (2 * ix == 2 * 0x3f800000) + return 1.0f; + if ((2 * ix < 2 * 0x3f800000) == !(iy & 0x80000000)) + return 0.0f; /* |x|<1 && y==inf or |x|>1 && y==-inf. */ + return y * y; + } + if (2 * ix - 1 >= 2u * 0x7f800000 - 1) { + float x2 = x * x; + if (ix & 0x80000000 && powf_checkint(iy) == 1) + x2 = -x2; + if (iy & 0x80000000 && x2 == 0.0) + return math_error(_SING, "powf", x, 0, 1 / x2); + /* Without the barrier some versions of clang hoist the 1/x2 and + thus division by zero exception can be signaled spuriously. */ + return iy & 0x80000000 ? fp_barrierf(1 / x2) : x2; + } + /* x and y are non-zero finite. */ + if (ix & 0x80000000) { + /* Finite x < 0. */ + int yint = powf_checkint(iy); + if (yint == 0) + return math_error(_DOMAIN, "powf", x, 0, 0 / (x - x)); + if (yint == 1) + sign_bias = 1 << (5 + 11); + ix &= 0x7fffffff; + } + if (ix < 0x00800000) { + /* Normalize subnormal x so exponent becomes negative. */ + x *= 0x1p23f; + ix = *(UINT32*)&x; + ix &= 0x7fffffff; + ix -= 23 << 23; + } + } + logx = powf_log2(ix); + ylogx = y * logx; /* cannot overflow, y is single prec. */ + if ((*(UINT64*)&ylogx >> 47 & 0xffff) >= 0x40af800000000000llu >> 47) { + /* |y*log(x)| >= 126. */ + if (ylogx > 0x1.fffffffd1d571p+6 * (1 << 5)) + return math_error(_OVERFLOW, "powf", x, 0, (sign_bias ? -1.0 : 1.0) * 0x1p1023); + if (ylogx <= -150.0 * (1 << 5)) + return math_error(_UNDERFLOW, "powf", x, 0, (sign_bias ? -1.0 : 1.0) / 0x1p1023); + } + return powf_exp2(ylogx, sign_bias); } /********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index 0498a736812..2b189246084 100644 --- a/dlls/msvcrt/unixlib.c +++ b/dlls/msvcrt/unixlib.c @@ -70,20 +70,11 @@ static double CDECL unix_pow( double x, double y ) return pow( x, y ); } -/********************************************************************* - * powf - */ -static float CDECL unix_powf( float x, float y ) -{ - return powf( x, y ); -} - static const struct unix_funcs funcs = { unix_exp, unix_exp2, unix_pow, - unix_powf, }; 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 21bb5e6c130..e82977e4097 100644 --- a/dlls/msvcrt/unixlib.h +++ b/dlls/msvcrt/unixlib.h @@ -26,7 +26,6 @@ struct unix_funcs double (CDECL *exp)(double x); double (CDECL *exp2)(double x); double (CDECL *pow)(double x, double y); - float (CDECL *powf)(float x, float y); }; #endif /* __UNIXLIB_H */
1
0
0
0
Piotr Caban : msvcrt: Import expf implementation from musl.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 9a459dc5afa417351de84f9ede4e14aab2c5a590 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9a459dc5afa417351de84f9e…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Thu Jun 10 19:04:36 2021 +0200 msvcrt: Import expf implementation from musl. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/math.c | 112 +++++++++++++++++++++++++++++++++++--------------- dlls/msvcrt/unixlib.c | 9 ---- dlls/msvcrt/unixlib.h | 1 - 3 files changed, 78 insertions(+), 44 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index ae943e845e8..eaaeb9bec12 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -668,6 +668,38 @@ static float __cosdf(double x) r = C2 + z * C3; return ((1.0 + z * C0) + w * C1) + (w * z) * r; } + +/* Based on musl implementation: src/math/round.c */ +static double __round(double x) +{ + ULONGLONG llx = *(ULONGLONG*)&x, tmp; + int e = (llx >> 52 & 0x7ff) - 0x3ff; + + if (e >= 52) + return x; + if (e < -1) + return 0 * x; + else if (e == -1) + return signbit(x) ? -1 : 1; + + tmp = 0x000fffffffffffffULL >> e; + if (!(llx & tmp)) + return x; + llx += 0x0008000000000000ULL >> e; + llx &= ~tmp; + return *(double*)&llx; +} + +static const UINT64 exp2f_T[] = { + 0x3ff0000000000000ULL, 0x3fefd9b0d3158574ULL, 0x3fefb5586cf9890fULL, 0x3fef9301d0125b51ULL, + 0x3fef72b83c7d517bULL, 0x3fef54873168b9aaULL, 0x3fef387a6e756238ULL, 0x3fef1e9df51fdee1ULL, + 0x3fef06fe0a31b715ULL, 0x3feef1a7373aa9cbULL, 0x3feedea64c123422ULL, 0x3feece086061892dULL, + 0x3feebfdad5362a27ULL, 0x3feeb42b569d4f82ULL, 0x3feeab07dd485429ULL, 0x3feea47eb03a5585ULL, + 0x3feea09e667f3bcdULL, 0x3fee9f75e8ec5f74ULL, 0x3feea11473eb0187ULL, 0x3feea589994cce13ULL, + 0x3feeace5422aa0dbULL, 0x3feeb737b0cdc5e5ULL, 0x3feec49182a3f090ULL, 0x3feed503b23e255dULL, + 0x3feee89f995ad3adULL, 0x3feeff76f2fb5e47ULL, 0x3fef199bdd85529cULL, 0x3fef3720dcef9069ULL, + 0x3fef5818dcfba487ULL, 0x3fef7c97337b9b5fULL, 0x3fefa4afa2a490daULL, 0x3fefd0765b6e4540ULL +}; #endif #ifndef __i386__ @@ -1134,11 +1166,50 @@ float CDECL coshf( float x ) */ float CDECL expf( float x ) { - float ret = unix_funcs->expf( x ); - if (isnan(x)) return math_error(_DOMAIN, "expf", x, 0, ret); - if (isfinite(x) && !ret) return math_error(_UNDERFLOW, "expf", x, 0, ret); - if (isfinite(x) && !isfinite(ret)) return math_error(_OVERFLOW, "expf", x, 0, ret); - return ret; + static const double C[] = { + 0x1.c6af84b912394p-5 / (1 << 5) / (1 << 5) / (1 << 5), + 0x1.ebfce50fac4f3p-3 / (1 << 5) / (1 << 5), + 0x1.62e42ff0c52d6p-1 / (1 << 5) + }; + static const double invln2n = 0x1.71547652b82fep+0 * (1 << 5); + + double kd, z, r, r2, y, s; + UINT32 abstop; + UINT64 ki, t; + + abstop = (*(UINT32*)&x >> 20) & 0x7ff; + if (abstop >= 0x42b) { + /* |x| >= 88 or x is nan. */ + if (*(UINT32*)&x == 0xff800000) + return 0.0f; + if (abstop >= 0x7f8) + return x + x; + if (x > 0x1.62e42ep6f) /* x > log(0x1p128) ~= 88.72 */ + return math_error(_OVERFLOW, "expf", x, 0, x * FLT_MAX); + if (x < -0x1.9fe368p6f) /* x < log(0x1p-150) ~= -103.97 */ + return math_error(_UNDERFLOW, "expf", x, 0, fp_barrierf(FLT_MIN) * FLT_MIN); + } + + /* x*N/Ln2 = k + r with r in [-1/2, 1/2] and int k. */ + z = invln2n * x; + + /* Round and convert z to int, the result is in [-150*N, 128*N] and + ideally ties-to-even rule is used, otherwise the magnitude of r + can be bigger which gives larger approximation error. */ + kd = __round(z); + ki = kd; + r = z - kd; + + /* exp(x) = 2^(k/N) * 2^(r/N) ~= 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; } /********************************************************************* @@ -7030,16 +7101,6 @@ double CDECL exp2(double x) */ float CDECL exp2f(float x) { - static const UINT64 T[] = { - 0x3ff0000000000000ULL, 0x3fefd9b0d3158574ULL, 0x3fefb5586cf9890fULL, 0x3fef9301d0125b51ULL, - 0x3fef72b83c7d517bULL, 0x3fef54873168b9aaULL, 0x3fef387a6e756238ULL, 0x3fef1e9df51fdee1ULL, - 0x3fef06fe0a31b715ULL, 0x3feef1a7373aa9cbULL, 0x3feedea64c123422ULL, 0x3feece086061892dULL, - 0x3feebfdad5362a27ULL, 0x3feeb42b569d4f82ULL, 0x3feeab07dd485429ULL, 0x3feea47eb03a5585ULL, - 0x3feea09e667f3bcdULL, 0x3fee9f75e8ec5f74ULL, 0x3feea11473eb0187ULL, 0x3feea589994cce13ULL, - 0x3feeace5422aa0dbULL, 0x3feeb737b0cdc5e5ULL, 0x3feec49182a3f090ULL, 0x3feed503b23e255dULL, - 0x3feee89f995ad3adULL, 0x3feeff76f2fb5e47ULL, 0x3fef199bdd85529cULL, 0x3fef3720dcef9069ULL, - 0x3fef5818dcfba487ULL, 0x3fef7c97337b9b5fULL, 0x3fefa4afa2a490daULL, 0x3fefd0765b6e4540ULL - }; static const double C[] = { 0x1.c6af84b912394p-5, 0x1.ebfce50fac4f3p-3, 0x1.62e42ff0c52d6p-1 }; @@ -7074,7 +7135,7 @@ float CDECL exp2f(float x) r = xd - kd; /* exp2(x) = 2^(k/N) * 2^r ~= s * (C0*r^3 + C1*r^2 + C2*r + 1) */ - t = T[ki % (1 << 5)]; + t = exp2f_T[ki % (1 << 5)]; t += ki << (52 - 5); s = *(double*)&t; z = C[0] * r + C[1]; @@ -7682,27 +7743,10 @@ __int64 CDECL llrintf(float x) /********************************************************************* * round (MSVCR120.@) - * - * Based on musl implementation: src/math/round.c */ double CDECL round(double x) { - ULONGLONG llx = *(ULONGLONG*)&x, tmp; - int e = (llx >> 52 & 0x7ff) - 0x3ff; - - if (e >= 52) - return x; - if (e < -1) - return 0 * x; - else if (e == -1) - return signbit(x) ? -1 : 1; - - tmp = 0x000fffffffffffffULL >> e; - if (!(llx & tmp)) - return x; - llx += 0x0008000000000000ULL >> e; - llx &= ~tmp; - return *(double*)&llx; + return __round(x); } /********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index 0adf402068f..0498a736812 100644 --- a/dlls/msvcrt/unixlib.c +++ b/dlls/msvcrt/unixlib.c @@ -50,14 +50,6 @@ static double CDECL unix_exp( double x ) return exp( x ); } -/********************************************************************* - * expf - */ -static float CDECL unix_expf( float x ) -{ - return expf( x ); -} - /********************************************************************* * exp2 */ @@ -89,7 +81,6 @@ static float CDECL unix_powf( float x, float y ) static const struct unix_funcs funcs = { unix_exp, - unix_expf, unix_exp2, unix_pow, unix_powf, diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h index c10f25e73f9..21bb5e6c130 100644 --- a/dlls/msvcrt/unixlib.h +++ b/dlls/msvcrt/unixlib.h @@ -24,7 +24,6 @@ struct unix_funcs { double (CDECL *exp)(double x); - float (CDECL *expf)(float x); double (CDECL *exp2)(double x); double (CDECL *pow)(double x, double y); float (CDECL *powf)(float x, float y);
1
0
0
0
Piotr Caban : msvcrt: Import exp2f implementation from musl.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 07e31f4eaf47c6f079d52d1069b2d384c837b021 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=07e31f4eaf47c6f079d52d10…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Thu Jun 10 19:04:27 2021 +0200 msvcrt: Import exp2f implementation from musl. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- configure | 3 +-- configure.ac | 3 +-- dlls/msvcrt/math.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++--- dlls/msvcrt/unixlib.c | 13 ------------ dlls/msvcrt/unixlib.h | 1 - include/config.h.in | 3 --- 6 files changed, 57 insertions(+), 24 deletions(-) diff --git a/configure b/configure index 3e798c50788..74c72003827 100755 --- a/configure +++ b/configure @@ -19620,8 +19620,7 @@ $as_echo "#define HAVE_ISNAN 1" >>confdefs.h fi for ac_func in \ - exp2 \ - exp2f + exp2 do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.ac b/configure.ac index db1fc0462b1..dc43d73858f 100644 --- a/configure.ac +++ b/configure.ac @@ -2659,8 +2659,7 @@ then fi AC_CHECK_FUNCS(\ - exp2 \ - exp2f + exp2 ) LIBS="$ac_save_LIBS" diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 4d7cc6ab727..ae943e845e8 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -7025,12 +7025,64 @@ double CDECL exp2(double x) /********************************************************************* * exp2f (MSVCR120.@) + * + * Copied from musl: src/math/exp2f.c */ float CDECL exp2f(float x) { - float ret = unix_funcs->exp2f( x ); - if (isfinite(x) && !isfinite(ret)) *_errno() = ERANGE; - return ret; + static const UINT64 T[] = { + 0x3ff0000000000000ULL, 0x3fefd9b0d3158574ULL, 0x3fefb5586cf9890fULL, 0x3fef9301d0125b51ULL, + 0x3fef72b83c7d517bULL, 0x3fef54873168b9aaULL, 0x3fef387a6e756238ULL, 0x3fef1e9df51fdee1ULL, + 0x3fef06fe0a31b715ULL, 0x3feef1a7373aa9cbULL, 0x3feedea64c123422ULL, 0x3feece086061892dULL, + 0x3feebfdad5362a27ULL, 0x3feeb42b569d4f82ULL, 0x3feeab07dd485429ULL, 0x3feea47eb03a5585ULL, + 0x3feea09e667f3bcdULL, 0x3fee9f75e8ec5f74ULL, 0x3feea11473eb0187ULL, 0x3feea589994cce13ULL, + 0x3feeace5422aa0dbULL, 0x3feeb737b0cdc5e5ULL, 0x3feec49182a3f090ULL, 0x3feed503b23e255dULL, + 0x3feee89f995ad3adULL, 0x3feeff76f2fb5e47ULL, 0x3fef199bdd85529cULL, 0x3fef3720dcef9069ULL, + 0x3fef5818dcfba487ULL, 0x3fef7c97337b9b5fULL, 0x3fefa4afa2a490daULL, 0x3fefd0765b6e4540ULL + }; + 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 = 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; } /********************************************************************* diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c index 91c6bc4c2f0..0adf402068f 100644 --- a/dlls/msvcrt/unixlib.c +++ b/dlls/msvcrt/unixlib.c @@ -70,18 +70,6 @@ static double CDECL unix_exp2( double x ) #endif } -/********************************************************************* - * exp2f - */ -static float CDECL unix_exp2f( float x ) -{ -#ifdef HAVE_EXP2F - return exp2f(x); -#else - return unix_exp2(x); -#endif -} - /********************************************************************* * pow */ @@ -103,7 +91,6 @@ static const struct unix_funcs funcs = unix_exp, unix_expf, unix_exp2, - unix_exp2f, unix_pow, unix_powf, }; diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h index b7afa6cdf8b..c10f25e73f9 100644 --- a/dlls/msvcrt/unixlib.h +++ b/dlls/msvcrt/unixlib.h @@ -26,7 +26,6 @@ struct unix_funcs double (CDECL *exp)(double x); float (CDECL *expf)(float x); double (CDECL *exp2)(double x); - float (CDECL *exp2f)(float x); double (CDECL *pow)(double x, double y); float (CDECL *powf)(float x, float y); }; diff --git a/include/config.h.in b/include/config.h.in index 09bcdd70983..68122959035 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -95,9 +95,6 @@ /* Define to 1 if you have the `exp2' function. */ #undef HAVE_EXP2 -/* Define to 1 if you have the `exp2f' function. */ -#undef HAVE_EXP2F - /* Define to 1 if you have the `F3DAudioInitialize8' function. */ #undef HAVE_F3DAUDIOINITIALIZE8
1
0
0
0
Francois Gouget : wined3d: Avoid an unneeded NULL cast.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 2fb789f5c65e9bc7e357518258aee14933fc989a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2fb789f5c65e9bc7e3575182…
Author: Francois Gouget <fgouget(a)free.fr> Date: Thu Jun 10 14:27:03 2021 +0200 wined3d: Avoid an unneeded NULL cast. Signed-off-by: Francois Gouget <fgouget(a)free.fr> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index c7a9b4da3e1..c77de1796c4 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -5013,7 +5013,7 @@ static void wined3d_texture_vk_download_data(struct wined3d_context *context, wined3d_context_vk_wait_command_buffer(context_vk, src_texture_vk->image.command_buffer_id); staging_bo_addr.buffer_object = (uintptr_t)&staging_bo; - staging_bo_addr.addr = (uint8_t *)NULL; + staging_bo_addr.addr = NULL; if (!(map_ptr = wined3d_context_map_bo_address(context, &staging_bo_addr, sub_resource->size, WINED3D_MAP_READ))) {
1
0
0
0
Stefan Dösinger : user32: Delete info.hbmColor and hbmMask after copying.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: efa52619af448cd1c30a2fc8b872030c6adcf25e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=efa52619af448cd1c30a2fc8…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Thu Jun 10 16:12:20 2021 +0200 user32: Delete info.hbmColor and hbmMask after copying. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/cursoricon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index f820c10a0d8..7ad0a04a551 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1670,12 +1670,16 @@ HICON WINAPI CreateIcon( HINSTANCE instance, int width, int height, BYTE planes, HICON WINAPI CopyIcon( HICON icon ) { ICONINFOEXW info; + HICON res; info.cbSize = sizeof(info); if (!GetIconInfoExW( icon, &info )) return NULL; - return CopyImage( icon, info.fIcon ? IMAGE_ICON : IMAGE_CURSOR, 0, 0, 0 ); + res = CopyImage( icon, info.fIcon ? IMAGE_ICON : IMAGE_CURSOR, 0, 0, 0 ); + DeleteObject( info.hbmColor ); + DeleteObject( info.hbmMask ); + return res; }
1
0
0
0
Stefan Dösinger : user32: Release the icon frame in CopyImage.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 7ec5a7e1b642cfc5d2adc25b1c1ded21f1dde872 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7ec5a7e1b642cfc5d2adc25b…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Thu Jun 10 16:12:19 2021 +0200 user32: Release the icon frame in CopyImage. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/cursoricon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index a225303f80f..f820c10a0d8 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -3000,6 +3000,7 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, { if (!(info.hbmColor = create_color_bitmap( desiredx, desiredy ))) { + release_icon_frame( icon, frame ); release_user_handle_ptr( icon ); return 0; } @@ -3009,6 +3010,7 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, if (!(info.hbmMask = CreateBitmap( desiredx, desiredy, 1, 1, NULL ))) { DeleteObject( info.hbmColor ); + release_icon_frame( icon, frame ); release_user_handle_ptr( icon ); return 0; } @@ -3034,6 +3036,7 @@ HANDLE WINAPI CopyImage( HANDLE hnd, UINT type, INT desiredx, DeleteObject( info.hbmMask ); } + release_icon_frame( icon, frame ); release_user_handle_ptr( icon ); if (res && (flags & LR_COPYDELETEORG)) DeleteObject( hnd );
1
0
0
0
Ziqing Hui : d3dx10/tests: Check more members of texture descriptor.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 6161571a7228be7f2ac23bac4929956926d63720 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6161571a7228be7f2ac23bac…
Author: Ziqing Hui <zhui(a)codeweavers.com> Date: Mon Jun 7 14:57:22 2021 +0800 d3dx10/tests: Check more members of texture descriptor. Signed-off-by: Ziqing Hui <zhui(a)codeweavers.com> Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3dx10_43/tests/d3dx10.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/dlls/d3dx10_43/tests/d3dx10.c b/dlls/d3dx10_43/tests/d3dx10.c index b0800d26407..235c60ebf7e 100644 --- a/dlls/d3dx10_43/tests/d3dx10.c +++ b/dlls/d3dx10_43/tests/d3dx10.c @@ -767,9 +767,25 @@ static void check_resource_info(ID3D10Resource *resource, unsigned int i, unsign ok_(__FILE__, line)(desc_2d.Format == test_image[i].expected.Format, "Test %u: Got unexpected Format %u, expected %u.\n", i, desc_2d.Format, test_image[i].expected.Format); + ok_(__FILE__, line)(desc_2d.SampleDesc.Count == 1, + "Test %u: Got unexpected SampleDesc.Count %u, expected %u\n", + i, desc_2d.SampleDesc.Count, 1); + ok_(__FILE__, line)(desc_2d.SampleDesc.Quality == 0, + "Test %u: Got unexpected SampleDesc.Quality %u, expected %u\n", + i, desc_2d.SampleDesc.Quality, 0); + ok_(__FILE__, line)(desc_2d.Usage == D3D10_USAGE_DEFAULT, + "Test %u: Got unexpected Usage %u, expected %u\n", + i, desc_2d.Usage, D3D10_USAGE_DEFAULT); + ok_(__FILE__, line)(desc_2d.BindFlags == D3D10_BIND_SHADER_RESOURCE, + "Test %u: Got unexpected BindFlags %#x, expected %#x\n", + i, desc_2d.BindFlags, D3D10_BIND_SHADER_RESOURCE); + ok_(__FILE__, line)(desc_2d.CPUAccessFlags == 0, + "Test %u: Got unexpected CPUAccessFlags %#x, expected %#x\n", + i, desc_2d.CPUAccessFlags, 0); ok_(__FILE__, line)(desc_2d.MiscFlags == test_image[i].expected.MiscFlags, - "Test %u: Got unexpected MiscFlags %u, expected %u.\n", + "Test %u: Got unexpected MiscFlags %#x, expected %#x.\n", i, desc_2d.MiscFlags, test_image[i].expected.MiscFlags); + ID3D10Texture2D_Release(texture_2d); break; @@ -792,8 +808,17 @@ static void check_resource_info(ID3D10Resource *resource, unsigned int i, unsign ok_(__FILE__, line)(desc_3d.Format == test_image[i].expected.Format, "Test %u: Got unexpected Format %u, expected %u.\n", i, desc_3d.Format, test_image[i].expected.Format); + ok_(__FILE__, line)(desc_3d.Usage == D3D10_USAGE_DEFAULT, + "Test %u: Got unexpected Usage %u, expected %u\n", + i, desc_3d.Usage, D3D10_USAGE_DEFAULT); + ok_(__FILE__, line)(desc_3d.BindFlags == D3D10_BIND_SHADER_RESOURCE, + "Test %u: Got unexpected BindFlags %#x, expected %#x\n", + i, desc_3d.BindFlags, D3D10_BIND_SHADER_RESOURCE); + ok_(__FILE__, line)(desc_3d.CPUAccessFlags == 0, + "Test %u: Got unexpected CPUAccessFlags %#x, expected %#x\n", + i, desc_3d.CPUAccessFlags, 0); ok_(__FILE__, line)(desc_3d.MiscFlags == test_image[i].expected.MiscFlags, - "Test %u: Got unexpected MiscFlags %u, expected %u.\n", + "Test %u: Got unexpected MiscFlags %#x, expected %#x.\n", i, desc_3d.MiscFlags, test_image[i].expected.MiscFlags); ID3D10Texture3D_Release(texture_3d); break;
1
0
0
0
Nikolay Sivov : d3d11: Fix freed memory access when releasing device context (Coverity).
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: d26275f9053f46b71c6325cc1cade0c7cc5921dd URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d26275f9053f46b71c6325cc…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Wed Jun 9 08:57:00 2021 +0300 d3d11: Fix freed memory access when releasing device context (Coverity). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d11/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index d3e49879676..56f34c70ea1 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -521,13 +521,14 @@ static ULONG STDMETHODCALLTYPE d3d11_device_context_Release(ID3D11DeviceContext1 if (!refcount) { + ID3D11Device2 *device = &context->device->ID3D11Device2_iface; if (context->type != D3D11_DEVICE_CONTEXT_IMMEDIATE) { wined3d_deferred_context_destroy(context->wined3d_context); d3d11_device_context_cleanup(context); heap_free(context); } - ID3D11Device2_Release(&context->device->ID3D11Device2_iface); + ID3D11Device2_Release(device); } return refcount;
1
0
0
0
Nikolay Sivov : d2d1: Reuse PS constant buffer object.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: f74163ad583303606ff6ef4caa54eba0f685c506 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f74163ad583303606ff6ef4c…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Thu Jun 10 15:13:23 2021 +0300 d2d1: Reuse PS constant buffer object. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d2d1/brush.c | 33 +----------- dlls/d2d1/d2d1_private.h | 4 +- dlls/d2d1/device.c | 133 +++++++++++++++++++++++++++-------------------- 3 files changed, 80 insertions(+), 90 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=f74163ad583303606ff6…
1
0
0
0
Nikolay Sivov : d2d1: Remove unused argument from constant buffer initialization helper.
by Alexandre Julliard
10 Jun '21
10 Jun '21
Module: wine Branch: master Commit: 140c4a094a4f4007fd56e6d0f6286280e5c08c36 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=140c4a094a4f4007fd56e6d0…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Thu Jun 10 15:13:22 2021 +0300 d2d1: Remove unused argument from constant buffer initialization helper. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d2d1/brush.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 76276bafc7a..94ed95337f4 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -1122,8 +1122,7 @@ static D3D10_TEXTURE_ADDRESS_MODE texture_address_mode_from_extend_mode(D2D1_EXT } } -static BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, - const struct d2d_device_context *render_target, struct d2d_brush_cb *cb) +static BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb) { float theta, sin_theta, cos_theta; float dpi_scale, d, s1, s2, t, u; @@ -1249,9 +1248,9 @@ HRESULT d2d_brush_get_ps_cb(struct d2d_brush *brush, struct d2d_brush *opacity_b cb_data.outline = outline; cb_data.is_arc = is_arc; - if (!d2d_brush_fill_cb(brush, render_target, &cb_data.colour_brush)) + if (!d2d_brush_fill_cb(brush, &cb_data.colour_brush)) return E_NOTIMPL; - if (!d2d_brush_fill_cb(opacity_brush, render_target, &cb_data.opacity_brush)) + if (!d2d_brush_fill_cb(opacity_brush, &cb_data.opacity_brush)) return E_NOTIMPL; buffer_desc.ByteWidth = sizeof(cb_data);
1
0
0
0
← Newer
1
...
45
46
47
48
49
50
51
...
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