commit 379d128cba904a7599ebb191afa0873ef1a633cc (tree)
parent 69a95571ed6e0f2c4562b70dc222f427b3366858
Author: Jeff Anderson <kj4tmp@gmail.com>
Date: Sat, 31 Jan 2026 17:18:42 -0800
libzigc: roundf
Diffstat:
7 files changed, 1 insertion(+), 79 deletions(-)
diff --git a/lib/libc/musl/src/math/aarch64/roundf.c b/lib/libc/musl/src/math/aarch64/roundf.c
@@ -1,7 +0,0 @@
-#include <math.h>
-
-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
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#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
@@ -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
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#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
@@ -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
@@ -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
@@ -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, .{});