authorgravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-01-07 19:14:58+01:00
committergravatar for rpkak@noreply.codeberg.orgrpkak <rpkak@noreply.codeberg.org> 2026-01-10 00:09:54+01:00
logaa7dac9739f7ce332c2c3841dd7f3a6d17343e0d
tree4d01d0f235b0cbf38bc9641d7c741b49b3c7b5e2
parenta2861a6c8dd96f69fa280f8a13541ca450143639
signaturebadge-check Signed by SSH key SHA256:A2g6ATENrgLKQcUdthsn72P0njmQxnHSimzwnyJsZzo

libc: remove fmin/fmax implementations


28 files changed, 0 insertions(+), 387 deletions(-)

lib/libc/mingw/math/fmaxl.c deleted-12
......@@ -1,12 +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 <math.h>
7
8long double
9fmaxl (long double _x, long double _y)
10{
11 return (( isgreaterequal(_x, _y) || __isnanl (_y)) ? _x : _y );
12}
lib/libc/mingw/math/fminl.c deleted-12
......@@ -1,12 +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 <math.h>
7
8long double
9fminl (long double _x, long double _y)
10{
11 return ((islessequal(_x, _y) || __isnanl (_y)) ? _x : _y );
12}
lib/libc/musl/src/math/aarch64/fmax.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3double fmax(double x, double y)
4{
5 __asm__ ("fmaxnm %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y));
6 return x;
7}
lib/libc/musl/src/math/aarch64/fmaxf.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3float fmaxf(float x, float y)
4{
5 __asm__ ("fmaxnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
6 return x;
7}
lib/libc/musl/src/math/aarch64/fmin.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3double fmin(double x, double y)
4{
5 __asm__ ("fminnm %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y));
6 return x;
7}
lib/libc/musl/src/math/aarch64/fminf.c deleted-7
......@@ -1,7 +0,0 @@
1#include <math.h>
2
3float fminf(float x, float y)
4{
5 __asm__ ("fminnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
6 return x;
7}
lib/libc/musl/src/math/fmax.c deleted-13
......@@ -1,13 +0,0 @@
1#include <math.h>
2
3double fmax(double x, double y)
4{
5 if (isnan(x))
6 return y;
7 if (isnan(y))
8 return x;
9 /* handle signed zeros, see C99 Annex F.9.9.2 */
10 if (signbit(x) != signbit(y))
11 return signbit(x) ? y : x;
12 return x < y ? y : x;
13}
lib/libc/musl/src/math/fmaxf.c deleted-13
......@@ -1,13 +0,0 @@
1#include <math.h>
2
3float fmaxf(float x, float y)
4{
5 if (isnan(x))
6 return y;
7 if (isnan(y))
8 return x;
9 /* handle signed zeroes, see C99 Annex F.9.9.2 */
10 if (signbit(x) != signbit(y))
11 return signbit(x) ? y : x;
12 return x < y ? y : x;
13}
lib/libc/musl/src/math/fmaxl.c deleted-21
......@@ -1,21 +0,0 @@
1#include <math.h>
2#include <float.h>
3
4#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
5long double fmaxl(long double x, long double y)
6{
7 return fmax(x, y);
8}
9#else
10long double fmaxl(long double x, long double y)
11{
12 if (isnan(x))
13 return y;
14 if (isnan(y))
15 return x;
16 /* handle signed zeros, see C99 Annex F.9.9.2 */
17 if (signbit(x) != signbit(y))
18 return signbit(x) ? y : x;
19 return x < y ? y : x;
20}
21#endif
lib/libc/musl/src/math/fmin.c deleted-13
......@@ -1,13 +0,0 @@
1#include <math.h>
2
3double fmin(double x, double y)
4{
5 if (isnan(x))
6 return y;
7 if (isnan(y))
8 return x;
9 /* handle signed zeros, see C99 Annex F.9.9.2 */
10 if (signbit(x) != signbit(y))
11 return signbit(x) ? x : y;
12 return x < y ? x : y;
13}
lib/libc/musl/src/math/fminf.c deleted-13
......@@ -1,13 +0,0 @@
1#include <math.h>
2
3float fminf(float x, float y)
4{
5 if (isnan(x))
6 return y;
7 if (isnan(y))
8 return x;
9 /* handle signed zeros, see C99 Annex F.9.9.2 */
10 if (signbit(x) != signbit(y))
11 return signbit(x) ? x : y;
12 return x < y ? x : y;
13}
lib/libc/musl/src/math/fminl.c deleted-21
......@@ -1,21 +0,0 @@
1#include <math.h>
2#include <float.h>
3
4#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
5long double fminl(long double x, long double y)
6{
7 return fmin(x, y);
8}
9#else
10long double fminl(long double x, long double y)
11{
12 if (isnan(x))
13 return y;
14 if (isnan(y))
15 return x;
16 /* handle signed zeros, see C99 Annex F.9.9.2 */
17 if (signbit(x) != signbit(y))
18 return signbit(x) ? x : y;
19 return x < y ? x : y;
20}
21#endif
lib/libc/musl/src/math/powerpc64/fmax.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef __VSX__
4
5double fmax(double x, double y)
6{
7 __asm__ ("xsmaxdp %x0, %x1, %x2" : "=ws"(x) : "ws"(x), "ws"(y));
8 return x;
9}
10
11#else
12
13#include "../fmax.c"
14
15#endif
lib/libc/musl/src/math/powerpc64/fmaxf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef __VSX__
4
5float fmaxf(float x, float y)
6{
7 __asm__ ("xsmaxdp %x0, %x1, %x2" : "=ww"(x) : "ww"(x), "ww"(y));
8 return x;
9}
10
11#else
12
13#include "../fmaxf.c"
14
15#endif
lib/libc/musl/src/math/powerpc64/fmin.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef __VSX__
4
5double fmin(double x, double y)
6{
7 __asm__ ("xsmindp %x0, %x1, %x2" : "=ws"(x) : "ws"(x), "ws"(y));
8 return x;
9}
10
11#else
12
13#include "../fmin.c"
14
15#endif
lib/libc/musl/src/math/powerpc64/fminf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#ifdef __VSX__
4
5float fminf(float x, float y)
6{
7 __asm__ ("xsmindp %x0, %x1, %x2" : "=ww"(x) : "ww"(x), "ww"(y));
8 return x;
9}
10
11#else
12
13#include "../fminf.c"
14
15#endif
lib/libc/musl/src/math/riscv32/fmax.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fmax(double x, double y)
6{
7 __asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmax.c"
14
15#endif
lib/libc/musl/src/math/riscv32/fmaxf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fmaxf(float x, float y)
6{
7 __asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmaxf.c"
14
15#endif
lib/libc/musl/src/math/riscv32/fmin.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fmin(double x, double y)
6{
7 __asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmin.c"
14
15#endif
lib/libc/musl/src/math/riscv32/fminf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fminf(float x, float y)
6{
7 __asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fminf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmax.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fmax(double x, double y)
6{
7 __asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmax.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmaxf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fmaxf(float x, float y)
6{
7 __asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmaxf.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fmin.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 64
4
5double fmin(double x, double y)
6{
7 __asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fmin.c"
14
15#endif
lib/libc/musl/src/math/riscv64/fminf.c deleted-15
......@@ -1,15 +0,0 @@
1#include <math.h>
2
3#if __riscv_flen >= 32
4
5float fminf(float x, float y)
6{
7 __asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
8 return x;
9}
10
11#else
12
13#include "../fminf.c"
14
15#endif
lib/libc/wasi/libc-bottom-half/sources/math/fmin-fmax.c deleted-34
......@@ -1,34 +0,0 @@
1// Wasm's `min` and `max` operators implement the IEEE 754-2019
2// `minimum` and `maximum` operations, meaning that given a choice
3// between NaN and a number, they return NaN. This differs from
4// the C standard library's `fmin` and `fmax` functions, which
5// return the number. However, we can still use wasm's builtins
6// by handling the NaN cases explicitly, and it still turns out
7// to be faster than doing the whole operation in
8// target-independent C. And, it's smaller.
9
10#include <math.h>
11
12float fminf(float x, float y) {
13 if (isnan(x)) return y;
14 if (isnan(y)) return x;
15 return __builtin_wasm_min_f32(x, y);
16}
17
18float fmaxf(float x, float y) {
19 if (isnan(x)) return y;
20 if (isnan(y)) return x;
21 return __builtin_wasm_max_f32(x, y);
22}
23
24double fmin(double x, double y) {
25 if (isnan(x)) return y;
26 if (isnan(y)) return x;
27 return __builtin_wasm_min_f64(x, y);
28}
29
30double fmax(double x, double y) {
31 if (isnan(x)) return y;
32 if (isnan(y)) return x;
33 return __builtin_wasm_max_f64(x, y);
34}
src/libs/mingw.zig-2
......@@ -942,8 +942,6 @@ const mingw32_x86_src = [_][]const u8{
942942 "math" ++ path.sep_str ++ "erfl.c",
943943 "math" ++ path.sep_str ++ "fdiml.c",
944944 "math" ++ path.sep_str ++ "fmal.c",
945 "math" ++ path.sep_str ++ "fmaxl.c",
946 "math" ++ path.sep_str ++ "fminl.c",
947945 "math" ++ path.sep_str ++ "llrintl.c",
948946 "math" ++ path.sep_str ++ "llroundl.c",
949947 "math" ++ path.sep_str ++ "lrintl.c",
src/libs/musl.zig-22
......@@ -812,10 +812,6 @@ const src_files = [_][]const u8{
812812 "musl/src/malloc/replaced.c",
813813 "musl/src/math/aarch64/fma.c",
814814 "musl/src/math/aarch64/fmaf.c",
815 "musl/src/math/aarch64/fmax.c",
816 "musl/src/math/aarch64/fmaxf.c",
817 "musl/src/math/aarch64/fmin.c",
818 "musl/src/math/aarch64/fminf.c",
819815 "musl/src/math/aarch64/llrint.c",
820816 "musl/src/math/aarch64/llrintf.c",
821817 "musl/src/math/aarch64/llround.c",
......@@ -893,12 +889,6 @@ const src_files = [_][]const u8{
893889 "musl/src/math/fma.c",
894890 "musl/src/math/fmaf.c",
895891 "musl/src/math/fmal.c",
896 "musl/src/math/fmax.c",
897 "musl/src/math/fmaxf.c",
898 "musl/src/math/fmaxl.c",
899 "musl/src/math/fmin.c",
900 "musl/src/math/fminf.c",
901 "musl/src/math/fminl.c",
902892 "musl/src/math/__fpclassify.c",
903893 "musl/src/math/__fpclassifyf.c",
904894 "musl/src/math/__fpclassifyl.c",
......@@ -1030,10 +1020,6 @@ const src_files = [_][]const u8{
10301020 "musl/src/math/pow_data.c",
10311021 "musl/src/math/powerpc64/fma.c",
10321022 "musl/src/math/powerpc64/fmaf.c",
1033 "musl/src/math/powerpc64/fmax.c",
1034 "musl/src/math/powerpc64/fmaxf.c",
1035 "musl/src/math/powerpc64/fmin.c",
1036 "musl/src/math/powerpc64/fminf.c",
10371023 "musl/src/math/powerpc64/lrint.c",
10381024 "musl/src/math/powerpc64/lrintf.c",
10391025 "musl/src/math/powerpc64/lround.c",
......@@ -1066,20 +1052,12 @@ const src_files = [_][]const u8{
10661052 "musl/src/math/riscv32/copysignf.c",
10671053 "musl/src/math/riscv32/fma.c",
10681054 "musl/src/math/riscv32/fmaf.c",
1069 "musl/src/math/riscv32/fmax.c",
1070 "musl/src/math/riscv32/fmaxf.c",
1071 "musl/src/math/riscv32/fmin.c",
1072 "musl/src/math/riscv32/fminf.c",
10731055 "musl/src/math/riscv32/sqrt.c",
10741056 "musl/src/math/riscv32/sqrtf.c",
10751057 "musl/src/math/riscv64/copysign.c",
10761058 "musl/src/math/riscv64/copysignf.c",
10771059 "musl/src/math/riscv64/fma.c",
10781060 "musl/src/math/riscv64/fmaf.c",
1079 "musl/src/math/riscv64/fmax.c",
1080 "musl/src/math/riscv64/fmaxf.c",
1081 "musl/src/math/riscv64/fmin.c",
1082 "musl/src/math/riscv64/fminf.c",
10831061 "musl/src/math/riscv64/sqrt.c",
10841062 "musl/src/math/riscv64/sqrtf.c",
10851063 "musl/src/math/round.c",
src/libs/wasi_libc.zig-3
......@@ -547,7 +547,6 @@ const libc_bottom_half_src_files = [_][]const u8{
547547 "wasi/libc-bottom-half/sources/getentropy.c",
548548 "wasi/libc-bottom-half/sources/isatty.c",
549549 "wasi/libc-bottom-half/sources/__main_void.c",
550 "wasi/libc-bottom-half/sources/math/fmin-fmax.c",
551550 "wasi/libc-bottom-half/sources/math/math-builtins.c",
552551 "wasi/libc-bottom-half/sources/posix.c",
553552 "wasi/libc-bottom-half/sources/preopens.c",
......@@ -737,8 +736,6 @@ const libc_top_half_src_files = [_][]const u8{
737736 "musl/src/math/finitef.c",
738737 "musl/src/math/fma.c",
739738 "musl/src/math/fmaf.c",
740 "musl/src/math/fmaxl.c",
741 "musl/src/math/fminl.c",
742739 "musl/src/math/frexp.c",
743740 "musl/src/math/frexpf.c",
744741 "musl/src/math/frexpl.c",