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.

syscall_fork

sparc.syscall_fork
pub fn syscall_fork() u32

File

lib/std/os/linux/sparc.zig:169

Code

pub fn syscall_fork() u32 {
    // Linux/sparc 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.
    return asm volatile (
        \\ t 0x10
        \\ bcc 1f
        \\  nop
        \\ ba 2f
        \\  neg %%o0
        \\1:
        \\ # Clear the child's %%o0
        \\ dec %%o1
        \\ and %%o1, %%o0, %%o0
        \\2:
        : [ret] "={o0}" (-> u32),
        : [number] "{g1}" (@backingInt(SYS.fork)),
        : .{ .memory = true, .xcc = true, .o1 = true, .o2 = true, .o3 = true, .o4 = true, .o5 = true, .o7 = true });
}