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.
muloXi4_genericSmall
mulo.muloXi4_genericSmall
inlinefnmuloXi4_genericSmall(comptimeST: type, a: ST, b: ST, overflow: *c_int) ST
inlinefnmuloXi4_genericSmall(comptimeST: type, a: ST, b: ST, overflow: *c_int) ST {
overflow.* = 0;
constmin = math.minInt(ST);
constres: ST = if (ST == i128andbuiltin.target.cpu.arch.isWasm()) res: {
// Despite compiler-rt being built with `-fno-builtin`, LLVM still converts this function to
// a call to `__muloti4` on WASM. This is an upstream bug: circumvent it by directly calling
// the "lower-level" compiler-rt routine for this wrapping multiplication.
break :res@import("mulXi3.zig").__multi3(a, b);
} elsea *% b;
// Hacker's Delight section Overflow subsection Multiplication
// case a=-2^{31}, b=-1 problem, because
// on some machines a*b = -2^{31} with overflow
// Then -2^{31}/-1 overflows and any result is possible.
// => check with a<0 and b=-2^{31}
if ((a < 0andb == min) or (a != 0and@divTrunc(res, a) != b))
overflow.* = 1;
returnres;
}