From 379d128cba904a7599ebb191afa0873ef1a633cc Mon Sep 17 00:00:00 2001 From: Jeff Anderson Date: Sat, 31 Jan 2026 17:18:42 -0800 Subject: [PATCH] libzigc: roundf --- lib/libc/musl/src/math/aarch64/roundf.c | 7 ----- lib/libc/musl/src/math/powerpc64/roundf.c | 15 ---------- lib/libc/musl/src/math/roundf.c | 36 ----------------------- lib/libc/musl/src/math/s390x/roundf.c | 15 ---------- src/libs/musl.zig | 4 --- src/libs/wasi_libc.zig | 1 - test/libc.zig | 2 +- 7 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 lib/libc/musl/src/math/aarch64/roundf.c delete mode 100644 lib/libc/musl/src/math/powerpc64/roundf.c delete mode 100644 lib/libc/musl/src/math/roundf.c delete mode 100644 lib/libc/musl/src/math/s390x/roundf.c diff --git a/lib/libc/musl/src/math/aarch64/roundf.c b/lib/libc/musl/src/math/aarch64/roundf.c deleted file mode 100644 index 91637eaa12..0000000000 --- a/lib/libc/musl/src/math/aarch64/roundf.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -float roundf(float x) -{ - __asm__ ("frinta %s0, %s1" : "=w"(x) : "w"(x)); - return x; -} diff --git a/lib/libc/musl/src/math/powerpc64/roundf.c b/lib/libc/musl/src/math/powerpc64/roundf.c deleted file mode 100644 index ae93f999ab..0000000000 --- a/lib/libc/musl/src/math/powerpc64/roundf.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#ifdef _ARCH_PWR5X - -float roundf(float x) -{ - __asm__ ("frin %0, %1" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../roundf.c" - -#endif diff --git a/lib/libc/musl/src/math/roundf.c b/lib/libc/musl/src/math/roundf.c deleted file mode 100644 index e8210af562..0000000000 --- a/lib/libc/musl/src/math/roundf.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "libm.h" - -#if FLT_EVAL_METHOD==0 -#define EPS FLT_EPSILON -#elif FLT_EVAL_METHOD==1 -#define EPS DBL_EPSILON -#elif FLT_EVAL_METHOD==2 -#define EPS LDBL_EPSILON -#endif -static const float_t toint = 1/EPS; - -float roundf(float x) -{ - union {float f; uint32_t i;} u = {x}; - int e = u.i >> 23 & 0xff; - float_t y; - - if (e >= 0x7f+23) - return x; - if (u.i >> 31) - x = -x; - if (e < 0x7f-1) { - FORCE_EVAL(x + toint); - return 0*u.f; - } - y = x + toint - toint - x; - if (y > 0.5f) - y = y + x - 1; - else if (y <= -0.5f) - y = y + x + 1; - else - y = y + x; - if (u.i >> 31) - y = -y; - return y; -} diff --git a/lib/libc/musl/src/math/s390x/roundf.c b/lib/libc/musl/src/math/s390x/roundf.c deleted file mode 100644 index 46d2e10c87..0000000000 --- a/lib/libc/musl/src/math/s390x/roundf.c +++ /dev/null @@ -1,15 +0,0 @@ -#include - -#if defined(__HTM__) || __ARCH__ >= 9 - -float roundf(float x) -{ - __asm__ ("fiebra %0, 1, %1, 4" : "=f"(x) : "f"(x)); - return x; -} - -#else - -#include "../roundf.c" - -#endif diff --git a/src/libs/musl.zig b/src/libs/musl.zig index 97f1d4e2f0..b8f7068e5c 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -818,7 +818,6 @@ const src_files = [_][]const u8{ "musl/src/math/aarch64/nearbyintf.c", "musl/src/math/aarch64/rint.c", "musl/src/math/aarch64/rintf.c", - "musl/src/math/aarch64/roundf.c", "musl/src/math/acosf.c", "musl/src/math/acosh.c", "musl/src/math/acoshf.c", @@ -996,7 +995,6 @@ const src_files = [_][]const u8{ "musl/src/math/powerpc64/lrintf.c", "musl/src/math/powerpc64/lround.c", "musl/src/math/powerpc64/lroundf.c", - "musl/src/math/powerpc64/roundf.c", "musl/src/math/powerpc/fma.c", "musl/src/math/powerpc/fmaf.c", "musl/src/math/powf.c", @@ -1019,7 +1017,6 @@ const src_files = [_][]const u8{ "musl/src/math/riscv32/fmaf.c", "musl/src/math/riscv64/fma.c", "musl/src/math/riscv64/fmaf.c", - "musl/src/math/roundf.c", "musl/src/math/s390x/fma.c", "musl/src/math/s390x/fmaf.c", "musl/src/math/s390x/nearbyint.c", @@ -1028,7 +1025,6 @@ const src_files = [_][]const u8{ "musl/src/math/s390x/rint.c", "musl/src/math/s390x/rintf.c", "musl/src/math/s390x/rintl.c", - "musl/src/math/s390x/roundf.c", "musl/src/math/scalb.c", "musl/src/math/scalbf.c", "musl/src/math/scalbln.c", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig index 743812e93c..239f8b4777 100644 --- a/src/libs/wasi_libc.zig +++ b/src/libs/wasi_libc.zig @@ -808,7 +808,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/remquof.c", "musl/src/math/remquol.c", "musl/src/math/rintl.c", - "musl/src/math/roundf.c", "musl/src/math/scalb.c", "musl/src/math/scalbf.c", "musl/src/math/scalbln.c", diff --git a/test/libc.zig b/test/libc.zig index cf61d1ba4d..57581ca32e 100644 --- a/test/libc.zig +++ b/test/libc.zig @@ -297,7 +297,7 @@ pub fn addCases(cases: *tests.LibcContext) void { cases.addLibcTestCase("math/rintf.c", true, .{}); // cases.addLibcTestCase("math/rintl.c", true, .{}); cases.addLibcTestCase("math/round.c", true, .{}); - // cases.addLibcTestCase("math/roundf.c", true, .{}); + cases.addLibcTestCase("math/roundf.c", true, .{}); cases.addLibcTestCase("math/roundl.c", true, .{}); cases.addLibcTestCase("math/scalb.c", true, .{}); cases.addLibcTestCase("math/scalbf.c", true, .{});