Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Function

stackAlignment

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

Params

File

Target.zig:3067
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
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,

        .spork8 => return 256,

        else => {},
    }

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