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.

clone

microblaze.clone
pub fn clone() callconv(.naked) u32

File

lib/std/os/linux/microblaze.zig:112

Code

pub fn clone() callconv(.naked) u32 {
    // __clone(func, stack, flags, arg, ptid, tls, ctid)
    //         r5,   r6,    r7,    r8,  r9,   r10, +28
    //
    // syscall(SYS_clone, flags, stack, ptid, ctid, tls)
    //         r12        r5,    r6,    r8,   r9,   r10
    asm volatile (
        \\ andi r6, r6, -4
        \\
        \\ addi r6, r6, -8
        \\ swi r5, r6, 0
        \\ swi r8, r6, 4
        \\
        \\ ori r12, r0, 120 # SYS_clone
        \\ ori r5, r7, 0
        \\ ori r7, r0, 0 # stack size
        \\ ori r8, r9, 0
        \\ lwi r9, r1, 28
        \\ brki r14, 0x8
        \\ beqi r3, 1f
        \\
        \\ // parent
        \\ rtsd r15, 8
        \\  nop
        \\
        \\ // child
        \\1:
        \\ ori r15, r0, 0
        \\ ori r19, r0, 0
        \\
        \\ lwi r3, r1, 0
        \\ lwi r5, r1, 4
        \\ brald r15, r3
        \\  nop
        \\
        \\ ori r12, r0, 1 # SYS_exit
        \\ brki r14, 0x8
    );
}