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, see
17 <http://www.gnu.org/licenses/>. */
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. */
24 #include <bits/errno.h>
25 #include <sys/syscall.h>
26 #include <bits/arm_asm.h>
28 #if defined(__NR_clone)
29 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
33 .type __clone,%function
35 #if defined(THUMB1_ONLY)
44 @ insert the args onto the new stack
47 @ save the function pointer as the 0th element
53 @ new sp is already in r1
54 @ load remaining arguments off the stack
67 @ pick the function arg and call address off the stack and execute
72 @ and we are done, passing the return value through r0
73 bl HIDDEN_JUMPTARGET(_exit)
96 @ insert the args onto the new stack
99 @ save the function pointer as the 0th element
105 @ new sp is already in r1
106 @ load remaining arguments off the stack
116 #if defined(__USE_BX__)
122 @ pick the function arg and call address off the stack and execute
127 @ and we are done, passing the return value through r0
128 b HIDDEN_JUMPTARGET(_exit)
134 .size __clone,.-__clone
135 weak_alias(__clone, clone)