libzigc: round

This commit is contained in:
Jeff Anderson 2026-01-31 17:15:00 -08:00
parent e60ba21114
commit 69a95571ed
7 changed files with 1 additions and 78 deletions

View file

@ -1,7 +0,0 @@
#include <math.h>
double round(double x)
{
__asm__ ("frinta %d0, %d1" : "=w"(x) : "w"(x));
return x;
}

View file

@ -1,15 +0,0 @@
#include <math.h>
#ifdef _ARCH_PWR5X
double round(double x)
{
__asm__ ("frin %0, %1" : "=d"(x) : "d"(x));
return x;
}
#else
#include "../round.c"
#endif

View file

@ -1,35 +0,0 @@
#include "libm.h"
#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
static const double_t toint = 1/EPS;
double round(double x)
{
union {double f; uint64_t i;} u = {x};
int e = u.i >> 52 & 0x7ff;
double_t y;
if (e >= 0x3ff+52)
return x;
if (u.i >> 63)
x = -x;
if (e < 0x3ff-1) {
/* raise inexact if x!=0 */
FORCE_EVAL(x + toint);
return 0*u.f;
}
y = x + toint - toint - x;
if (y > 0.5)
y = y + x - 1;
else if (y <= -0.5)
y = y + x + 1;
else
y = y + x;
if (u.i >> 63)
y = -y;
return y;
}

View file

@ -1,15 +0,0 @@
#include <math.h>
#if defined(__HTM__) || __ARCH__ >= 9
double round(double x)
{
__asm__ ("fidbra %0, 1, %1, 4" : "=f"(x) : "f"(x));
return x;
}
#else
#include "../round.c"
#endif

View file

@ -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/round.c",
"musl/src/math/aarch64/roundf.c",
"musl/src/math/acosf.c",
"musl/src/math/acosh.c",
@ -997,7 +996,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/round.c",
"musl/src/math/powerpc64/roundf.c",
"musl/src/math/powerpc/fma.c",
"musl/src/math/powerpc/fmaf.c",
@ -1021,7 +1019,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/round.c",
"musl/src/math/roundf.c",
"musl/src/math/s390x/fma.c",
"musl/src/math/s390x/fmaf.c",
@ -1031,7 +1028,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/round.c",
"musl/src/math/s390x/roundf.c",
"musl/src/math/scalb.c",
"musl/src/math/scalbf.c",

View file

@ -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/round.c",
"musl/src/math/roundf.c",
"musl/src/math/scalb.c",
"musl/src/math/scalbf.c",

View file

@ -296,7 +296,7 @@ pub fn addCases(cases: *tests.LibcContext) void {
// cases.addLibcTestCase("math/rint.c", true, .{});
cases.addLibcTestCase("math/rintf.c", true, .{});
// cases.addLibcTestCase("math/rintl.c", true, .{});
// cases.addLibcTestCase("math/round.c", true, .{});
cases.addLibcTestCase("math/round.c", true, .{});
// cases.addLibcTestCase("math/roundf.c", true, .{});
cases.addLibcTestCase("math/roundl.c", true, .{});
cases.addLibcTestCase("math/scalb.c", true, .{});