]> git.proxmox.com Git - wasi-libc.git/commitdiff
Fix sinh's sign handling
authorDan Gohman <dev@sunfishcode.online>
Mon, 30 Nov 2020 21:25:28 +0000 (13:25 -0800)
committerDan Gohman <dev@sunfishcode.online>
Tue, 1 Dec 2020 00:12:10 +0000 (16:12 -0800)
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
libc-top-half/musl/src/math/sinhf.c

index 8463abc7b6fd15b600822e39db23474102b8199d..c8dda8d6849e49fc4e489ba5e71cae05f86ebce4 100644 (file)
@@ -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;
 }
index 1fcd27a0646a217aeb80c39dea81605c7e1dba51..3ac49e218678cd69dab0e7be853bc1286bcc656d 100644 (file)
@@ -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;
 }