diff options
| author | David <seda18@rolmail.net> | 2025-05-21 00:57:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-21 00:57:38 +0200 |
| commit | 55848363fd5c88bd6313880e770515a9c548c0df (patch) | |
| tree | 1c2cb9fe2d20f6273d41e238aa366f775611f413 /src/libs | |
| parent | a63f7875f451bda975ddabcc0c1feed10a216516 (diff) | |
| download | zig-55848363fd5c88bd6313880e770515a9c548c0df.tar.gz zig-55848363fd5c88bd6313880e770515a9c548c0df.zip | |
libc: implement common `abs` for various integer sizes (#23893)
* libc: implement common `abs` for various integer sizes
* libc: move imaxabs to inttypes.zig and don't use cInclude
* libc: delete `fabs` c implementations because already implemented in compiler_rt
* libc: export functions depending on the target libc
Previously all the functions that were exported were handled equally,
though some may exist and some not inside the same file. Moving the
checks inside the file allows handling different functions differently
* remove empty ifs in inttypes
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
* remove empty ifs in stdlib
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
* libc: use `@abs` for the absolute value calculation
---------
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
Diffstat (limited to 'src/libs')
| -rw-r--r-- | src/libs/mingw.zig | 2 | ||||
| -rw-r--r-- | src/libs/musl.zig | 33 | ||||
| -rw-r--r-- | src/libs/wasi_libc.zig | 5 |
3 files changed, 0 insertions, 40 deletions
diff --git a/src/libs/mingw.zig b/src/libs/mingw.zig index 640ed908f5..59c4cd0e4a 100644 --- a/src/libs/mingw.zig +++ b/src/libs/mingw.zig @@ -574,7 +574,6 @@ const mingw32_generic_src = [_][]const u8{ "gdtoa" ++ path.sep_str ++ "sum.c", "gdtoa" ++ path.sep_str ++ "ulp.c", "math" ++ path.sep_str ++ "coshl.c", - "math" ++ path.sep_str ++ "fabsl.c", "math" ++ path.sep_str ++ "fp_consts.c", "math" ++ path.sep_str ++ "fp_constsf.c", "math" ++ path.sep_str ++ "fp_constsl.c", @@ -946,7 +945,6 @@ const mingw32_x86_src = [_][]const u8{ "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "sinl_internal.S", "math" ++ path.sep_str ++ "x86" ++ path.sep_str ++ "tanl.S", // ucrtbase - "math" ++ path.sep_str ++ "fabsf.c", "math" ++ path.sep_str ++ "nextafterl.c", "math" ++ path.sep_str ++ "nexttoward.c", "math" ++ path.sep_str ++ "nexttowardf.c", diff --git a/src/libs/musl.zig b/src/libs/musl.zig index 4ae86f0214..e9d213b485 100644 --- a/src/libs/musl.zig +++ b/src/libs/musl.zig @@ -825,8 +825,6 @@ const src_files = [_][]const u8{ "musl/src/malloc/replaced.c", "musl/src/math/aarch64/ceil.c", "musl/src/math/aarch64/ceilf.c", - "musl/src/math/aarch64/fabs.c", - "musl/src/math/aarch64/fabsf.c", "musl/src/math/aarch64/floor.c", "musl/src/math/aarch64/floorf.c", "musl/src/math/aarch64/fma.c", @@ -859,8 +857,6 @@ const src_files = [_][]const u8{ "musl/src/math/acoshf.c", "musl/src/math/acoshl.c", "musl/src/math/acosl.c", - "musl/src/math/arm/fabs.c", - "musl/src/math/arm/fabsf.c", "musl/src/math/arm/fma.c", "musl/src/math/arm/fmaf.c", "musl/src/math/arm/sqrt.c", @@ -917,9 +913,6 @@ const src_files = [_][]const u8{ "musl/src/math/expm1l.c", "musl/src/math/__expo2.c", "musl/src/math/__expo2f.c", - "musl/src/math/fabs.c", - "musl/src/math/fabsf.c", - "musl/src/math/fabsl.c", "musl/src/math/fdim.c", "musl/src/math/fdimf.c", "musl/src/math/fdiml.c", @@ -968,9 +961,6 @@ const src_files = [_][]const u8{ "musl/src/math/i386/exp_ld.s", "musl/src/math/i386/expl.s", "musl/src/math/i386/expm1l.s", - "musl/src/math/i386/fabs.c", - "musl/src/math/i386/fabsf.c", - "musl/src/math/i386/fabsl.c", "musl/src/math/i386/floorf.s", "musl/src/math/i386/floorl.s", "musl/src/math/i386/floor.s", @@ -1083,8 +1073,6 @@ const src_files = [_][]const u8{ "musl/src/math/__math_uflowf.c", "musl/src/math/__math_xflow.c", "musl/src/math/__math_xflowf.c", - "musl/src/math/mips/fabs.c", - "musl/src/math/mips/fabsf.c", "musl/src/math/mips/sqrt.c", "musl/src/math/mips/sqrtf.c", "musl/src/math/modf.c", @@ -1107,8 +1095,6 @@ const src_files = [_][]const u8{ "musl/src/math/pow_data.c", "musl/src/math/powerpc64/ceil.c", "musl/src/math/powerpc64/ceilf.c", - "musl/src/math/powerpc64/fabs.c", - "musl/src/math/powerpc64/fabsf.c", "musl/src/math/powerpc64/floor.c", "musl/src/math/powerpc64/floorf.c", "musl/src/math/powerpc64/fma.c", @@ -1127,8 +1113,6 @@ const src_files = [_][]const u8{ "musl/src/math/powerpc64/sqrtf.c", "musl/src/math/powerpc64/trunc.c", "musl/src/math/powerpc64/truncf.c", - "musl/src/math/powerpc/fabs.c", - "musl/src/math/powerpc/fabsf.c", "musl/src/math/powerpc/fma.c", "musl/src/math/powerpc/fmaf.c", "musl/src/math/powerpc/sqrt.c", @@ -1151,8 +1135,6 @@ const src_files = [_][]const u8{ "musl/src/math/rintl.c", "musl/src/math/riscv32/copysign.c", "musl/src/math/riscv32/copysignf.c", - "musl/src/math/riscv32/fabs.c", - "musl/src/math/riscv32/fabsf.c", "musl/src/math/riscv32/fma.c", "musl/src/math/riscv32/fmaf.c", "musl/src/math/riscv32/fmax.c", @@ -1163,8 +1145,6 @@ const src_files = [_][]const u8{ "musl/src/math/riscv32/sqrtf.c", "musl/src/math/riscv64/copysign.c", "musl/src/math/riscv64/copysignf.c", - "musl/src/math/riscv64/fabs.c", - "musl/src/math/riscv64/fabsf.c", "musl/src/math/riscv64/fma.c", "musl/src/math/riscv64/fmaf.c", "musl/src/math/riscv64/fmax.c", @@ -1179,9 +1159,6 @@ const src_files = [_][]const u8{ "musl/src/math/s390x/ceil.c", "musl/src/math/s390x/ceilf.c", "musl/src/math/s390x/ceill.c", - "musl/src/math/s390x/fabs.c", - "musl/src/math/s390x/fabsf.c", - "musl/src/math/s390x/fabsl.c", "musl/src/math/s390x/floor.c", "musl/src/math/s390x/floorf.c", "musl/src/math/s390x/floorl.c", @@ -1255,9 +1232,6 @@ const src_files = [_][]const u8{ "musl/src/math/x32/exp2l.s", "musl/src/math/x32/expl.s", "musl/src/math/x32/expm1l.s", - "musl/src/math/x32/fabsf.s", - "musl/src/math/x32/fabsl.s", - "musl/src/math/x32/fabs.s", "musl/src/math/x32/floorl.s", "musl/src/math/x32/fma.c", "musl/src/math/x32/fmaf.c", @@ -1287,9 +1261,6 @@ const src_files = [_][]const u8{ "musl/src/math/x86_64/exp2l.s", "musl/src/math/x86_64/expl.s", "musl/src/math/x86_64/expm1l.s", - "musl/src/math/x86_64/fabs.c", - "musl/src/math/x86_64/fabsf.c", - "musl/src/math/x86_64/fabsl.c", "musl/src/math/x86_64/floorl.s", "musl/src/math/x86_64/fma.c", "musl/src/math/x86_64/fmaf.c", @@ -1809,7 +1780,6 @@ const src_files = [_][]const u8{ "musl/src/stdio/vwscanf.c", "musl/src/stdio/wprintf.c", "musl/src/stdio/wscanf.c", - "musl/src/stdlib/abs.c", "musl/src/stdlib/atof.c", "musl/src/stdlib/atoi.c", "musl/src/stdlib/atol.c", @@ -1819,11 +1789,8 @@ const src_files = [_][]const u8{ "musl/src/stdlib/ecvt.c", "musl/src/stdlib/fcvt.c", "musl/src/stdlib/gcvt.c", - "musl/src/stdlib/imaxabs.c", "musl/src/stdlib/imaxdiv.c", - "musl/src/stdlib/labs.c", "musl/src/stdlib/ldiv.c", - "musl/src/stdlib/llabs.c", "musl/src/stdlib/lldiv.c", "musl/src/stdlib/qsort.c", "musl/src/stdlib/qsort_nr.c", diff --git a/src/libs/wasi_libc.zig b/src/libs/wasi_libc.zig index f718f39793..302a47c623 100644 --- a/src/libs/wasi_libc.zig +++ b/src/libs/wasi_libc.zig @@ -751,7 +751,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/math/expm1.c", "musl/src/math/expm1f.c", "musl/src/math/expm1l.c", - "musl/src/math/fabsl.c", "musl/src/math/fdim.c", "musl/src/math/fdimf.c", "musl/src/math/fdiml.c", @@ -1024,7 +1023,6 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/stdio/vwscanf.c", "musl/src/stdio/wprintf.c", "musl/src/stdio/wscanf.c", - "musl/src/stdlib/abs.c", "musl/src/stdlib/atof.c", "musl/src/stdlib/atoi.c", "musl/src/stdlib/atol.c", @@ -1034,11 +1032,8 @@ const libc_top_half_src_files = [_][]const u8{ "musl/src/stdlib/ecvt.c", "musl/src/stdlib/fcvt.c", "musl/src/stdlib/gcvt.c", - "musl/src/stdlib/imaxabs.c", "musl/src/stdlib/imaxdiv.c", - "musl/src/stdlib/labs.c", "musl/src/stdlib/ldiv.c", - "musl/src/stdlib/llabs.c", "musl/src/stdlib/lldiv.c", "musl/src/stdlib/qsort.c", "musl/src/stdlib/qsort_nr.c", |
