4 .type __clone, %function
6 # int clone(fn, stack, flags, arg, ptid, tls, ctid)
10 # tid = syscall(SYS_clone,c,b,e,f,g);
11 # if (!tid) syscall(SYS_exit, a(d));
14 # create initial stack frame for new thread
19 # save fn and arg to child stack
23 # shuffle args into correct registers and call SYS_clone
29 li 0, 120 # SYS_clone = 120
32 # if error, negate return (errno)
36 1: # if we're the parent, return
40 # we're the child. call fn(arg)
46 # call SYS_exit. exit code is already in r3 from fn return value
47 li 0, 1 # SYS_exit = 1