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.

__ctz_limb64

limb64.__ctz_limb64
fn __ctz_limb64(a_ptr: [*]const u64, bits: u16) callconv(.c) u16

File

lib/compiler_rt/limb64.zig:736

Code

fn __ctz_limb64(a_ptr: [*]const u64, bits: u16) callconv(.c) u16 {
    const limb_cnt = usedLimbCount(bits);
    const a = constLimbs(a_ptr, bits);

    var res: u16 = 0;
    var i: usize = 0;
    while (i < limb_cnt - 1) : (i += 1) {
        const limb = limbGet(a, i);
        if (limb == 0) {
            res += 64;
        } else {
            res += @ctz(limb);
            return res;
        }
    }

    const limb = limbGet(a, i);
    if (bits % 64 != 0 and limb == 0) {
        res += bits % 64;
    } else {
        res += @ctz(limb);
    }

    return res;
}