diff --git a/lib/c/math.zig b/lib/c/math.zig index 3520c63457355a23afa512d1d1291ce11f5660e5..15022cb4a6a39dae5f7ea1e365f9614f0260a5b5 100644 --- a/lib/c/math.zig +++ b/lib/c/math.zig @@ -43,6 +43,7 @@ comptime { symbol(&nan, "nan"); symbol(&nanf, "nanf"); symbol(&nanl, "nanl"); + symbol(&tanhf, "tanhf"); } if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { @@ -343,3 +344,7 @@ test "rint" { fn tanh(x: f64) callconv(.c) f64 { return math.tanh(x); } + +fn tanhf(x: f32) callconv(.c) f32 { + return math.tanh(x); +} diff --git a/lib/libc/mingw/math/tanhf.c b/lib/libc/mingw/math/tanhf.c deleted file mode 100644 index cb6f4c75a4c53434586346a5cb88db5cdc24e90b..0000000000000000000000000000000000000000 --- a/lib/libc/mingw/math/tanhf.c +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ -#include -float tanhf (float x) -{ - return (float) tanh (x); -} diff --git a/lib/libc/musl/src/math/tanhf.c b/lib/libc/musl/src/math/tanhf.c deleted file mode 100644 index 10636fbd7be6c21d1c58326eba2bf7179b0dea8f..0000000000000000000000000000000000000000 --- a/lib/libc/musl/src/math/tanhf.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "libm.h" - -float tanhf(float x) -{ - union {float f; uint32_t i;} u = {.f = x}; - uint32_t w; - int sign; - float t; - - /* x = |x| */ - sign = u.i >> 31; - u.i &= 0x7fffffff; - x = u.f; - w = u.i; - - if (w > 0x3f0c9f54) { - /* |x| > log(3)/2 ~= 0.5493 or nan */ - if (w > 0x41200000) { - /* |x| > 10 */ - t = 1 + 0/x; - } else { - t = expm1f(2*x); - t = 1 - 2/(t+2); - } - } else if (w > 0x3e82c578) { - /* |x| > log(5/3)/2 ~= 0.2554 */ - t = expm1f(2*x); - t = t/(t+2); - } else if (w >= 0x00800000) { - /* |x| >= 0x1p-126 */ - t = expm1f(-2*x); - t = -t/(t+2); - } else { - /* |x| is subnormal */ - FORCE_EVAL(x*x); - t = x; - } - return sign ? -t : t; -} diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index 312a9a1e261f5086b4a312ab7ae8a9409f5d241a..07e67ea468f859f174c390158f9ee141a4f52062 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -978,7 +978,6 @@ const mingw32_x86_32_src = [_][]const u8{ // ucrtbase "math" ++ path.sep_str ++ "powf.c", "math" ++ path.sep_str ++ "sinhf.c", - "math" ++ path.sep_str ++ "tanhf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c", diff --git a/src/libs/musl.zig b/src/libs/musl.zig index 4e5408beca3a713bdccda42d7b6c33d1b8d65336..b96ffbf18a324457960f821e0814a7f9bf372113 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -1003,7 +1003,6 @@ const src_files = [_][]const u8{ "musl/src/math/sinl.c", "musl/src/math/__tan.c", "musl/src/math/__tandf.c", - "musl/src/math/tanhf.c", "musl/src/math/tanhl.c", "musl/src/math/__tanl.c", "musl/src/math/tanl.c", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig index 1d35b0bf19ed74838b85486723fff05ddeac8814..de7cabd542d5841c24344a33ae532fadd2c5cb2d 100644 --- a/src/libs/wasi_libc.zig +++ b/src/libs/wasi_libc.zig @@ -793,7 +793,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/sinl.c", "musl/src/math/__tan.c", "musl/src/math/__tandf.c", - "musl/src/math/tanhf.c", "musl/src/math/tanhl.c", "musl/src/math/__tanl.c", "musl/src/math/tanl.c",