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.
pubfnsyscall_fork() u64 {
// Linux/sparc64 fork() returns two values in %o0 and %o1:
// - On the parent's side, %o0 is the child's PID and %o1 is 0.
// - On the child's side, %o0 is the parent's PID and %o1 is 1.
// We need to clear the child's %o0 so that the return values
// conform to the libc convention.
returnasmvolatile (
\\ t 0x6d\\ bcc,pt %%xcc, 1f\\ nop\\ ba 2f\\ neg %%o0\\1:\\ # Clear the child's %%o0\\ dec %%o1\\ and %%o1, %%o0, %%o0\\2:
: [ret] "={o0}" (-> u64),
: [number] "{g1}" (@backingInt(SYS.fork)),
: .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
}