1 /* Copyright (C) 1996-2017 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Lesser General Public
5 License as published by the Free Software Foundation; either
6 version 2.1 of the License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
13 You should have received a copy of the GNU Lesser General Public
14 License along with the GNU C Library; if not, see
15 <http://www.gnu.org/licenses/>. */
17 /* clone() is even more special than fork() as it mucks with stacks
18 and invokes a function in the right context after its all over. */
22 #include <bits/errno.h>
24 /* int clone(int (*fn)(void *arg), x0
29 struct user_desc *tls, x5
34 /* Save args for the child. */
39 /* Sanity check args. */
41 cbz x10, .Lsyscall_error
42 cbz x1, .Lsyscall_error
44 /* Do the system call. */
45 /* X0:flags, x1:newsp, x2:parenttidptr, x3:newtls, x4:childtid. */
46 mov x0, x2 /* flags */
47 /* New sp is already in x1. */
51 mov x8, #SYS_ify(clone)
61 .type thread_start, %function
67 /* Pick the function arg and execute. */
71 /* We are done, pass the return value through x0. */
72 mov x8, #SYS_ify(exit)
75 .size thread_start, .-thread_start
77 libc_hidden_def (__clone)
78 weak_alias (__clone, clone)