1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 Contributed by Richard Henderson (rth@tamu.edu)
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
19 /* clone() is even more special than fork() as it mucks with stacks
20 and invokes a function in the right context after its all over. */
25 /* int clone(int (*fn)(), void *child_stack, int flags, int nargs, ...) */
29 /* Sanity check arguments. */
31 movl 4(%esp),%ecx /* no NULL function pointers */
34 movl 8(%esp),%ecx /* no NULL stack pointers */
37 movl 16(%esp),%edx /* no negative argument counts */
41 /* Allocate space on the new stack and copy args over */
44 lea -4(%ecx,%eax,4),%ecx
46 1: movl 16(%esp,%edx,4),%eax
47 movl %eax,0(%ecx,%edx,4)
51 /* Save the function pointer as the zeroth argument.
52 It will be popped off in the child in the ebx frobbing below. */
56 /* Do the system call */
59 movl $SYS_ify(clone),%eax
72 subl %ebp,%ebp /* terminate the stack frame */
81 weak_alias(__clone, clone)