| author | |
| committer | |
| log | c77103add76a320d1ce877216e26dddd390caadc |
| tree | 24d7cdd82475eeac34d225399bba239c606ff0e5 |
| parent | 69cbe8ea3c54b181a42612973ae25aada7bd8b6e |
| signature |
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 { |
| 42 | 42 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 43 | 43 | symbol(&acos, "acos"); |
| 44 | 44 | symbol(&acosf, "acosf"); |
| 45 | symbol(&acoshf, "acoshf"); | |
| 45 | 46 | symbol(&asin, "asin"); |
| 46 | 47 | symbol(&atan, "atan"); |
| 47 | 48 | symbol(&atanf, "atanf"); |
| ... | ... | @@ -74,6 +75,10 @@ fn acosf(x: f32) callconv(.c) f32 { |
| 74 | 75 | return math.acos(x); |
| 75 | 76 | } |
| 76 | 77 | |
| 78 | fn acoshf(x: f32) callconv(.c) f32 { | |
| 79 | return math.acosh(x); | |
| 80 | } | |
| 81 | ||
| 77 | 82 | fn asin(x: f64) callconv(.c) f64 { |
| 78 | 83 | return math.asin(x); |
| 79 | 84 | } |
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)) */ | |
| 12 | float 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{ |
| 796 | 796 | "musl/src/math/aarch64/nearbyintf.c", |
| 797 | 797 | "musl/src/math/aarch64/rintf.c", |
| 798 | 798 | "musl/src/math/acosh.c", |
| 799 | "musl/src/math/acoshf.c", | |
| 800 | 799 | "musl/src/math/acoshl.c", |
| 801 | 800 | "musl/src/math/acosl.c", |
| 802 | 801 | "musl/src/math/arm/fma.c", |
src/libs/wasi_libc.zig-1| ... | ... | @@ -665,7 +665,6 @@ const libc_top_half_src_files = [_][]const u8{ |
| 665 | 665 | "musl/src/locale/wcscoll.c", |
| 666 | 666 | "musl/src/locale/wcsxfrm.c", |
| 667 | 667 | "musl/src/math/acosh.c", |
| 668 | "musl/src/math/acoshf.c", | |
| 669 | 668 | "musl/src/math/acoshl.c", |
| 670 | 669 | "musl/src/math/acosl.c", |
| 671 | 670 | "musl/src/math/asinf.c", |