Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

Abi

Target.Abi
pub const Abi = enum

File

lib/std/Target.zig:797

Code

pub const Abi = enum {
    none,
    gnu,
    gnuabin32,
    gnuabi64,
    gnueabi,
    gnueabihf,
    gnuf32,
    gnusf,
    gnux32,
    eabi,
    eabihf,
    abin32,
    x32,
    ilp32,
    android,
    androideabi,
    musl,
    muslabin32,
    muslabi64,
    musleabi,
    musleabihf,
    muslf32,
    muslsf,
    muslx32,
    msvc,
    itanium,
    simulator,
    ohos,
    ohoseabi,
    call0,

    pub fn default(arch: Cpu.Arch, os_tag: Os.Tag) Abi {
        return switch (os_tag) {
            .freestanding, .other => switch (arch) {
                // Soft float is usually a sane default for freestanding.
                .arm,
                .armeb,
                .csky,
                .hppa,
                .mips,
                .mipsel,
                .powerpc,
                .powerpcle,
                .sh,
                .sheb,
                .thumb,
                .thumbeb,
                => .eabi,
                else => .none,
            },
            .fuchsia => switch (arch) {
                .arm,
                .thumb,
                => .eabihf,
                else => .none,
            },
            .haiku => switch (arch) {
                .arm => .eabihf,
                else => .none,
            },
            .hurd => .gnu,
            .linux => switch (arch) {
                .arm,
                .armeb,
                .powerpc,
                .powerpcle,
                .thumb,
                .thumbeb,
                => .musleabihf,
                .mips,
                .mipsel,
                => .musleabi,
                .mips64,
                .mips64el,
                => .muslabi64,

                // No musl support.
                .alpha,
                .arc,
                .arceb,
                .or1k,
                .sparc,
                .sparc64,
                => .gnu,
                .csky,
                => .gnueabi,
                .hppa,
                .sh,
                .sheb,
                => .gnueabihf,

                // No glibc or musl support.
                .xtensa,
                .xtensaeb,
                => .none,

                else => .musl,
            },
            .rtems => switch (arch) {
                .arm,
                .armeb,
                .thumb,
                .thumbeb,
                .mips,
                .mipsel,
                => .eabi,
                .powerpc,
                => .eabihf,
                else => .none,
            },
            .freebsd => switch (arch) {
                .arm,
                => .eabihf,
                else => .none,
            },
            .netbsd => switch (arch) {
                .arm,
                .armeb,
                .powerpc,
                => .eabihf,
                // Soft float tends to be more common for MIPS.
                .mips,
                .mipsel,
                => .eabi,
                else => .none,
            },
            .openbsd => switch (arch) {
                .arm,
                => .eabi,
                .powerpc,
                => .eabihf,
                else => .none,
            },
            .windows => .gnu,
            .uefi => .msvc,
            .@"3ds" => .eabihf,
            .wiiu => .eabihf,
            .psx => .eabi,
            .psp => .eabihf,
            .vita => .eabihf,
            .wasi, .emscripten => .musl,

            .ashetos => .eabi,

            .contiki,
            .hermit,
            .illumos,
            .managarm,
            .plan9,
            .serenity,
            .dragonfly,
            .driverkit,
            .ios,
            .maccatalyst,
            .macos,
            .tvos,
            .visionos,
            .watchos,
            .@"switch",
            .ps3,
            .ps4,
            .ps5,
            .amdhsa,
            .amdpal,
            .cuda,
            .mesa3d,
            .nvcl,
            .opencl,
            .opengl,
            .vulkan,
            .tios,
            => .none,
        };
    }

    pub inline fn isGnu(abi: Abi) bool {
        return switch (abi) {
            .gnu,
            .gnuabin32,
            .gnuabi64,
            .gnueabi,
            .gnueabihf,
            .gnuf32,
            .gnusf,
            .gnux32,
            => true,
            else => false,
        };
    }

    pub inline fn isMusl(abi: Abi) bool {
        return switch (abi) {
            .musl,
            .muslabin32,
            .muslabi64,
            .musleabi,
            .musleabihf,
            .muslf32,
            .muslsf,
            .muslx32,
            => true,
            else => abi.isOpenHarmony(),
        };
    }

    pub inline fn isOpenHarmony(abi: Abi) bool {
        return switch (abi) {
            .ohos, .ohoseabi => true,
            else => false,
        };
    }

    pub inline fn isAndroid(abi: Abi) bool {
        return switch (abi) {
            .android, .androideabi => true,
            else => false,
        };
    }

    pub const Float = enum {
        hard,
        soft,
    };

    pub inline fn float(abi: Abi) Float {
        return switch (abi) {
            .androideabi,
            .eabi,
            .gnueabi,
            .musleabi,
            .gnusf,
            .muslsf,
            .ohoseabi,
            => .soft,
            else => .hard,
        };
    }
}