1const builtin = @import("builtin");
2const std = @import("std.zig");
3const native_os = builtin.os.tag;
4
5pub const linux = @import("os/linux.zig");
6pub const plan9 = @import("os/plan9.zig");
7pub const uefi = @import("os/uefi.zig");
8pub const wasi = @import("os/wasi.zig");
9pub const emscripten = @import("os/emscripten.zig");
10pub const windows = @import("os/windows.zig");
11
12/// Returns whether the Zig standard library requires libc in order to interface
13/// with the operating system on the given target.
14pub fn targetRequiresLibC(target: *const std.Target) bool {
15 if (target.requiresLibC()) return true;
16 return switch (target.os.tag) {
17 .linux => switch (target.cpu.arch) {
18 // https://codeberg.org/ziglang/zig/issues/30943
19 .hppa,
20 .hppa64,
21 => true,
22 else => false,
23 },
24 .freebsd => true, // https://codeberg.org/ziglang/zig/issues/30981
25 .netbsd => true, // https://codeberg.org/ziglang/zig/issues/30980
26 .openbsd => true, // https://codeberg.org/ziglang/zig/issues/30982
27 else => false,
28 };
29}
30
31/// Returns whether the Zig standard library requires libc in order to interface
32/// with the operating system on the current target.
33pub fn requiresLibC() bool {
34 return targetRequiresLibC(&builtin.target);
35}
36
37test {
38 _ = linux;
39 if (native_os == .uefi) _ = uefi;
40 _ = wasi;
41 _ = windows;
42}