1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Pat Beirne <patb@corelcomputer.com>
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
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 <sys/syscall.h>
27 #include <bits/arm_asm.h>
29 #if defined(__NR_clone)
30 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
34 .type __clone,%function
36 #if defined(THUMB1_ONLY)
45 @ insert the args onto the new stack
48 @ save the function pointer as the 0th element
54 @ new sp is already in r1
55 @ load remaining arguments off the stack
68 @ pick the function arg and call address off the stack and execute
73 @ and we are done, passing the return value through r0
74 bl HIDDEN_JUMPTARGET(_exit)
97 @ insert the args onto the new stack
100 @ save the function pointer as the 0th element
106 @ new sp is already in r1
107 @ load remaining arguments off the stack
117 #if defined(__USE_BX__)
123 @ pick the function arg and call address off the stack and execute
128 @ and we are done, passing the return value through r0
129 b HIDDEN_JUMPTARGET(_exit)
135 .size __clone,.-__clone
136 weak_alias(__clone, clone)