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>
This commit is contained in:
David
2025-05-21 00:57:38 +02:00
committed by GitHub
parent a63f7875f4
commit 55848363fd
42 changed files with 65 additions and 428 deletions

View File

@@ -14,6 +14,9 @@ else
std.debug.no_panic;
comptime {
_ = @import("c/inttypes.zig");
_ = @import("c/stdlib.zig");
if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
// Files specific to musl and wasi-libc.
_ = @import("c/string.zig");