From 90c61c7cd2d120ebc48e262bc47186ce23cd233e Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 30 Mar 2023 13:37:39 +0200 Subject: [PATCH] msvcrt: Use the __cosdf() implementation from the bundled musl library. With the changes from 9008cd2f2437650ad41ce8a8924ed1828ca21889. --- dlls/msvcrt/math.c | 17 +---------------- libs/musl/src/math/__cosdf.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 8fa904b1cc9..684a4807489 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -220,22 +220,7 @@ float CDECL _chgsignf( float num ) #ifndef __i386__ extern float __sindf(double x); - -/* Copied from musl: src/math/__cosdf.c */ -static float __cosdf(double x) -{ - static const double C0 = -0x1.0000000000000p-1, - C1 = 0x1.5555555555555p-5, - C2 = -0x1.6c16c16c16c17p-10, - C3 = 0x1.a01a01a01a01ap-16, - C4 = -0x1.27e4fb7789f5cp-22; - double z; - - z = x * x; - if (x > -7.8163146972656250e-03 && x < 7.8163146972656250e-03) - return 1 + C0 * z; - return 1.0 + z * (C0 + z * (C1 + z * (C2 + z * (C3 + z * C4)))); -} +extern float __cosdf(double x); static const UINT64 exp2f_T[] = { 0x3ff0000000000000ULL, 0x3fefd9b0d3158574ULL, 0x3fefb5586cf9890fULL, 0x3fef9301d0125b51ULL, diff --git a/libs/musl/src/math/__cosdf.c b/libs/musl/src/math/__cosdf.c index 2124989b329..a84a50c6980 100644 --- a/libs/musl/src/math/__cosdf.c +++ b/libs/musl/src/math/__cosdf.c @@ -18,18 +18,18 @@ /* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */ static const double -C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */ -C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */ -C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */ -C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */ +C0 = -0x1.0000000000000p-1, +C1 = 0x1.5555555555555p-5, +C2 = -0x1.6c16c16c16c17p-10, +C3 = 0x1.a01a01a01a01ap-16, +C4 = -0x1.27e4fb7789f5cp-22; float __cosdf(double x) { - double_t r, w, z; + double_t z; - /* Try to optimize for parallel evaluation as in __tandf.c. */ z = x*x; - w = z*z; - r = C2+z*C3; - return ((1.0+z*C0) + w*C1) + (w*z)*r; + if (x > -7.8163146972656250e-03 && x < 7.8163146972656250e-03) + return 1 + C0 * z; + return 1.0 + z * (C0 + z * (C1 + z * (C2 + z * (C3 + z * C4)))); }