zig/lib/c.zig
GasInfinity 9cf34a8d81
feat(libzigc): move over some linux syscalls
* does not move all of them, only those which map almost 1:1
* also removes their musl implementation
2026-01-24 20:41:15 +01:00

46 lines
1.4 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");
_ = @import("c/unistd.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.
}
}