1 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Richard Henderson (rth@tamu.edu)
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* clone() is even more special than fork() as it mucks with stacks
21 and invokes a function in the right context after its all over. */
25 #include <bits/errno.h>
26 #include <asm-syntax.h>
28 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
32 /* Sanity check arguments. */
34 movl 4(%esp),%ecx /* no NULL function pointers */
37 movl 8(%esp),%ecx /* no NULL stack pointers */
41 /* Insert the argument onto the new stack. */
43 movl 16(%esp),%eax /* no negative argument counts */
46 /* Save the function pointer as the zeroth argument.
47 It will be popped off in the child in the ebx frobbing below. */
51 /* Do the system call */
54 movl $SYS_ify(clone),%eax
65 subl %ebp,%ebp /* terminate the stack frame */
71 addl $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ebx
74 call JUMPTARGET (_exit)
78 weak_alias (__clone, clone)