3 .type __clone, %function
5 # int clone(fn, stack, flags, arg, ptid, tls, ctid)
9 # tid = syscall(SYS_clone,c,b,e,f,g);
10 # if (!tid) syscall(SYS_exit, a(d));
16 # in order that the child can find the start func and its arg, we need to store it into
17 # non-volative regs. to do so, we have to store those 2 regs into our stackframe, so
18 # we can restore them later.
23 # save r3 (func) into r30, and r6(arg) into r31
27 #move c into first arg
34 # move syscall number into r0
39 # check for syscall error
40 #this code should be more efficient, but it borks
41 #bns+ 1f # jump to label 1 if no summary overflow.
43 #neg 3, 3 #negate the result (errno)
44 #b 2f # jump to epilogue
46 # this error check code at least does not spoil the clone call.
47 #mfcr 0 # Check for an error
48 #rlwinm 4, 0, 0, 3, 3 # by checking for bit 28.
49 #cmplwi 0, 4, 0 # It is an error if non-zero.
50 #beq 0, 1f # Jump if not an error.
51 #neg 3, 3 # Negate the error number.
52 #b 2f # jump to epilogue
54 # compare sc result with 0
57 # if not 0, jump to end
60 #else: we're the child
62 # move arg (d) into r3
64 #move r30 (funcptr) into CTR reg
68 # mov SYS_exit into r0 (the exit param is already in r3)