aboutsummaryrefslogtreecommitdiff
path: root/lib/c.zig
blob: d59ef950f4d48a4a660c337911a7c6830ed54dc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! 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");
    _ = @import("c/math.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.
    }
}