mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
libzigc/math: Implement lrintf
This was checked by running: ``` $ ./build/stage3/bin/zig build -p stage4 -Denable-llvm -Dno-lib $ stage4/bin/zig build test-libc -Dlibc-test-path=<LIBC-TEST-PATH> -Dtest-filter=lrintf -fqemu -fwasmtime --summary line Build Summary: 369/369 steps succeeded ```
This commit is contained in:
@@ -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);
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
long lrintf(float x)
|
||||
{
|
||||
long n;
|
||||
__asm__ (
|
||||
"frintx %s1, %s1\n"
|
||||
"fcvtzs %x0, %s1\n" : "=r"(n), "+w"(x));
|
||||
return n;
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
long lrintf(float x)
|
||||
{
|
||||
long r;
|
||||
__asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
|
||||
return r;
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
/* uses LONG_MAX > 2^24, see comments in lrint.c */
|
||||
|
||||
long lrintf(float x)
|
||||
{
|
||||
return rintf(x);
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _ARCH_PWR5X
|
||||
|
||||
long lrintf(float x)
|
||||
{
|
||||
long n;
|
||||
__asm__ ("fctid %0, %1" : "=d"(n) : "f"(x));
|
||||
return n;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "../lrintf.c"
|
||||
|
||||
#endif
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
.global lrintf
|
||||
.type lrintf,@function
|
||||
lrintf:
|
||||
cvtss2si %xmm0,%rax
|
||||
ret
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
#include <math.h>
|
||||
|
||||
long lrintf(float x)
|
||||
{
|
||||
long r;
|
||||
__asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x));
|
||||
return r;
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user