zig/lib/c.zig
GasInfinity 4f652fb4e3
feat(libzigc): use common implementations for sys/utsname.h
* and remove their musl/wasi implementation
2026-01-21 00:06:42 +01:00

45 lines
1.3 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;
// NOTE: `libzigc` aims to be a standalone libc and provide ABI compatibility with its bundled libc's.
// Some of them like `mingw` are not fully statically linked so some symbols don't need to be exported.
comptime {
_ = @import("c/inttypes.zig");
_ = @import("c/ctype.zig");
_ = @import("c/stdlib.zig");
_ = @import("c/math.zig");
_ = @import("c/string.zig");
_ = @import("c/strings.zig");
_ = @import("c/wchar.zig");
_ = @import("c/sys.zig");
if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
// Files specific to musl and wasi-libc.
}
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.
}
}