| 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std.zig"); |
| 3 | const native_os = builtin.os.tag; |
| 4 | |
| 5 | pub const linux = @import("os/linux.zig"); |
| 6 | pub const plan9 = @import("os/plan9.zig"); |
| 7 | pub const uefi = @import("os/uefi.zig"); |
| 8 | pub const wasi = @import("os/wasi.zig"); |
| 9 | pub const emscripten = @import("os/emscripten.zig"); |
| 10 | pub 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. |
| 14 | pub 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. |
| 33 | pub fn requiresLibC() bool { |
| 34 | return targetRequiresLibC(&builtin.target); |
| 35 | } |
| 36 | |
| 37 | test { |
| 38 | _ = linux; |
| 39 | if (native_os == .uefi) _ = uefi; |
| 40 | _ = wasi; |
| 41 | _ = windows; |
| 42 | } |