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.

stackAlignment

Target.stackAlignment
pub fn stackAlignment(target: *const Target) u16

File

lib/std/Target.zig:2989

Code

pub fn stackAlignment(target: *const Target) u16 {
    // Overrides for when the stack alignment is not equal to the pointer width.
    switch (target.cpu.arch) {
        .ez80 => return 1,

        .m68k => return 2,

        .amdgcn => return 4,

        .arm,
        .armeb,
        .hppa,
        .lanai,
        .mips,
        .mipsel,
        .sparc,
        .thumb,
        .thumbeb,
        => return 8,

        .aarch64,
        .aarch64_be,
        .alpha,
        .bpfeb,
        .bpfel,
        .hppa64,
        .loongarch32,
        .loongarch64,
        .mips64,
        .mips64el,
        .sparc64,
        .ve,
        .wasm32,
        .wasm64,
        .x86_64,
        => return 16,

        // Some of the following prongs should really be testing the ABI, but our current `Abi` enum
        // can't handle that level of nuance yet.
        .powerpc64,
        .powerpc64le,
        => if (target.os.tag == .linux) return 16,

        .riscv32,
        .riscv32be,
        .riscv64,
        .riscv64be,
        => if (!target.cpu.has(.riscv, .e)) return 16,

        .x86 => if (target.os.tag != .windows and target.os.tag != .uefi) return 16,

        .kvx => return 32,

        else => {},
    }

    return @divExact(target.ptrBitWidth(), 8);
}