diff --git a/lib/c/math.zig b/lib/c/math.zig index 0621b4af97..a03a9a6eea 100644 --- a/lib/c/math.zig +++ b/lib/c/math.zig @@ -72,6 +72,7 @@ comptime { symbol(&frexp, "frexp"); symbol(&hypot, "hypot"); symbol(&lrint, "lrint"); + symbol(&lrintf, "lrintf"); symbol(&modf, "modf"); symbol(&pow, "pow"); symbol(&pow10, "pow10"); @@ -238,6 +239,10 @@ fn lrint(x: f64) callconv(.c) c_long { return @intFromFloat(rint(x)); } +fn lrintf(x: f32) callconv(.c) c_long { + return @intFromFloat(rintf(x)); +} + fn modfGeneric(comptime T: type, x: T, iptr: *T) T { if (math.isNegativeInf(x)) { iptr.* = -math.inf(T); diff --git a/lib/libc/musl/src/math/aarch64/lrintf.c b/lib/libc/musl/src/math/aarch64/lrintf.c deleted file mode 100644 index 4d750d699d..0000000000 --- a/lib/libc/musl/src/math/aarch64/lrintf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -long lrintf(float x) -{ - long n; - __asm__ ( - "frintx %s1, %s1\n" - "fcvtzs %x0, %s1\n" : "=r"(n), "+w"(x)); - return n; -} diff --git a/lib/libc/musl/src/math/i386/lrintf.c b/lib/libc/musl/src/math/i386/lrintf.c deleted file mode 100644 index 0bbf29de06..0000000000 --- a/lib/libc/musl/src/math/i386/lrintf.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -long lrintf(float x) -{ - long r; - __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st"); - return r; -} diff --git a/lib/libc/musl/src/math/lrintf.c b/lib/libc/musl/src/math/lrintf.c deleted file mode 100644 index ca0b6a46aa..0000000000 --- a/lib/libc/musl/src/math/lrintf.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -/* uses LONG_MAX > 2^24, see comments in lrint.c */ - -long lrintf(float x) -{ - return rintf(x); -} diff --git a/lib/libc/musl/src/math/powerpc64/lrintf.c b/lib/libc/musl/src/math/powerpc64/lrintf.c deleted file mode 100644 index 9070fc03dc..0000000000 --- a/lib/libc/musl/src/math/powerpc64/lrintf.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#ifdef _ARCH_PWR5X - -long lrintf(float x) -{ - long n; - __asm__ ("fctid %0, %1" : "=d"(n) : "f"(x)); - return n; -} - -#else - -#include "../lrintf.c" - -#endif diff --git a/lib/libc/musl/src/math/x32/lrintf.s b/lib/libc/musl/src/math/x32/lrintf.s deleted file mode 100644 index 488423d217..0000000000 --- a/lib/libc/musl/src/math/x32/lrintf.s +++ /dev/null @@ -1,5 +0,0 @@ -.global lrintf -.type lrintf,@function -lrintf: - cvtss2si %xmm0,%rax - ret diff --git a/lib/libc/musl/src/math/x86_64/lrintf.c b/lib/libc/musl/src/math/x86_64/lrintf.c deleted file mode 100644 index 2ba5639dc2..0000000000 --- a/lib/libc/musl/src/math/x86_64/lrintf.c +++ /dev/null @@ -1,8 +0,0 @@ -#include - -long lrintf(float x) -{ - long r; - __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x)); - return r; -} diff --git a/src/libs/musl.zig b/src/libs/musl.zig index e325efd931..074f9e626e 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -787,7 +787,6 @@ const src_files = [_][]const u8{ "musl/src/math/aarch64/llrintf.c", "musl/src/math/aarch64/llround.c", "musl/src/math/aarch64/llroundf.c", - "musl/src/math/aarch64/lrintf.c", "musl/src/math/aarch64/lround.c", "musl/src/math/aarch64/lroundf.c", "musl/src/math/aarch64/nearbyint.c", @@ -858,7 +857,6 @@ const src_files = [_][]const u8{ "musl/src/math/i386/log1p.s", "musl/src/math/i386/log2l.s", "musl/src/math/i386/logl.s", - "musl/src/math/i386/lrintf.c", "musl/src/math/i386/lrintl.c", "musl/src/math/i386/remainder.c", "musl/src/math/i386/remainderf.c", @@ -906,7 +904,6 @@ const src_files = [_][]const u8{ "musl/src/math/logbf.c", "musl/src/math/logbl.c", "musl/src/math/logl.c", - "musl/src/math/lrintf.c", "musl/src/math/lrintl.c", "musl/src/math/lround.c", "musl/src/math/lroundf.c", @@ -935,7 +932,6 @@ const src_files = [_][]const u8{ "musl/src/math/pow_data.c", "musl/src/math/powerpc64/fma.c", "musl/src/math/powerpc64/fmaf.c", - "musl/src/math/powerpc64/lrintf.c", "musl/src/math/powerpc64/lround.c", "musl/src/math/powerpc64/lroundf.c", "musl/src/math/powerpc/fma.c", @@ -1007,7 +1003,6 @@ const src_files = [_][]const u8{ "musl/src/math/x32/log1pl.s", "musl/src/math/x32/log2l.s", "musl/src/math/x32/logl.s", - "musl/src/math/x32/lrintf.s", "musl/src/math/x32/lrintl.s", "musl/src/math/x32/remainderl.s", "musl/src/math/x32/rintl.s", @@ -1027,7 +1022,6 @@ const src_files = [_][]const u8{ "musl/src/math/x86_64/log1pl.s", "musl/src/math/x86_64/log2l.s", "musl/src/math/x86_64/logl.s", - "musl/src/math/x86_64/lrintf.c", "musl/src/math/x86_64/lrintl.c", "musl/src/math/x86_64/remainderl.c", "musl/src/math/x86_64/remquol.c", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig index 691deabd08..cae605d124 100644 --- a/src/libs/wasi_libc.zig +++ b/src/libs/wasi_libc.zig @@ -732,7 +732,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/logbf.c", "musl/src/math/logbl.c", "musl/src/math/logl.c", - "musl/src/math/lrintf.c", "musl/src/math/lrintl.c", "musl/src/math/lround.c", "musl/src/math/lroundf.c",