1 /* Copyright 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>.
4 Based on ../i386/clone.S.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* clone() is even more special than fork() as it mucks with stacks
22 and invokes a function in the right context after its all over. */
26 #include <bits/errno.h>
27 #include <asm-syntax.h>
30 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
33 ENTRY (BP_SYM (__clone))
34 /* Sanity check arguments. */
35 cmp 0,d0 /* no NULL function pointers */
37 cmp 0,d1 /* no NULL stack pointers */
40 /* Allocate room for a function call in the new stack, and
41 store fn and arg in it. They will be read back in
49 /* Do the system call */
57 blt L(to_SYSCALL_ERROR_LABEL)
64 L(to_SYSCALL_ERROR_LABEL):
65 jmp SYSCALL_ERROR_LABEL
68 mov 0,a3 /* terminate the stack frame */
75 add _GLOBAL_OFFSET_TABLE_-(L(here) - .),a2
77 call JUMPTARGET (_exit),[],0
79 PSEUDO_END (BP_SYM (__clone))
81 weak_alias (BP_SYM (__clone), BP_SYM (clone))