1 /* Copyright 2015 Yoshinori Sato <ysato@users.sourceforge.jp> */
3 /* clone is even more special than fork as it mucks with stacks
4 and invokes a function in the right context after its all over. */
7 #include <bits/errno.h>
8 #include <sys/syscall.h>
10 /* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg
11 void *parent_tidptr, void *tls, void *child_tidptr) */
23 /* Sanity check arguments. */
25 mov.l er0,er0 /* no NULL function pointers */
27 mov.l er1,er1 /* no NULL stack pointers */
30 /* Allocate space and copy the argument onto the new stack. */
35 mov.l er0,er3 /* er3 = child entry */
37 mov.l er2,@sp /* flags */
38 mov.l er1,@(4,sp) /* new sp */
41 mov.l er0,@er1 /* parent tid */
44 mov.l er0,@er1 /* child tid */
47 mov.l er0,@er1 /* tls */
48 /* do the system call */
65 mov.l @(__errno_location@GOTOFF,er5),er1
76 mov.l @sp+,er0 /* restore args */