authorgravatar for seda18@rolmail.netDavid Senoner <seda18@rolmail.net> 2025-08-27 13:40:16+02:00
committergravatar for seda18@rolmail.netDavid Senoner <seda18@rolmail.net> 2025-08-28 07:33:50+02:00
logf707de15a14e4400e99d5260d6d7af98aa2a69cd
treedb40dc68d6a3a962fb70fb4df044374ba4b54540
parentf6b0d64ddc2132d3a08f216011480be6cb959234

libc: delete superfluous c and assembly ceil implementation


23 files changed, 3 insertions(+), 408 deletions(-)

lib/libc/mingw/math/x86/ceilf.S deleted-111
...@@ -1,111 +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#include <_mingw_mac.h>
7
8 .file "ceilf.S"
9 .text
10 .align 4
11 .globl __MINGW_USYMBOL(ceilf)
12 .def __MINGW_USYMBOL(ceilf); .scl 2; .type 32; .endef
13#ifdef __x86_64__
14 .seh_proc __MINGW_USYMBOL(ceilf)
15#endif
16
17__MINGW_USYMBOL(ceilf):
18#if defined(_AMD64_) || defined(__x86_64__)
19 subq $24, %rsp
20 .seh_stackalloc 24
21 .seh_endprologue
22 movd %xmm0, 12(%rsp)
23 movl 12(%rsp), %eax
24 movl %eax, %ecx
25 movl %eax, %edx
26 sarl $23, %ecx
27 andl $255, %ecx
28 subl $127, %ecx
29 cmpl $22, %ecx
30 jg .l4
31 testl %ecx, %ecx
32 js .l5
33 movl $8388607, %r8d
34 sarl %cl, %r8d
35 testl %eax, %r8d
36 je .l3
37 addss .hugeval(%rip), %xmm0
38 ucomiss .zeroval(%rip), %xmm0
39 jbe .l2
40 testl %eax, %eax
41 jle .l1
42 movl $8388608, %eax
43 sarl %cl, %eax
44 addl %eax, %edx
45.l1:
46 movl %r8d, %eax
47 notl %eax
48 andl %edx, %eax
49.l2:
50 movl %eax, 8(%rsp)
51 movss 8(%rsp), %xmm0
52.l3:
53 addq $24, %rsp
54 ret
55 .p2align 4,,10
56.l4:
57 addl $-128, %ecx
58 jne .l3
59 addss %xmm0, %xmm0
60 addq $24, %rsp
61 ret
62 .p2align 4,,10
63.l5:
64 addss .hugeval(%rip), %xmm0
65 ucomiss .zeroval(%rip), %xmm0
66 jbe .islesseqzero
67 testl %eax, %eax
68 js .l6
69 movl $1065353216, %edx
70 cmovne %edx, %eax
71.islesseqzero:
72 movl %eax, 8(%rsp)
73 movss 8(%rsp), %xmm0
74 addq $24, %rsp
75 ret
76 .p2align 4,,10
77.l6:
78 movl $-2147483648, 8(%rsp)
79 movss 8(%rsp), %xmm0
80 addq $24, %rsp
81 ret
82 .seh_endproc
83 .section .rdata,"dr"
84 .align 4
85.hugeval:
86 .long 1900671690
87 .align 4
88.zeroval:
89 .long 0
90#elif defined(_X86_) || defined(__i386__)
91 flds 4(%esp)
92 subl $8,%esp
93
94 fstcw 4(%esp) /* store fpu control word */
95
96 /* We use here %edx although only the low 1 bits are defined.
97 But none of the operations should care and they are faster
98 than the 16 bit operations. */
99 movl $0x0800,%edx /* round towards +oo */
100 orl 4(%esp),%edx
101 andl $0xfbff,%edx
102 movl %edx,(%esp)
103 fldcw (%esp) /* load modified control word */
104
105 frndint /* round */
106
107 fldcw 4(%esp) /* restore original control word */
108
109 addl $8,%esp
110 ret
111#endif
lib/libc/mingw/math/x86/ceill.S deleted-55
...@@ -1,55 +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#include <_mingw_mac.h>
7
8 .file "ceill.S"
9 .text
10#ifdef __x86_64__
11 .align 8
12#else
13 .align 4
14#endif
15 .globl __MINGW_USYMBOL(ceill)
16 .def __MINGW_USYMBOL(ceill); .scl 2; .type 32; .endef
17__MINGW_USYMBOL(ceill):
18#if defined(_AMD64_) || defined(__x86_64__)
19 fldt (%rdx)
20 subq $24,%rsp
21
22 fstcw 8(%rsp) /* store fpu control word */
23
24 /* We use here %edx although only the low 1 bits are defined.
25 But none of the operations should care and they are faster
26 than the 16 bit operations. */
27 movl $0x0800,%edx /* round towards +oo */
28 orl 8(%rsp),%edx
29 andl $0xfbff,%edx
30 movl %edx,(%rsp)
31 fldcw (%rsp) /* load modified control word */
32
33 frndint /* round */
34
35 fldcw 8(%rsp) /* restore original control word */
36
37 addq $24,%rsp
38 movq %rcx,%rax
39 movq $0,8(%rcx)
40 fstpt (%rcx)
41 ret
42#elif defined(_X86_) || defined(__i386__)
43 fldt 4(%esp)
44 subl $8,%esp
45 fstcw 4(%esp)
46 movl $0x0800,%edx
47 orl 4(%esp),%edx
48 andl $0xfbff,%edx
49 movl %edx,(%esp)
50 fldcw (%esp)
51 frndint
52 fldcw 4(%esp)
53 addl $8,%esp
54 ret
55#endif
lib/libc/musl/src/math/aarch64/ceil.c deleted-7
...@@ -1,7 +0,0 @@
1#include <math.h>
2
3double ceil(double x)
4{
5 __asm__ ("frintp %d0, %d1" : "=w"(x) : "w"(x));
6 return x;
7}
lib/libc/musl/src/math/aarch64/ceilf.c deleted-7
...@@ -1,7 +0,0 @@
1#include <math.h>
2
3float ceilf(float x)
4{
5 __asm__ ("frintp %s0, %s1" : "=w"(x) : "w"(x));
6 return x;
7}
lib/libc/musl/src/math/ceil.c deleted-31
...@@ -1,31 +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 ceil(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 || x == 0)
17 return x;
18 /* y = int(x) - x, where int(x) is an integer neighbor of x */
19 if (u.i >> 63)
20 y = x - toint + toint - x;
21 else
22 y = x + toint - toint - x;
23 /* special case because of non-nearest rounding modes */
24 if (e <= 0x3ff-1) {
25 FORCE_EVAL(y);
26 return u.i >> 63 ? -0.0 : 1;
27 }
28 if (y < 0)
29 return x + y + 1;
30 return x + y;
31}
lib/libc/musl/src/math/ceilf.c deleted-27
...@@ -1,27 +0,0 @@
1#include "libm.h"
2
3float ceilf(float x)
4{
5 union {float f; uint32_t i;} u = {x};
6 int e = (int)(u.i >> 23 & 0xff) - 0x7f;
7 uint32_t m;
8
9 if (e >= 23)
10 return x;
11 if (e >= 0) {
12 m = 0x007fffff >> e;
13 if ((u.i & m) == 0)
14 return x;
15 FORCE_EVAL(x + 0x1p120f);
16 if (u.i >> 31 == 0)
17 u.i += m;
18 u.i &= ~m;
19 } else {
20 FORCE_EVAL(x + 0x1p120f);
21 if (u.i >> 31)
22 u.f = -0.0;
23 else if (u.i << 1)
24 u.f = 1.0;
25 }
26 return u.f;
27}
lib/libc/musl/src/math/ceill.c deleted-34
...@@ -1,34 +0,0 @@
1#include "libm.h"
2
3#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
4long double ceill(long double x)
5{
6 return ceil(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 ceill(long double x)
13{
14 union ldshape u = {x};
15 int e = u.i.se & 0x7fff;
16 long double y;
17
18 if (e >= 0x3fff+LDBL_MANT_DIG-1 || x == 0)
19 return x;
20 /* y = int(x) - x, where int(x) is an integer neighbor of x */
21 if (u.i.se >> 15)
22 y = x - toint + toint - x;
23 else
24 y = x + toint - toint - x;
25 /* special case because of non-nearest rounding modes */
26 if (e <= 0x3fff-1) {
27 FORCE_EVAL(y);
28 return u.i.se >> 15 ? -0.0 : 1;
29 }
30 if (y < 0)
31 return x + y + 1;
32 return x + y;
33}
34#endif
lib/libc/musl/src/math/i386/ceil.s deleted-1
...@@ -1 +0,0 @@
1# see floor.s
lib/libc/musl/src/math/i386/ceilf.s deleted-1
...@@ -1 +0,0 @@
1# see floor.s
lib/libc/musl/src/math/i386/ceill.s deleted-1
...@@ -1 +0,0 @@
1# see floor.s
lib/libc/musl/src/math/i386/floor.s+1-22
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1/* zig patch: removed `floorl` and `floorf` in favor of using zig compiler_rt's implementations */1/* zig patch: removed `floorl`, `floorf`, `ceil`, `ceilf` and `ceill` in favor of using zig compiler_rt's implementations */
22
31: fstcw 4(%esp)31: fstcw 4(%esp)
4 mov 5(%esp),%ah4 mov 5(%esp),%ah
...@@ -9,27 +9,6 @@...@@ -9,27 +9,6 @@
9 fldcw 4(%esp)9 fldcw 4(%esp)
10 ret10 ret
1111
12.global ceil
13.type ceil,@function
14ceil:
15 fldl 4(%esp)
16 mov $0xb,%al
17 jmp 1b
18
19.global ceilf
20.type ceilf,@function
21ceilf:
22 flds 4(%esp)
23 mov $0xb,%al
24 jmp 1b
25
26.global ceill
27.type ceill,@function
28ceill:
29 fldt 4(%esp)
30 mov $0xb,%al
31 jmp 1b
32
33.global trunc12.global trunc
34.type trunc,@function13.type trunc,@function
35trunc:14trunc:
lib/libc/musl/src/math/powerpc64/ceil.c deleted-15
...@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef _ARCH_PWR5X
4
5double ceil(double x)
6{
7 __asm__ ("frip %0, %1" : "=d"(x) : "d"(x));
8 return x;
9}
10
11#else
12
13#include "../ceil.c"
14
15#endif
lib/libc/musl/src/math/powerpc64/ceilf.c deleted-15
...@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef _ARCH_PWR5X
4
5float ceilf(float x)
6{
7 __asm__ ("frip %0, %1" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../ceilf.c"
14
15#endif
lib/libc/musl/src/math/s390x/ceil.c deleted-15
...@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5double ceil(double x)
6{
7 __asm__ ("fidbra %0, 6, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../ceil.c"
14
15#endif
lib/libc/musl/src/math/s390x/ceilf.c deleted-15
...@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5float ceilf(float x)
6{
7 __asm__ ("fiebra %0, 6, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../ceilf.c"
14
15#endif
lib/libc/musl/src/math/s390x/ceill.c deleted-15
...@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if defined(__HTM__) || __ARCH__ >= 9
4
5long double ceill(long double x)
6{
7 __asm__ ("fixbra %0, 6, %1, 4" : "=f"(x) : "f"(x));
8 return x;
9}
10
11#else
12
13#include "../ceill.c"
14
15#endif
lib/libc/musl/src/math/x32/ceill.s deleted-1
...@@ -1 +0,0 @@
1# see floorl.s
lib/libc/musl/src/math/x32/floorl.s+1-8
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1/* zig patch: removed `floorl` in favor of using zig compiler_rt's implementations */1/* zig patch: removed `floorl` and `ceill` in favor of using zig compiler_rt's implementations */
22
31: fstcw 8(%esp)31: fstcw 8(%esp)
4 mov 9(%esp),%ah4 mov 9(%esp),%ah
...@@ -9,13 +9,6 @@...@@ -9,13 +9,6 @@
9 fldcw 8(%esp)9 fldcw 8(%esp)
10 ret10 ret
1111
12.global ceill
13.type ceill,@function
14ceill:
15 fldt 8(%esp)
16 mov $0xb,%al
17 jmp 1b
18
19.global truncl12.global truncl
20.type truncl,@function13.type truncl,@function
21truncl:14truncl:
lib/libc/musl/src/math/x86_64/ceill.s deleted-1
...@@ -1 +0,0 @@
1# see floorl.s
lib/libc/musl/src/math/x86_64/floorl.s+1-8
...@@ -1,4 +1,4 @@...@@ -1,4 +1,4 @@
1/* zig patch: removed `floorl` in favor of using zig compiler_rt's implementations */1/* zig patch: removed `floorl` and `ceill` in favor of using zig compiler_rt's implementations */
22
31: fstcw 8(%rsp)31: fstcw 8(%rsp)
4 mov 9(%rsp),%ah4 mov 9(%rsp),%ah
...@@ -9,13 +9,6 @@...@@ -9,13 +9,6 @@
9 fldcw 8(%rsp)9 fldcw 8(%rsp)
10 ret10 ret
1111
12.global ceill
13.type ceill,@function
14ceill:
15 fldt 8(%rsp)
16 mov $0xb,%al
17 jmp 1b
18
19.global truncl12.global truncl
20.type truncl,@function13.type truncl,@function
21truncl:14truncl:
src/libs/mingw.zig-2
...@@ -920,7 +920,6 @@ const mingw32_x86_src = [_][]const u8{...@@ -920,7 +920,6 @@ const mingw32_x86_src = [_][]const u8{
920 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",920 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2l.c",
921 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",921 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanhl.c",
922 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",922 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanl.c",
923 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceill.S",
924 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",923 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "copysignl.S",
925 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",924 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl.c",
926 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",925 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "cosl_internal.S",
...@@ -970,7 +969,6 @@ const mingw32_x86_32_src = [_][]const u8{...@@ -970,7 +969,6 @@ const mingw32_x86_32_src = [_][]const u8{
970 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c",969 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "asinf.c",
971 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c",970 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atan2f.c",
972 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c",971 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "atanf.c",
973 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "ceilf.S",
974 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c",972 "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "fmodf.c",
975};973};
976974
src/libs/musl.zig-15
...@@ -831,8 +831,6 @@ const src_files = [_][]const u8{...@@ -831,8 +831,6 @@ const src_files = [_][]const u8{
831 "musl/src/malloc/reallocarray.c",831 "musl/src/malloc/reallocarray.c",
832 "musl/src/malloc/realloc.c",832 "musl/src/malloc/realloc.c",
833 "musl/src/malloc/replaced.c",833 "musl/src/malloc/replaced.c",
834 "musl/src/math/aarch64/ceil.c",
835 "musl/src/math/aarch64/ceilf.c",
836 "musl/src/math/aarch64/fma.c",834 "musl/src/math/aarch64/fma.c",
837 "musl/src/math/aarch64/fmaf.c",835 "musl/src/math/aarch64/fmaf.c",
838 "musl/src/math/aarch64/fmax.c",836 "musl/src/math/aarch64/fmax.c",
...@@ -885,9 +883,6 @@ const src_files = [_][]const u8{...@@ -885,9 +883,6 @@ const src_files = [_][]const u8{
885 "musl/src/math/cbrt.c",883 "musl/src/math/cbrt.c",
886 "musl/src/math/cbrtf.c",884 "musl/src/math/cbrtf.c",
887 "musl/src/math/cbrtl.c",885 "musl/src/math/cbrtl.c",
888 "musl/src/math/ceil.c",
889 "musl/src/math/ceilf.c",
890 "musl/src/math/ceill.c",
891 "musl/src/math/copysign.c",886 "musl/src/math/copysign.c",
892 "musl/src/math/copysignf.c",887 "musl/src/math/copysignf.c",
893 "musl/src/math/copysignl.c",888 "musl/src/math/copysignl.c",
...@@ -955,9 +950,6 @@ const src_files = [_][]const u8{...@@ -955,9 +950,6 @@ const src_files = [_][]const u8{
955 "musl/src/math/i386/atanf.s",950 "musl/src/math/i386/atanf.s",
956 "musl/src/math/i386/atanl.s",951 "musl/src/math/i386/atanl.s",
957 "musl/src/math/i386/atan.s",952 "musl/src/math/i386/atan.s",
958 "musl/src/math/i386/ceilf.s",
959 "musl/src/math/i386/ceill.s",
960 "musl/src/math/i386/ceil.s",
961 "musl/src/math/i386/exp2l.s",953 "musl/src/math/i386/exp2l.s",
962 "musl/src/math/i386/exp_ld.s",954 "musl/src/math/i386/exp_ld.s",
963 "musl/src/math/i386/expl.s",955 "musl/src/math/i386/expl.s",
...@@ -1092,8 +1084,6 @@ const src_files = [_][]const u8{...@@ -1092,8 +1084,6 @@ const src_files = [_][]const u8{
1092 "musl/src/math/__polevll.c",1084 "musl/src/math/__polevll.c",
1093 "musl/src/math/pow.c",1085 "musl/src/math/pow.c",
1094 "musl/src/math/pow_data.c",1086 "musl/src/math/pow_data.c",
1095 "musl/src/math/powerpc64/ceil.c",
1096 "musl/src/math/powerpc64/ceilf.c",
1097 "musl/src/math/powerpc64/fma.c",1087 "musl/src/math/powerpc64/fma.c",
1098 "musl/src/math/powerpc64/fmaf.c",1088 "musl/src/math/powerpc64/fmaf.c",
1099 "musl/src/math/powerpc64/fmax.c",1089 "musl/src/math/powerpc64/fmax.c",
...@@ -1153,9 +1143,6 @@ const src_files = [_][]const u8{...@@ -1153,9 +1143,6 @@ const src_files = [_][]const u8{
1153 "musl/src/math/round.c",1143 "musl/src/math/round.c",
1154 "musl/src/math/roundf.c",1144 "musl/src/math/roundf.c",
1155 "musl/src/math/roundl.c",1145 "musl/src/math/roundl.c",
1156 "musl/src/math/s390x/ceil.c",
1157 "musl/src/math/s390x/ceilf.c",
1158 "musl/src/math/s390x/ceill.c",
1159 "musl/src/math/s390x/fma.c",1146 "musl/src/math/s390x/fma.c",
1160 "musl/src/math/s390x/fmaf.c",1147 "musl/src/math/s390x/fmaf.c",
1161 "musl/src/math/s390x/nearbyint.c",1148 "musl/src/math/s390x/nearbyint.c",
...@@ -1216,7 +1203,6 @@ const src_files = [_][]const u8{...@@ -1216,7 +1203,6 @@ const src_files = [_][]const u8{
1216 "musl/src/math/x32/asinl.s",1203 "musl/src/math/x32/asinl.s",
1217 "musl/src/math/x32/atan2l.s",1204 "musl/src/math/x32/atan2l.s",
1218 "musl/src/math/x32/atanl.s",1205 "musl/src/math/x32/atanl.s",
1219 "musl/src/math/x32/ceill.s",
1220 "musl/src/math/x32/exp2l.s",1206 "musl/src/math/x32/exp2l.s",
1221 "musl/src/math/x32/expl.s",1207 "musl/src/math/x32/expl.s",
1222 "musl/src/math/x32/expm1l.s",1208 "musl/src/math/x32/expm1l.s",
...@@ -1245,7 +1231,6 @@ const src_files = [_][]const u8{...@@ -1245,7 +1231,6 @@ const src_files = [_][]const u8{
1245 "musl/src/math/x86_64/asinl.s",1231 "musl/src/math/x86_64/asinl.s",
1246 "musl/src/math/x86_64/atan2l.s",1232 "musl/src/math/x86_64/atan2l.s",
1247 "musl/src/math/x86_64/atanl.s",1233 "musl/src/math/x86_64/atanl.s",
1248 "musl/src/math/x86_64/ceill.s",
1249 "musl/src/math/x86_64/exp2l.s",1234 "musl/src/math/x86_64/exp2l.s",
1250 "musl/src/math/x86_64/expl.s",1235 "musl/src/math/x86_64/expl.s",
1251 "musl/src/math/x86_64/expm1l.s",1236 "musl/src/math/x86_64/expm1l.s",
src/libs/wasi_libc.zig-1
...@@ -727,7 +727,6 @@ const libc_top_half_src_files = [_][]const u8{...@@ -727,7 +727,6 @@ const libc_top_half_src_files = [_][]const u8{
727 "musl/src/math/cbrt.c",727 "musl/src/math/cbrt.c",
728 "musl/src/math/cbrtf.c",728 "musl/src/math/cbrtf.c",
729 "musl/src/math/cbrtl.c",729 "musl/src/math/cbrtl.c",
730 "musl/src/math/ceill.c",
731 "musl/src/math/copysignl.c",730 "musl/src/math/copysignl.c",
732 "musl/src/math/__cos.c",731 "musl/src/math/__cos.c",
733 "musl/src/math/__cosdf.c",732 "musl/src/math/__cosdf.c",