1 /* Wrapper around clone system call.
2 Copyright (C) 1997-2019 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/>. */
21 #include <bits/errno.h>
23 /* This is the only really unusual system call in PPC linux, but not
24 because of any weirdness in the system call itself; because of
25 all the freaky stuff we have to do to make the call useful. */
27 /* int [r3] clone(int (*fn)(void *arg) [r3], void *child_stack [r4],
28 int flags [r5], void *arg [r6], void *parent_tid [r7],
29 void *tls [r8], void *child_tid [r9]); */
33 /* Check for child_stack == NULL || fn == NULL. */
36 cror cr0*4+eq,cr1*4+eq,cr0*4+eq
39 /* Set up stack frame for parent. */
41 cfi_adjust_cfa_offset (32)
44 /* Set up stack frame for child. */
49 /* Save fn, args, stack across syscall. */
50 mr r30,r3 /* Function in r30. */
52 mr r31,r6 /* Argument in r31. */
54 /* 'flags' argument is first parameter to clone syscall. (The other
55 argument is the stack pointer, already in r4.) */
58 /* Move the parent_tid, child_tid and tls arguments. */
63 /* End FDE now, because in the child the unwind info will be
68 DO_CALL(SYS_ify(clone))
70 /* Check for child process. */
72 crandc cr1*4+eq,cr1*4+eq,cr0*4+so
73 bne- cr1,L(parent) /* The '-' is to minimise the race. */
79 DO_CALL(SYS_ify(exit))
82 /* Parent. Restore registers & return. */
86 b __syscall_error@local
90 b __syscall_error@local
95 libc_hidden_def (__clone)
96 weak_alias (__clone, clone)