authorgravatar for kj4tmp@gmail.comkj4tmp <kj4tmp@gmail.com> 2026-01-31 17:15:00-08:00
committergravatar for kj4tmp@gmail.comkj4tmp <kj4tmp@gmail.com> 2026-01-31 17:26:17-08:00
log69a95571ed6e0f2c4562b70dc222f427b3366858
tree05e8e0ec5af7b9f3ef5ef0f3f79adadac99784f8
parente60ba21114bc4514acc535be7106ce6c16e9bf04

libzigc: round


7 files changed, 1 insertions(+), 78 deletions(-)

lib/libc/musl/src/math/aarch64/round.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3double round(double x)
4{
5 __asm__ ("frinta %d0, %d1" : "=w"(x) : "w"(x));
6 return x;
7}
lib/libc/musl/src/math/powerpc64/round.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef _ARCH_PWR5X
4
5double round(double x)
6{
7 __asm__ ("frin %0, %1" : "=d"(x) : "d"(x));
8 return x;
9}
10
11#else
12
13#include "../round.c"
14
15#endif
lib/libc/musl/src/math/round.c deleted-35
......@@ -1,35 +0,0 @@
1#include "libm.h"
2
3#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
4#define EPS DBL_EPSILON
5#elif FLT_EVAL_METHOD==2
6#define EPS LDBL_EPSILON
7#endif
8static const double_t toint = 1/EPS;
9
10double round(double x)
11{
12 union {double f; uint64_t i;} u = {x};
13 int e = u.i >> 52 & 0x7ff;
14 double_t y;
15
16 if (e >= 0x3ff+52)
17 return x;
18 if (u.i >> 63)
19 x = -x;
20 if (e < 0x3ff-1) {
21 /* raise inexact if x!=0 */
22 FORCE_EVAL(x + toint);
23 return 0*u.f;
24 }
25 y = x + toint - toint - x;
26 if (y > 0.5)
27 y = y + x - 1;
28 else if (y <= -0.5)
29 y = y + x + 1;
30 else
31 y = y + x;
32 if (u.i >> 63)
33 y = -y;
34 return y;
35}
lib/libc/musl/src/math/s390x/round.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5double round(double x)
6{
7 __asm__ ("fidbra %0, 1, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../round.c"
14
15#endif
src/libs/musl.zig-4
......@@ -818,7 +818,6 @@ const src_files = [_][]const u8{
818818 "musl/src/math/aarch64/nearbyintf.c",
819819 "musl/src/math/aarch64/rint.c",
820820 "musl/src/math/aarch64/rintf.c",
821 "musl/src/math/aarch64/round.c",
822821 "musl/src/math/aarch64/roundf.c",
823822 "musl/src/math/acosf.c",
824823 "musl/src/math/acosh.c",
......@@ -997,7 +996,6 @@ const src_files = [_][]const u8{
997996 "musl/src/math/powerpc64/lrintf.c",
998997 "musl/src/math/powerpc64/lround.c",
999998 "musl/src/math/powerpc64/lroundf.c",
1000 "musl/src/math/powerpc64/round.c",
1001999 "musl/src/math/powerpc64/roundf.c",
10021000 "musl/src/math/powerpc/fma.c",
10031001 "musl/src/math/powerpc/fmaf.c",
......@@ -1021,7 +1019,6 @@ const src_files = [_][]const u8{
10211019 "musl/src/math/riscv32/fmaf.c",
10221020 "musl/src/math/riscv64/fma.c",
10231021 "musl/src/math/riscv64/fmaf.c",
1024 "musl/src/math/round.c",
10251022 "musl/src/math/roundf.c",
10261023 "musl/src/math/s390x/fma.c",
10271024 "musl/src/math/s390x/fmaf.c",
......@@ -1031,7 +1028,6 @@ const src_files = [_][]const u8{
10311028 "musl/src/math/s390x/rint.c",
10321029 "musl/src/math/s390x/rintf.c",
10331030 "musl/src/math/s390x/rintl.c",
1034 "musl/src/math/s390x/round.c",
10351031 "musl/src/math/s390x/roundf.c",
10361032 "musl/src/math/scalb.c",
10371033 "musl/src/math/scalbf.c",
src/libs/wasi_libc.zig-1
......@@ -808,7 +808,6 @@ const libc_top_half_src_files = [_][]const u8{
808808 "musl/src/math/remquof.c",
809809 "musl/src/math/remquol.c",
810810 "musl/src/math/rintl.c",
811 "musl/src/math/round.c",
812811 "musl/src/math/roundf.c",
813812 "musl/src/math/scalb.c",
814813 "musl/src/math/scalbf.c",
test/libc.zig+1-1
......@@ -296,7 +296,7 @@ pub fn addCases(cases: *tests.LibcContext) void {
296296 // cases.addLibcTestCase("math/rint.c", true, .{});
297297 cases.addLibcTestCase("math/rintf.c", true, .{});
298298 // cases.addLibcTestCase("math/rintl.c", true, .{});
299 // cases.addLibcTestCase("math/round.c", true, .{});
299 cases.addLibcTestCase("math/round.c", true, .{});
300300 // cases.addLibcTestCase("math/roundf.c", true, .{});
301301 cases.addLibcTestCase("math/roundl.c", true, .{});
302302 cases.addLibcTestCase("math/scalb.c", true, .{});