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.

intAlignment

target.intAlignment
pub fn intAlignment(target: *const std.Target, bits: u16) u16

File

lib/std/zig/target.zig:501

Code

pub fn intAlignment(target: *const std.Target, bits: u16) u16 {
    return switch (target.cpu.arch) {
        .x86 => switch (bits) {
            0...8 => 1,
            9...16 => 2,
            17...32 => 4,
            33...64 => switch (target.os.tag) {
                .uefi, .windows => 8,
                else => 4,
            },
            else => 16,
        },
        .x86_64 => switch (bits) {
            0...8 => 1,
            9...16 => 2,
            17...32 => 4,
            33...64 => 8,
            else => 16,
        },
        else => switch (bits) {
            0 => 1,
            else => @min(
                std.math.ceilPowerOfTwoPromote(u16, @intCast((@as(u17, bits) + 7) / 8)),
                target.cMaxIntAlignment(),
            ),
        },
    };
}