From 424d0582ca0e0cf9dfea90202c1002641a06db88 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 30 Nov 2020 13:25:28 -0800 Subject: [PATCH] Fix sinh's sign handling In the musl 1.2.1 update, I made a change to disable the new code in sinh for handling directed rounding modes, but I only incompletely disabled it. This led to `sinh(-inf)` computing `inf` instead of `-inf`, detected in [wasi-libc-test]. This patch fixes it. [wasi-libc-test]: https://github.com/CraneStation/wasi-libc-test/tree/master/libc-test --- libc-top-half/musl/src/math/sinh.c | 2 +- libc-top-half/musl/src/math/sinhf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-top-half/musl/src/math/sinh.c b/libc-top-half/musl/src/math/sinh.c index 8463abc..c8dda8d 100644 --- a/libc-top-half/musl/src/math/sinh.c +++ b/libc-top-half/musl/src/math/sinh.c @@ -37,7 +37,7 @@ double sinh(double x) #ifdef __wasilibc_unmodified_upstream // Wasm doesn't have alternate rounding modes t = __expo2(absx, 2*h); #else - t = __expo2(absx); + t = 2*h*__expo2(absx); #endif return t; } diff --git a/libc-top-half/musl/src/math/sinhf.c b/libc-top-half/musl/src/math/sinhf.c index 1fcd27a..3ac49e2 100644 --- a/libc-top-half/musl/src/math/sinhf.c +++ b/libc-top-half/musl/src/math/sinhf.c @@ -29,7 +29,7 @@ float sinhf(float x) #ifdef __wasilibc_unmodified_upstream // Wasm doesn't have alternate rounding modes t = __expo2f(absx, 2*h); #else - t = __expo2f(absx); + t = 2*h*__expo2f(absx); #endif return t; } -- 2.39.2