Module: wine Branch: master Commit: 248a17377cd535afed8ae611ce7d8401815e3629 URL: https://gitlab.winehq.org/wine/wine/-/commit/248a17377cd535afed8ae611ce7d840...
Author: Alexandre Julliard julliard@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; }