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.

smix

scrypt.smix
fn smix(b: []align(16) u8, r: u30, n: usize, v: []align(16) u32, xy: []align(16) u32) void

File

lib/std/crypto/scrypt.zig:88

Code

fn smix(b: []align(16) u8, r: u30, n: usize, v: []align(16) u32, xy: []align(16) u32) void {
    const x: []align(16) u32 = @alignCast(xy[0 .. 32 * r]);
    const y: []align(16) u32 = @alignCast(xy[32 * r ..]);

    for (x, 0..) |*v1, j| {
        v1.* = mem.readInt(u32, b[4 * j ..][0..4], .little);
    }

    var tmp: [16]u32 align(16) = undefined;
    var i: usize = 0;
    while (i < n) : (i += 2) {
        blockCopy(@alignCast(v[i * (32 * r) ..]), x, 2 * r);
        blockMix(&tmp, x, y, r);

        blockCopy(@alignCast(v[(i + 1) * (32 * r) ..]), y, 2 * r);
        blockMix(&tmp, y, x, r);
    }

    i = 0;
    while (i < n) : (i += 2) {
        var j = @as(usize, @intCast(integerify(x, r) & (n - 1)));
        blockXor(x, @alignCast(v[j * (32 * r) ..]), 2 * r);
        blockMix(&tmp, x, y, r);

        j = @as(usize, @intCast(integerify(y, r) & (n - 1)));
        blockXor(y, @alignCast(v[j * (32 * r) ..]), 2 * r);
        blockMix(&tmp, y, x, r);
    }

    for (x, 0..) |v1, j| {
        mem.writeInt(u32, b[4 * j ..][0..4], v1, .little);
    }
}