| author | |
| committer | |
| log | 159568a05a222681f54a27310ac15c3043563f95 |
| tree | 4d173c445efc90f343f80b0712cfa939c495e9ef |
| parent | 1f92162875a3f05942dad6696b206cb9a1394f80 |
| signature |
The function basically calls the Zig std's implementation.
The changes 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=coshf -fqemu -fwasmtime --summary line
Build Summary: 553/553 steps succeeded
```7 files changed, 5 insertions(+), 83 deletions(-)
lib/c/math.zig+5| ... | @@ -31,6 +31,7 @@ comptime { | ... | @@ -31,6 +31,7 @@ comptime { |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 33 | if (builtin.target.isMinGW() or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 34 | symbol(&coshf, "coshf"); | ||
| 34 | symbol(&hypotf, "hypotf"); | 35 | symbol(&hypotf, "hypotf"); |
| 35 | symbol(&hypotl, "hypotl"); | 36 | symbol(&hypotl, "hypotl"); |
| 36 | symbol(&nan, "nan"); | 37 | symbol(&nan, "nan"); |
| ... | @@ -130,6 +131,10 @@ fn cosh(x: f64) callconv(.c) f64 { | ... | @@ -130,6 +131,10 @@ fn cosh(x: f64) callconv(.c) f64 { |
| 130 | return math.cosh(x); | 131 | return math.cosh(x); |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 134 | fn coshf(x: f32) callconv(.c) f32 { | ||
| 135 | return math.cosh(x); | ||
| 136 | } | ||
| 137 | |||
| 133 | fn cbrt(x: f64) callconv(.c) f64 { | 138 | fn cbrt(x: f64) callconv(.c) f64 { |
| 134 | return math.cbrt(x); | 139 | return math.cbrt(x); |
| 135 | } | 140 | } |
lib/libc/mingw/math/coshf.c deleted-10| ... | @@ -1,10 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | #include <math.h> | ||
| 7 | float coshf (float x) | ||
| 8 | { | ||
| 9 | return (float) cosh (x); | ||
| 10 | } | ||
lib/libc/musl/src/math/coshf.c deleted-33| ... | @@ -1,33 +0,0 @@ | ||
| 1 | #include "libm.h" | ||
| 2 | |||
| 3 | float coshf(float x) | ||
| 4 | { | ||
| 5 | 	union {float f; uint32_t i;} u = {.f = x}; | ||
| 6 | 	uint32_t w; | ||
| 7 | 	float t; | ||
| 8 | |||
| 9 | 	/* |x| */ | ||
| 10 | 	u.i &= 0x7fffffff; | ||
| 11 | 	x = u.f; | ||
| 12 | 	w = u.i; | ||
| 13 | |||
| 14 | 	/* |x| < log(2) */ | ||
| 15 | 	if (w < 0x3f317217) { | ||
| 16 | 		if (w < 0x3f800000 - (12<<23)) { | ||
| 17 | 			FORCE_EVAL(x + 0x1p120f); | ||
| 18 | 			return 1; | ||
| 19 | 		} | ||
| 20 | 		t = expm1f(x); | ||
| 21 | 		return 1 + t*t/(2*(1+t)); | ||
| 22 | 	} | ||
| 23 | |||
| 24 | 	/* |x| < log(FLT_MAX) */ | ||
| 25 | 	if (w < 0x42b17217) { | ||
| 26 | 		t = expf(x); | ||
| 27 | 		return 0.5f*(t + 1/t); | ||
| 28 | 	} | ||
| 29 | |||
| 30 | 	/* |x| > log(FLT_MAX) or nan */ | ||
| 31 | 	t = __expo2f(x, 1.0f); | ||
| 32 | 	return t; | ||
| 33 | } | ||
lib/libc/wasi/libc-top-half/musl/src/math/coshf.c deleted-37| ... | @@ -1,37 +0,0 @@ | ||
| 1 | #include "libm.h" | ||
| 2 | |||
| 3 | float coshf(float x) | ||
| 4 | { | ||
| 5 | 	union {float f; uint32_t i;} u = {.f = x}; | ||
| 6 | 	uint32_t w; | ||
| 7 | 	float t; | ||
| 8 | |||
| 9 | 	/* |x| */ | ||
| 10 | 	u.i &= 0x7fffffff; | ||
| 11 | 	x = u.f; | ||
| 12 | 	w = u.i; | ||
| 13 | |||
| 14 | 	/* |x| < log(2) */ | ||
| 15 | 	if (w < 0x3f317217) { | ||
| 16 | 		if (w < 0x3f800000 - (12<<23)) { | ||
| 17 | 			FORCE_EVAL(x + 0x1p120f); | ||
| 18 | 			return 1; | ||
| 19 | 		} | ||
| 20 | 		t = expm1f(x); | ||
| 21 | 		return 1 + t*t/(2*(1+t)); | ||
| 22 | 	} | ||
| 23 | |||
| 24 | 	/* |x| < log(FLT_MAX) */ | ||
| 25 | 	if (w < 0x42b17217) { | ||
| 26 | 		t = expf(x); | ||
| 27 | 		return 0.5f*(t + 1/t); | ||
| 28 | 	} | ||
| 29 | |||
| 30 | 	/* |x| > log(FLT_MAX) or nan */ | ||
| 31 | #ifdef __wasilibc_unmodified_upstream // Wasm doesn't have alternate rounding modes | ||
| 32 | 	t = __expo2f(x, 1.0f); | ||
| 33 | #else | ||
| 34 | 	t = __expo2f(x); | ||
| 35 | #endif | ||
| 36 | 	return t; | ||
| 37 | } | ||
src/libs/mingw.zig-1| ... | @@ -977,7 +977,6 @@ const mingw32_x86_src = [_][]const u8{ | ... | @@ -977,7 +977,6 @@ const mingw32_x86_src = [_][]const u8{ |
| 977 | 977 | ||
| 978 | const mingw32_x86_32_src = [_][]const u8{ | 978 | const mingw32_x86_32_src = [_][]const u8{ |
| 979 | // ucrtbase | 979 | // ucrtbase |
| 980 | "math" ++ path.sep_str ++ "coshf.c", | ||
| 981 | "math" ++ path.sep_str ++ "modff.c", | 980 | "math" ++ path.sep_str ++ "modff.c", |
| 982 | "math" ++ path.sep_str ++ "powf.c", | 981 | "math" ++ path.sep_str ++ "powf.c", |
| 983 | "math" ++ path.sep_str ++ "sinhf.c", | 982 | "math" ++ path.sep_str ++ "sinhf.c", |
src/libs/musl.zig-1| ... | @@ -819,7 +819,6 @@ const src_files = [_][]const u8{ | ... | @@ -819,7 +819,6 @@ const src_files = [_][]const u8{ |
| 819 | "musl/src/math/cbrtl.c", | 819 | "musl/src/math/cbrtl.c", |
| 820 | "musl/src/math/__cos.c", | 820 | "musl/src/math/__cos.c", |
| 821 | "musl/src/math/__cosdf.c", | 821 | "musl/src/math/__cosdf.c", |
| 822 | "musl/src/math/coshf.c", | ||
| 823 | "musl/src/math/coshl.c", | 822 | "musl/src/math/coshl.c", |
| 824 | "musl/src/math/__cosl.c", | 823 | "musl/src/math/__cosl.c", |
| 825 | "musl/src/math/cosl.c", | 824 | "musl/src/math/cosl.c", |
src/libs/wasi_libc.zig-1| ... | @@ -1003,7 +1003,6 @@ const libc_top_half_src_files = [_][]const u8{ | ... | @@ -1003,7 +1003,6 @@ const libc_top_half_src_files = [_][]const u8{ |
| 1003 | "wasi/libc-top-half/musl/src/locale/locale_map.c", | 1003 | "wasi/libc-top-half/musl/src/locale/locale_map.c", |
| 1004 | "wasi/libc-top-half/musl/src/locale/newlocale.c", | 1004 | "wasi/libc-top-half/musl/src/locale/newlocale.c", |
| 1005 | "wasi/libc-top-half/musl/src/locale/uselocale.c", | 1005 | "wasi/libc-top-half/musl/src/locale/uselocale.c", |
| 1006 | "wasi/libc-top-half/musl/src/math/coshf.c", | ||
| 1007 | "wasi/libc-top-half/musl/src/math/__expo2.c", | 1006 | "wasi/libc-top-half/musl/src/math/__expo2.c", |
| 1008 | "wasi/libc-top-half/musl/src/math/__expo2f.c", | 1007 | "wasi/libc-top-half/musl/src/math/__expo2f.c", |
| 1009 | "wasi/libc-top-half/musl/src/math/fmal.c", | 1008 | "wasi/libc-top-half/musl/src/math/fmal.c", |