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.

__popcount_limb64

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

File

lib/compiler_rt/limb64.zig:792

Code

fn __popcount_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) {
        res += @popCount(limbGet(a, i));
    }

    var limb = limbGet(a, i);
    if (bits % 64 != 0) {
        limb <<= @intCast(64 - bits % 64);
    }
    res += @popCount(limb);

    return res;
}