1 /* Copyright (C) 1996-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 <https://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), x0
31 struct user_desc *tls, x5
43 /* Save args for the child. */
48 /* Sanity check args. */
50 cbz x10, .Lsyscall_error
51 cbz x1, .Lsyscall_error
53 /* Do the system call. */
54 /* X0:flags, x1:newsp, x2:parenttidptr, x3:newtls, x4:childtid. */
55 mov x0, x2 /* flags */
56 /* New sp is already in x1. */
60 mov x8, #SYS_ify(clone)
70 .type thread_start, %function
76 /* Pick the function arg and execute. */
80 /* We are done, pass the return value through x0. */
81 mov x8, #SYS_ify(exit)
84 .size thread_start, .-thread_start
86 libc_hidden_def (__clone)
87 weak_alias (__clone, clone)