authorgravatar for hi@mihaelm.commihael <hi@mihaelm.com> 2026-03-14 10:55:04+01:00
committergravatar for hi@mihaelm.commihael <hi@mihaelm.com> 2026-03-17 23:33:10+01:00
logc77103add76a320d1ce877216e26dddd390caadc
tree24d7cdd82475eeac34d225399bba239c606ff0e5
parent69cbe8ea3c54b181a42612973ae25aada7bd8b6e
signaturebadge-check Signed by SSH key SHA256:aoFoShdYLdrqMichqKXSSieTKUfACUIDJHsKc4V2tQg

`libzigc`: implement `acoshf`

The functions were tested by running: ``` $ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib $ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=acoshf -fqemu -fwasmtime --summary line Build Summary: 369/369 steps succeeded ```

4 files changed, 5 insertions(+), 28 deletions(-)

lib/c/math.zig+5
......@@ -42,6 +42,7 @@ comptime {
4242 if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
4343 symbol(&acos, "acos");
4444 symbol(&acosf, "acosf");
45 symbol(&acoshf, "acoshf");
4546 symbol(&asin, "asin");
4647 symbol(&atan, "atan");
4748 symbol(&atanf, "atanf");
......@@ -74,6 +75,10 @@ fn acosf(x: f32) callconv(.c) f32 {
7475 return math.acos(x);
7576}
7677
78fn acoshf(x: f32) callconv(.c) f32 {
79 return math.acosh(x);
80}
81
7782fn asin(x: f64) callconv(.c) f64 {
7883 return math.asin(x);
7984}
lib/libc/musl/src/math/acoshf.c deleted-26
......@@ -1,26 +0,0 @@
1#include "libm.h"
2
3#if FLT_EVAL_METHOD==2
4#undef sqrtf
5#define sqrtf sqrtl
6#elif FLT_EVAL_METHOD==1
7#undef sqrtf
8#define sqrtf sqrt
9#endif
10
11/* acosh(x) = log(x + sqrt(x*x-1)) */
12float acoshf(float x)
13{
14 union {float f; uint32_t i;} u = {x};
15 uint32_t a = u.i & 0x7fffffff;
16
17 if (a < 0x3f800000+(1<<23))
18 /* |x| < 2, invalid if x < 1 */
19 /* up to 2ulp error in [1,1.125] */
20 return log1pf(x-1 + sqrtf((x-1)*(x-1)+2*(x-1)));
21 if (u.i < 0x3f800000+(12<<23))
22 /* 2 <= x < 0x1p12 */
23 return logf(2*x - 1/(x+sqrtf(x*x-1)));
24 /* x >= 0x1p12 or x <= -2 or nan */
25 return logf(x) + 0.693147180559945309417232121458176568f;
26}
src/libs/musl.zig-1
......@@ -796,7 +796,6 @@ const src_files = [_][]const u8{
796796 "musl/src/math/aarch64/nearbyintf.c",
797797 "musl/src/math/aarch64/rintf.c",
798798 "musl/src/math/acosh.c",
799 "musl/src/math/acoshf.c",
800799 "musl/src/math/acoshl.c",
801800 "musl/src/math/acosl.c",
802801 "musl/src/math/arm/fma.c",
src/libs/wasi_libc.zig-1
......@@ -665,7 +665,6 @@ const libc_top_half_src_files = [_][]const u8{
665665 "musl/src/locale/wcscoll.c",
666666 "musl/src/locale/wcsxfrm.c",
667667 "musl/src/math/acosh.c",
668 "musl/src/math/acoshf.c",
669668 "musl/src/math/acoshl.c",
670669 "musl/src/math/acosl.c",
671670 "musl/src/math/asinf.c",