authorgravatar for seda18@rolmail.netDavid Senoner <seda18@rolmail.net> 2025-08-27 21:53:16+02:00
committergravatar for seda18@rolmail.netDavid Senoner <seda18@rolmail.net> 2025-08-28 20:09:07+02:00
log70e22d79a4d7aedcc76a00f123837d387545c3c6
treeb01caace5dd72d3db8848d42e1e38035d4869260
parentf707de15a14e4400e99d5260d6d7af98aa2a69cd

libc: delete superfluous c and assembly trunc implementations


22 files changed, 0 insertions(+), 276 deletions(-)

lib/libc/mingw/math/truncl.c deleted-25
......@@ -1,25 +0,0 @@
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7#include <math.h>
8
9long double
10truncl (long double _x)
11{
12#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
13 return trunc(_x);
14#else
15 long double retval = 0.0L;
16 unsigned short saved_cw;
17 unsigned short tmp_cw;
18 __asm__ __volatile__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
19 tmp_cw = saved_cw | 0xc00; /* round towards zero */
20 __asm__ __volatile__ ("fldcw %0;" : : "m" (tmp_cw));
21 __asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
22 __asm__ __volatile__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
23 return retval;
24#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
25}
lib/libc/musl/src/math/aarch64/trunc.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3double trunc(double x)
4{
5 __asm__ ("frintz %d0, %d1" : "=w"(x) : "w"(x));
6 return x;
7}
lib/libc/musl/src/math/aarch64/truncf.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3float truncf(float x)
4{
5 __asm__ ("frintz %s0, %s1" : "=w"(x) : "w"(x));
6 return x;
7}
lib/libc/musl/src/math/i386/floor.s deleted-31
......@@ -1,31 +0,0 @@
1/* zig patch: removed `floorl`, `floorf`, `ceil`, `ceilf` and `ceill` in favor of using zig compiler_rt's implementations */
2
31: fstcw 4(%esp)
4 mov 5(%esp),%ah
5 mov %al,5(%esp)
6 fldcw 4(%esp)
7 frndint
8 mov %ah,5(%esp)
9 fldcw 4(%esp)
10 ret
11
12.global trunc
13.type trunc,@function
14trunc:
15 fldl 4(%esp)
16 mov $0xf,%al
17 jmp 1b
18
19.global truncf
20.type truncf,@function
21truncf:
22 flds 4(%esp)
23 mov $0xf,%al
24 jmp 1b
25
26.global truncl
27.type truncl,@function
28truncl:
29 fldt 4(%esp)
30 mov $0xf,%al
31 jmp 1b
lib/libc/musl/src/math/i386/trunc.s deleted-1
......@@ -1 +0,0 @@
1# see floor.s
lib/libc/musl/src/math/i386/truncf.s deleted-1
......@@ -1 +0,0 @@
1# see floor.s
lib/libc/musl/src/math/i386/truncl.s deleted-1
......@@ -1 +0,0 @@
1# see floor.s
lib/libc/musl/src/math/powerpc64/trunc.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef _ARCH_PWR5X
4
5double trunc(double x)
6{
7 __asm__ ("friz %0, %1" : "=d"(x) : "d"(x));
8 return x;
9}
10
11#else
12
13#include "../trunc.c"
14
15#endif
lib/libc/musl/src/math/powerpc64/truncf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef _ARCH_PWR5X
4
5float truncf(float x)
6{
7 __asm__ ("friz %0, %1" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../truncf.c"
14
15#endif
lib/libc/musl/src/math/s390x/trunc.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5double trunc(double x)
6{
7 __asm__ ("fidbra %0, 5, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../trunc.c"
14
15#endif
lib/libc/musl/src/math/s390x/truncf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5float truncf(float x)
6{
7 __asm__ ("fiebra %0, 5, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../truncf.c"
14
15#endif
lib/libc/musl/src/math/s390x/truncl.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5long double truncl(long double x)
6{
7 __asm__ ("fixbra %0, 5, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../truncl.c"
14
15#endif
lib/libc/musl/src/math/trunc.c deleted-19
......@@ -1,19 +0,0 @@
1#include "libm.h"
2
3double trunc(double x)
4{
5 union {double f; uint64_t i;} u = {x};
6 int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12;
7 uint64_t m;
8
9 if (e >= 52 + 12)
10 return x;
11 if (e < 12)
12 e = 1;
13 m = -1ULL >> e;
14 if ((u.i & m) == 0)
15 return x;
16 FORCE_EVAL(x + 0x1p120f);
17 u.i &= ~m;
18 return u.f;
19}
lib/libc/musl/src/math/truncf.c deleted-19
......@@ -1,19 +0,0 @@
1#include "libm.h"
2
3float truncf(float x)
4{
5 union {float f; uint32_t i;} u = {x};
6 int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9;
7 uint32_t m;
8
9 if (e >= 23 + 9)
10 return x;
11 if (e < 9)
12 e = 1;
13 m = -1U >> e;
14 if ((u.i & m) == 0)
15 return x;
16 FORCE_EVAL(x + 0x1p120f);
17 u.i &= ~m;
18 return u.f;
19}
lib/libc/musl/src/math/truncl.c deleted-34
......@@ -1,34 +0,0 @@
1#include "libm.h"
2
3#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4long double truncl(long double x)
5{
6 return trunc(x);
7}
8#elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
9
10static const long double toint = 1/LDBL_EPSILON;
11
12long double truncl(long double x)
13{
14 union ldshape u = {x};
15 int e = u.i.se & 0x7fff;
16 int s = u.i.se >> 15;
17 long double y;
18
19 if (e >= 0x3fff+LDBL_MANT_DIG-1)
20 return x;
21 if (e <= 0x3fff-1) {
22 FORCE_EVAL(x + 0x1p120f);
23 return x*0;
24 }
25 /* y = int(|x|) - |x|, where int(|x|) is an integer neighbor of |x| */
26 if (s)
27 x = -x;
28 y = x + toint - toint - x;
29 if (y > 0)
30 y -= 1;
31 x += y;
32 return s ? -x : x;
33}
34#endif
lib/libc/musl/src/math/x32/floorl.s deleted-17
......@@ -1,17 +0,0 @@
1/* zig patch: removed `floorl` and `ceill` in favor of using zig compiler_rt's implementations */
2
31: fstcw 8(%esp)
4 mov 9(%esp),%ah
5 mov %al,9(%esp)
6 fldcw 8(%esp)
7 frndint
8 mov %ah,9(%esp)
9 fldcw 8(%esp)
10 ret
11
12.global truncl
13.type truncl,@function
14truncl:
15 fldt 8(%esp)
16 mov $0xf,%al
17 jmp 1b
lib/libc/musl/src/math/x32/truncl.s deleted-1
......@@ -1 +0,0 @@
1# see floorl.s
lib/libc/musl/src/math/x86_64/floorl.s deleted-17
......@@ -1,17 +0,0 @@
1/* zig patch: removed `floorl` and `ceill` in favor of using zig compiler_rt's implementations */
2
31: fstcw 8(%rsp)
4 mov 9(%rsp),%ah
5 mov %al,9(%rsp)
6 fldcw 8(%rsp)
7 frndint
8 mov %ah,9(%rsp)
9 fldcw 8(%rsp)
10 ret
11
12.global truncl
13.type truncl,@function
14truncl:
15 fldt 8(%rsp)
16 mov $0xf,%al
17 jmp 1b
lib/libc/musl/src/math/x86_64/truncl.s deleted-1
......@@ -1 +0,0 @@
1# see floorl.s
src/libs/mingw.zig-1
......@@ -911,7 +911,6 @@ const mingw32_x86_src = [_][]const u8{
911911 "math" ++ path.sep_str ++ "rintl.c",
912912 "math" ++ path.sep_str ++ "roundl.c",
913913 "math" ++ path.sep_str ++ "tgammal.c",
914 "math" ++ path.sep_str ++ "truncl.c",
915914 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "_chgsignl.S",
916915 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acoshl.c",
917916 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "acosl.c",
src/libs/musl.zig-18
......@@ -853,8 +853,6 @@ const src_files = [_][]const u8{
853853 "musl/src/math/aarch64/roundf.c",
854854 "musl/src/math/aarch64/sqrt.c",
855855 "musl/src/math/aarch64/sqrtf.c",
856 "musl/src/math/aarch64/trunc.c",
857 "musl/src/math/aarch64/truncf.c",
858856 "musl/src/math/acos.c",
859857 "musl/src/math/acosf.c",
860858 "musl/src/math/acosh.c",
......@@ -954,7 +952,6 @@ const src_files = [_][]const u8{
954952 "musl/src/math/i386/exp_ld.s",
955953 "musl/src/math/i386/expl.s",
956954 "musl/src/math/i386/expm1l.s",
957 "musl/src/math/i386/floor.s",
958955 "musl/src/math/i386/fmod.c",
959956 "musl/src/math/i386/fmodf.c",
960957 "musl/src/math/i386/fmodl.c",
......@@ -1000,9 +997,6 @@ const src_files = [_][]const u8{
1000997 "musl/src/math/i386/sqrt.c",
1001998 "musl/src/math/i386/sqrtf.c",
1002999 "musl/src/math/i386/sqrtl.c",
1003 "musl/src/math/i386/truncf.s",
1004 "musl/src/math/i386/truncl.s",
1005 "musl/src/math/i386/trunc.s",
10061000 "musl/src/math/ilogb.c",
10071001 "musl/src/math/ilogbf.c",
10081002 "musl/src/math/ilogbl.c",
......@@ -1098,8 +1092,6 @@ const src_files = [_][]const u8{
10981092 "musl/src/math/powerpc64/roundf.c",
10991093 "musl/src/math/powerpc64/sqrt.c",
11001094 "musl/src/math/powerpc64/sqrtf.c",
1101 "musl/src/math/powerpc64/trunc.c",
1102 "musl/src/math/powerpc64/truncf.c",
11031095 "musl/src/math/powerpc/fma.c",
11041096 "musl/src/math/powerpc/fmaf.c",
11051097 "musl/src/math/powerpc/sqrt.c",
......@@ -1157,9 +1149,6 @@ const src_files = [_][]const u8{
11571149 "musl/src/math/s390x/sqrt.c",
11581150 "musl/src/math/s390x/sqrtf.c",
11591151 "musl/src/math/s390x/sqrtl.c",
1160 "musl/src/math/s390x/trunc.c",
1161 "musl/src/math/s390x/truncf.c",
1162 "musl/src/math/s390x/truncl.c",
11631152 "musl/src/math/scalb.c",
11641153 "musl/src/math/scalbf.c",
11651154 "musl/src/math/scalbln.c",
......@@ -1196,9 +1185,6 @@ const src_files = [_][]const u8{
11961185 "musl/src/math/tgamma.c",
11971186 "musl/src/math/tgammaf.c",
11981187 "musl/src/math/tgammal.c",
1199 "musl/src/math/trunc.c",
1200 "musl/src/math/truncf.c",
1201 "musl/src/math/truncl.c",
12021188 "musl/src/math/x32/acosl.s",
12031189 "musl/src/math/x32/asinl.s",
12041190 "musl/src/math/x32/atan2l.s",
......@@ -1206,7 +1192,6 @@ const src_files = [_][]const u8{
12061192 "musl/src/math/x32/exp2l.s",
12071193 "musl/src/math/x32/expl.s",
12081194 "musl/src/math/x32/expm1l.s",
1209 "musl/src/math/x32/floorl.s",
12101195 "musl/src/math/x32/fma.c",
12111196 "musl/src/math/x32/fmaf.c",
12121197 "musl/src/math/x32/fmodl.s",
......@@ -1226,7 +1211,6 @@ const src_files = [_][]const u8{
12261211 "musl/src/math/x32/sqrtf.s",
12271212 "musl/src/math/x32/sqrtl.s",
12281213 "musl/src/math/x32/sqrt.s",
1229 "musl/src/math/x32/truncl.s",
12301214 "musl/src/math/x86_64/acosl.s",
12311215 "musl/src/math/x86_64/asinl.s",
12321216 "musl/src/math/x86_64/atan2l.s",
......@@ -1234,7 +1218,6 @@ const src_files = [_][]const u8{
12341218 "musl/src/math/x86_64/exp2l.s",
12351219 "musl/src/math/x86_64/expl.s",
12361220 "musl/src/math/x86_64/expm1l.s",
1237 "musl/src/math/x86_64/floorl.s",
12381221 "musl/src/math/x86_64/fma.c",
12391222 "musl/src/math/x86_64/fmaf.c",
12401223 "musl/src/math/x86_64/fmodl.c",
......@@ -1255,7 +1238,6 @@ const src_files = [_][]const u8{
12551238 "musl/src/math/x86_64/sqrt.c",
12561239 "musl/src/math/x86_64/sqrtf.c",
12571240 "musl/src/math/x86_64/sqrtl.c",
1258 "musl/src/math/x86_64/truncl.s",
12591241 "musl/src/misc/a64l.c",
12601242 "musl/src/misc/basename.c",
12611243 "musl/src/misc/dirname.c",
src/libs/wasi_libc.zig-1
......@@ -886,7 +886,6 @@ const libc_top_half_src_files = [_][]const u8{
886886 "musl/src/math/tgamma.c",
887887 "musl/src/math/tgammaf.c",
888888 "musl/src/math/tgammal.c",
889 "musl/src/math/truncl.c",
890889 "musl/src/misc/a64l.c",
891890 "musl/src/misc/basename.c",
892891 "musl/src/misc/dirname.c",