mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
* 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>
38 lines
1.0 KiB
Zig
38 lines
1.0 KiB
Zig
//! This is Zig's multi-target implementation of libc.
|
|
//!
|
|
//! When `builtin.link_libc` is true, we need to export all the functions and
|
|
//! provide a libc API compatible with the target (e.g. musl, wasi-libc, ...).
|
|
|
|
const builtin = @import("builtin");
|
|
const std = @import("std");
|
|
|
|
// Avoid dragging in the runtime safety mechanisms into this .o file, unless
|
|
// we're trying to test zigc.
|
|
pub const panic = if (builtin.is_test)
|
|
std.debug.FullPanic(std.debug.defaultPanic)
|
|
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");
|
|
_ = @import("c/strings.zig");
|
|
}
|
|
|
|
if (builtin.target.isMuslLibC()) {
|
|
// Files specific to musl.
|
|
}
|
|
|
|
if (builtin.target.isWasiLibC()) {
|
|
// Files specific to wasi-libc.
|
|
}
|
|
|
|
if (builtin.target.isMinGW()) {
|
|
// Files specific to MinGW-w64.
|
|
}
|
|
}
|