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
October 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
2 participants
1165 discussions
Start a n
N
ew thread
Alexandre Julliard : ntdll: Copy sqrt() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 2e4c090c5ecac67908e3fb3290925503c358c38b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2e4c090c5ecac67908e3fb32…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:34:06 2021 +0200 ntdll: Copy sqrt() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index 3126f1d7b39..e6de9e67c1f 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -1047,6 +1047,37 @@ static inline int pow_checkint(UINT64 iy) return 2; } +/* Copied from musl: src/math/__fpclassify.c */ +static short _dclass(double x) +{ + union { double f; UINT64 i; } u = { x }; + int e = u.i >> 52 & 0x7ff; + + if (!e) return u.i << 1 ? FP_SUBNORMAL : FP_ZERO; + if (e == 0x7ff) return (u.i << 12) ? FP_NAN : FP_INFINITE; + return FP_NORMAL; +} + +static BOOL sqrt_validate( double *x, BOOL update_sw ) +{ + short c = _dclass(*x); + + if (c == FP_ZERO) return FALSE; + if (c == FP_NAN) + { + /* set signaling bit */ + *(ULONGLONG*)x |= 0x8000000000000ULL; + return FALSE; + } + if (signbit(*x)) + { + *x = -NAN; + return FALSE; + } + if (c == FP_INFINITE) return FALSE; + return TRUE; +} + /********************************************************************* * abs (NTDLL.@) @@ -1756,10 +1787,109 @@ double CDECL sin( double x ) /********************************************************************* * sqrt (NTDLL.@) + * + * Copied from musl: src/math/sqrt.c */ -double CDECL sqrt( double d ) +double CDECL sqrt( double x ) { - return unix_funcs->sqrt( d ); + static const double tiny = 1.0e-300; + + double z; + int sign = 0x80000000; + int ix0,s0,q,m,t,i; + unsigned int r,t1,s1,ix1,q1; + ULONGLONG ix; + + if (!sqrt_validate(&x, TRUE)) + return x; + + ix = *(ULONGLONG*)&x; + ix0 = ix >> 32; + ix1 = ix; + + /* normalize x */ + m = ix0 >> 20; + if (m == 0) { /* subnormal x */ + while (ix0 == 0) { + m -= 21; + ix0 |= (ix1 >> 11); + ix1 <<= 21; + } + for (i=0; (ix0 & 0x00100000) == 0; i++) + ix0 <<= 1; + m -= i - 1; + ix0 |= ix1 >> (32 - i); + ix1 <<= i; + } + m -= 1023; /* unbias exponent */ + ix0 = (ix0 & 0x000fffff) | 0x00100000; + if (m & 1) { /* odd m, double x to make it even */ + ix0 += ix0 + ((ix1 & sign) >> 31); + ix1 += ix1; + } + m >>= 1; /* m = [m/2] */ + + /* generate sqrt(x) bit by bit */ + ix0 += ix0 + ((ix1 & sign) >> 31); + ix1 += ix1; + q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ + r = 0x00200000; /* r = moving bit from right to left */ + + while (r != 0) { + t = s0 + r; + if (t <= ix0) { + s0 = t + r; + ix0 -= t; + q += r; + } + ix0 += ix0 + ((ix1 & sign) >> 31); + ix1 += ix1; + r >>= 1; + } + + r = sign; + while (r != 0) { + t1 = s1 + r; + t = s0; + if (t < ix0 || (t == ix0 && t1 <= ix1)) { + s1 = t1 + r; + if ((t1&sign) == sign && (s1 & sign) == 0) + s0++; + ix0 -= t; + if (ix1 < t1) + ix0--; + ix1 -= t1; + q1 += r; + } + ix0 += ix0 + ((ix1 & sign) >> 31); + ix1 += ix1; + r >>= 1; + } + + /* use floating add to find out rounding direction */ + if ((ix0 | ix1) != 0) { + z = 1.0 - tiny; /* raise inexact flag */ + if (z >= 1.0) { + z = 1.0 + tiny; + if (q1 == (unsigned int)0xffffffff) { + q1 = 0; + q++; + } else if (z > 1.0) { + if (q1 == (unsigned int)0xfffffffe) + q++; + q1 += 2; + } else + q1 += q1 & 1; + } + } + ix0 = (q >> 1) + 0x3fe00000; + ix1 = q1 >> 1; + if (q & 1) + ix1 |= sign; + ix = ix0 + ((unsigned int)m << 20); + ix <<= 32; + ix |= ix1; + return *(double*)&ix; } /*********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Copy pow() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 140cd3553c136864ea722a15834b37d348945e00 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=140cd3553c136864ea722a15…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:34:02 2021 +0200 ntdll: Copy pow() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 564 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 563 insertions(+), 1 deletion(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=140cd3553c136864ea72…
1
0
0
0
Alexandre Julliard : ntdll: Copy log() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 0c0915e98584d93b22d9d02d3752136a65b6fa9f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=0c0915e98584d93b22d9d02d…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:58 2021 +0200 ntdll: Copy log() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 369 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 367 insertions(+), 2 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=0c0915e98584d93b22d9…
1
0
0
0
Alexandre Julliard : ntdll: Copy tan() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 90bd0487862c5c6fae85cb8a7d84b53b59db0098 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=90bd0487862c5c6fae85cb8a…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:55 2021 +0200 ntdll: Copy tan() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index 55d82cc3f8e..58965c7b169 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -507,6 +507,65 @@ static double __cos(double x, double y) return w + (((1.0 - w) - hz) + (z * r - x * y)); } +/* Copied from musl: src/math/__tan.c */ +static double __tan(double x, double y, int odd) +{ + static const double T[] = { + 3.33333333333334091986e-01, + 1.33333333333201242699e-01, + 5.39682539762260521377e-02, + 2.18694882948595424599e-02, + 8.86323982359930005737e-03, + 3.59207910759131235356e-03, + 1.45620945432529025516e-03, + 5.88041240820264096874e-04, + 2.46463134818469906812e-04, + 7.81794442939557092300e-05, + 7.14072491382608190305e-05, + -1.85586374855275456654e-05, + 2.59073051863633712884e-05, + }; + static const double pio4 = 7.85398163397448278999e-01; + static const double pio4lo = 3.06161699786838301793e-17; + + double z, r, v, w, s, a, w0, a0; + UINT32 hx; + int big, sign; + + hx = *(ULONGLONG*)&x >> 32; + big = (hx & 0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */ + if (big) { + sign = hx >> 31; + if (sign) { + x = -x; + y = -y; + } + x = (pio4 - x) + (pio4lo - y); + y = 0.0; + } + z = x * x; + w = z * z; + r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] + w * T[11])))); + v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] + w * T[12]))))); + s = z * x; + r = y + z * (s * (r + v) + y) + s * T[0]; + w = x + r; + if (big) { + s = 1 - 2 * odd; + v = s - 2.0 * (x + (r - w * w / (w + s))); + return sign ? -v : v; + } + if (!odd) + return w; + /* -1.0/(x+r) has up to 2ulp error, so compute it accurately */ + w0 = w; + *(LONGLONG*)&w0 = *(LONGLONG*)&w0 & 0xffffffff00000000ULL; + v = r - (w0 - x); /* w0+v = r+x */ + a0 = a = -1.0 / w; + *(LONGLONG*)&a0 = *(LONGLONG*)&a0 & 0xffffffff00000000ULL; + return a0 + a * (1.0 + a0 * w0 + a0 * v); +} + /********************************************************************* * abs (NTDLL.@) @@ -778,10 +837,33 @@ double CDECL sqrt( double d ) /********************************************************************* * tan (NTDLL.@) + * + * Copied from musl: src/math/tan.c */ -double CDECL tan( double d ) +double CDECL tan( double x ) { - return unix_funcs->tan( d ); + double y[2]; + UINT32 ix; + unsigned n; + + ix = *(ULONGLONG*)&x >> 32; + ix &= 0x7fffffff; + + if (ix <= 0x3fe921fb) { /* |x| ~< pi/4 */ + if (ix < 0x3e400000) { /* |x| < 2**-27 */ + /* raise inexact if x!=0 and underflow if subnormal */ + fp_barrier(ix < 0x00100000 ? x / 0x1p120f : x + 0x1p120f); + return x; + } + return __tan(x, 0.0, 0); + } + + if (isinf(x)) return x - x; + if (ix >= 0x7ff00000) + return x - x; + + n = __rem_pio2(x, y); + return __tan(y[0], y[1], n & 1); } #if (defined(__GNUC__) || defined(__clang__)) && defined(__i386__)
1
0
0
0
Alexandre Julliard : ntdll: Copy sin() and cos() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: e4737d285b83ad38914d635d665f4037640ddba7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e4737d285b83ad38914d635d…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:51 2021 +0200 ntdll: Copy sin() and cos() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 530 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 526 insertions(+), 4 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=e4737d285b83ad38914d…
1
0
0
0
Alexandre Julliard : ntdll: Copy fabs() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 9eb3adbc851733352aa4b7edb401f012290e61b6 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9eb3adbc851733352aa4b7ed…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:47 2021 +0200 ntdll: Copy fabs() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index a7d20acdf59..7202897ce1b 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -183,10 +183,14 @@ double CDECL cos( double d ) /********************************************************************* * fabs (NTDLL.@) + * + * Copied from musl: src/math/fabsf.c */ -double CDECL fabs( double d ) +double CDECL fabs( double x ) { - return unix_funcs->fabs( d ); + union { double f; UINT64 i; } u = { x }; + u.i &= ~0ull >> 1; + return u.f; } /*********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Copy floor() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: f0d3a7d33be980b06abc2298fea90c4d2110643a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f0d3a7d33be980b06abc2298…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:43 2021 +0200 ntdll: Copy floor() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index e7f5987a5af..a7d20acdf59 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -191,10 +191,31 @@ double CDECL fabs( double d ) /********************************************************************* * floor (NTDLL.@) + * + * Based on musl: src/math/floorf.c */ -double CDECL floor( double d ) +double CDECL floor( double x ) { - return unix_funcs->floor( d ); + union {double f; UINT64 i;} u = {x}; + int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff; + UINT64 m; + + if (e >= 52) + return x; + if (e >= 0) { + m = 0x000fffffffffffffULL >> e; + if ((u.i & m) == 0) + return x; + if (u.i >> 63) + u.i += m; + u.i &= ~m; + } else { + if (u.i >> 63 == 0) + return 0; + else if (u.i << 1) + return -1; + } + return u.f; } /*********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Copy ceil() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: fca34420f6348a0344a3eff4f1d882d2b67873f8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fca34420f6348a0344a3eff4…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:39 2021 +0200 ntdll: Copy ceil() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index 25477b44d4a..e7f5987a5af 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -146,10 +146,31 @@ double CDECL atan( double x ) /********************************************************************* * ceil (NTDLL.@) + * + * Based on musl: src/math/ceilf.c */ -double CDECL ceil( double d ) +double CDECL ceil( double x ) { - return unix_funcs->ceil( d ); + union {double f; UINT64 i;} u = {x}; + int e = (u.i >> 52 & 0x7ff) - 0x3ff; + UINT64 m; + + if (e >= 52) + return x; + if (e >= 0) { + m = 0x000fffffffffffffULL >> e; + if ((u.i & m) == 0) + return x; + if (u.i >> 63 == 0) + u.i += m; + u.i &= ~m; + } else { + if (u.i >> 63) + return -0.0; + else if (u.i << 1) + return 1.0; + } + return u.f; } /*********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Copy atan() implementation from msvcrt.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: bb9e068babb9049a09c205ca4bf07fa2744cd26d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=bb9e068babb9049a09c205ca…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:30 2021 +0200 ntdll: Copy atan() implementation from msvcrt. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/math.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c index 8241e5077c2..25477b44d4a 100644 --- a/dlls/ntdll/math.c +++ b/dlls/ntdll/math.c @@ -16,6 +16,23 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + * + * + * For functions copied from musl libc (
http://musl.libc.org/
): + * ==================================================== + * Copyright 2005-2020 Rich Felker, et al. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * ==================================================== */ #include <math.h> @@ -24,6 +41,15 @@ #define WIN32_NO_STATUS #include "ntdll_misc.h" +/* Copied from musl: src/internal/libm.h */ +static inline float fp_barrierf(float x) +{ + volatile float y = x; + return y; +} + + + /********************************************************************* * abs (NTDLL.@) */ @@ -34,10 +60,88 @@ int CDECL abs( int i ) /********************************************************************* * atan (NTDLL.@) + * + * Copied from musl: src/math/atan.c */ -double CDECL atan( double d ) +double CDECL atan( double x ) { - return unix_funcs->atan( d ); + static const double atanhi[] = { + 4.63647609000806093515e-01, + 7.85398163397448278999e-01, + 9.82793723247329054082e-01, + 1.57079632679489655800e+00, + }; + static const double atanlo[] = { + 2.26987774529616870924e-17, + 3.06161699786838301793e-17, + 1.39033110312309984516e-17, + 6.12323399573676603587e-17, + }; + static const double aT[] = { + 3.33333333333329318027e-01, + -1.99999999998764832476e-01, + 1.42857142725034663711e-01, + -1.11111104054623557880e-01, + 9.09088713343650656196e-02, + -7.69187620504482999495e-02, + 6.66107313738753120669e-02, + -5.83357013379057348645e-02, + 4.97687799461593236017e-02, + -3.65315727442169155270e-02, + 1.62858201153657823623e-02, + }; + + double w, s1, s2, z; + unsigned int ix, sign; + int id; + + ix = *(ULONGLONG*)&x >> 32; + sign = ix >> 31; + ix &= 0x7fffffff; + if (ix >= 0x44100000) { /* if |x| >= 2^66 */ + if (isnan(x)) + return x; + z = atanhi[3] + 7.5231638452626401e-37; + return sign ? -z : z; + } + if (ix < 0x3fdc0000) { /* |x| < 0.4375 */ + if (ix < 0x3e400000) { /* |x| < 2^-27 */ + if (ix < 0x00100000) + /* raise underflow for subnormal x */ + fp_barrierf((float)x); + return x; + } + id = -1; + } else { + x = fabs(x); + if (ix < 0x3ff30000) { /* |x| < 1.1875 */ + if (ix < 0x3fe60000) { /* 7/16 <= |x| < 11/16 */ + id = 0; + x = (2.0 * x - 1.0) / (2.0 + x); + } else { /* 11/16 <= |x| < 19/16 */ + id = 1; + x = (x - 1.0) / (x + 1.0); + } + } else { + if (ix < 0x40038000) { /* |x| < 2.4375 */ + id = 2; + x = (x - 1.5) / (1.0 + 1.5 * x); + } else { /* 2.4375 <= |x| < 2^66 */ + id = 3; + x = -1.0 / x; + } + } + } + /* end of argument reduction */ + z = x * x; + w = z * z; + /* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */ + s1 = z * (aT[0] + w * (aT[2] + w * (aT[4] + w * (aT[6] + w * (aT[8] + w * aT[10]))))); + s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9])))); + if (id < 0) + return x - x * (s1 + s2); + z = atanhi[id] - (x * (s1 + s2) - atanlo[id] - x); + return sign ? -z : z; } /*********************************************************************
1
0
0
0
Alexandre Julliard : ntdll: Move math functions to a separate file.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: c7454eef0bf577545225c7c236a3f3b03daf31d3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c7454eef0bf577545225c7c2…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Oct 26 10:33:25 2021 +0200 ntdll: Move math functions to a separate file. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/Makefile.in | 1 + dlls/ntdll/math.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/misc.c | 153 ------------------------------------------ 3 files changed, 178 insertions(+), 153 deletions(-) diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index aac7f8eead7..ba23e397545 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -22,6 +22,7 @@ C_SRCS = \ large_int.c \ loader.c \ locale.c \ + math.c \ misc.c \ path.c \ printf.c \ diff --git a/dlls/ntdll/math.c b/dlls/ntdll/math.c new file mode 100644 index 00000000000..8241e5077c2 --- /dev/null +++ b/dlls/ntdll/math.c @@ -0,0 +1,177 @@ +/* + * Math functions + * + * Copyright 2021 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <math.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS +#include "ntdll_misc.h" + +/********************************************************************* + * abs (NTDLL.@) + */ +int CDECL abs( int i ) +{ + return i >= 0 ? i : -i; +} + +/********************************************************************* + * atan (NTDLL.@) + */ +double CDECL atan( double d ) +{ + return unix_funcs->atan( d ); +} + +/********************************************************************* + * ceil (NTDLL.@) + */ +double CDECL ceil( double d ) +{ + return unix_funcs->ceil( d ); +} + +/********************************************************************* + * cos (NTDLL.@) + */ +double CDECL cos( double d ) +{ + return unix_funcs->cos( d ); +} + +/********************************************************************* + * fabs (NTDLL.@) + */ +double CDECL fabs( double d ) +{ + return unix_funcs->fabs( d ); +} + +/********************************************************************* + * floor (NTDLL.@) + */ +double CDECL floor( double d ) +{ + return unix_funcs->floor( d ); +} + +/********************************************************************* + * log (NTDLL.@) + */ +double CDECL log( double d ) +{ + return unix_funcs->log( d ); +} + +/********************************************************************* + * pow (NTDLL.@) + */ +double CDECL pow( double x, double y ) +{ + return unix_funcs->pow( x, y ); +} + +/********************************************************************* + * sin (NTDLL.@) + */ +double CDECL sin( double d ) +{ + return unix_funcs->sin( d ); +} + +/********************************************************************* + * sqrt (NTDLL.@) + */ +double CDECL sqrt( double d ) +{ + return unix_funcs->sqrt( d ); +} + +/********************************************************************* + * tan (NTDLL.@) + */ +double CDECL tan( double d ) +{ + return unix_funcs->tan( d ); +} + +#if (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) + +#define FPU_DOUBLE(var) double var; \ + __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : ) +#define FPU_DOUBLES(var1,var2) double var1,var2; \ + __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \ + __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : ) + +/********************************************************************* + * _CIcos (NTDLL.@) + */ +double CDECL _CIcos(void) +{ + FPU_DOUBLE(x); + return cos(x); +} + +/********************************************************************* + * _CIlog (NTDLL.@) + */ +double CDECL _CIlog(void) +{ + FPU_DOUBLE(x); + return log(x); +} + +/********************************************************************* + * _CIpow (NTDLL.@) + */ +double CDECL _CIpow(void) +{ + FPU_DOUBLES(x,y); + return pow(x,y); +} + +/********************************************************************* + * _CIsin (NTDLL.@) + */ +double CDECL _CIsin(void) +{ + FPU_DOUBLE(x); + return sin(x); +} + +/********************************************************************* + * _CIsqrt (NTDLL.@) + */ +double CDECL _CIsqrt(void) +{ + FPU_DOUBLE(x); + return sqrt(x); +} + +/********************************************************************* + * _ftol (NTDLL.@) + */ +LONGLONG CDECL _ftol(void) +{ + FPU_DOUBLE(x); + return (LONGLONG)x; +} + +#endif /* (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) */ diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c index 092900b289b..3bef5a561c8 100644 --- a/dlls/ntdll/misc.c +++ b/dlls/ntdll/misc.c @@ -20,7 +20,6 @@ */ #include <time.h> -#include <math.h> #include "ntstatus.h" #define WIN32_NO_STATUS @@ -38,158 +37,6 @@ LPCSTR debugstr_us( const UNICODE_STRING *us ) return debugstr_wn(us->Buffer, us->Length / sizeof(WCHAR)); } -/********************************************************************* - * abs (NTDLL.@) - */ -int CDECL abs( int i ) -{ - return i >= 0 ? i : -i; -} - -/********************************************************************* - * atan (NTDLL.@) - */ -double CDECL atan( double d ) -{ - return unix_funcs->atan( d ); -} - -/********************************************************************* - * ceil (NTDLL.@) - */ -double CDECL ceil( double d ) -{ - return unix_funcs->ceil( d ); -} - -/********************************************************************* - * cos (NTDLL.@) - */ -double CDECL cos( double d ) -{ - return unix_funcs->cos( d ); -} - -/********************************************************************* - * fabs (NTDLL.@) - */ -double CDECL fabs( double d ) -{ - return unix_funcs->fabs( d ); -} - -/********************************************************************* - * floor (NTDLL.@) - */ -double CDECL floor( double d ) -{ - return unix_funcs->floor( d ); -} - -/********************************************************************* - * log (NTDLL.@) - */ -double CDECL log( double d ) -{ - return unix_funcs->log( d ); -} - -/********************************************************************* - * pow (NTDLL.@) - */ -double CDECL pow( double x, double y ) -{ - return unix_funcs->pow( x, y ); -} - -/********************************************************************* - * sin (NTDLL.@) - */ -double CDECL sin( double d ) -{ - return unix_funcs->sin( d ); -} - -/********************************************************************* - * sqrt (NTDLL.@) - */ -double CDECL sqrt( double d ) -{ - return unix_funcs->sqrt( d ); -} - -/********************************************************************* - * tan (NTDLL.@) - */ -double CDECL tan( double d ) -{ - return unix_funcs->tan( d ); -} - -#if (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) - -#define FPU_DOUBLE(var) double var; \ - __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var) : ) -#define FPU_DOUBLES(var1,var2) double var1,var2; \ - __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var2) : ); \ - __asm__ __volatile__( "fstpl %0;fwait" : "=m" (var1) : ) - -/********************************************************************* - * _CIcos (NTDLL.@) - */ -double CDECL _CIcos(void) -{ - FPU_DOUBLE(x); - return cos(x); -} - -/********************************************************************* - * _CIlog (NTDLL.@) - */ -double CDECL _CIlog(void) -{ - FPU_DOUBLE(x); - return log(x); -} - -/********************************************************************* - * _CIpow (NTDLL.@) - */ -double CDECL _CIpow(void) -{ - FPU_DOUBLES(x,y); - return pow(x,y); -} - -/********************************************************************* - * _CIsin (NTDLL.@) - */ -double CDECL _CIsin(void) -{ - FPU_DOUBLE(x); - return sin(x); -} - -/********************************************************************* - * _CIsqrt (NTDLL.@) - */ -double CDECL _CIsqrt(void) -{ - FPU_DOUBLE(x); - return sqrt(x); -} - -/********************************************************************* - * _ftol (NTDLL.@) - */ -LONGLONG CDECL _ftol(void) -{ - FPU_DOUBLE(x); - return (LONGLONG)x; -} - -#endif /* (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) */ - static void NTDLL_mergesort( void *arr, void *barr, size_t elemsize, int(__cdecl *compar)(const void *, const void *), size_t left, size_t right )
1
0
0
0
← Newer
1
...
14
15
16
17
18
19
20
...
117
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Results per page:
10
25
50
100
200