1 /* Copyright (C) 1996-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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>
26 /* int clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg,
27 pid_t *ptid, struct user_desc *tls, pid_t *ctid);
29 INCOMING: r5 (fn), r6 (child_stack), r7 (flags), r8 (arg), r9 (ptid)
30 r10 (tls), 28 (r1) ctid
34 linux: arch/microblaze/entry.S: sys_clone expects
35 r5 (flags) r6 (child stack) r7 (stack_size) r8 (ptid)r9 (ctid)
42 beqi r5,SYSCALL_ERROR_LABEL ; // Invalid func
43 beqi r6,SYSCALL_ERROR_LABEL ; // Invalid stack
45 swi r5,r6,0 ; // Push fn onto child's stack
46 swi r8,r6,4 ; // Push arg for child
47 addk r5,r0,r7 ; // flags for clone() syscall
49 addk r8,r0,r9 ; // parent tid ptr
50 lwi r9,r1,28 ; // child tid ptr
51 addik r12,r0,SYS_ify(clone)
56 bgei r4,SYSCALL_ERROR_LABEL
57 beqi r3,L(thread_start)
67 addik r12,r0,SYS_ify(exit)
72 libc_hidden_def (__clone)
73 weak_alias (__clone,clone)