cleanup unused defines and includes from clone.S
[uclibc-ng.git] / libc / sysdeps / linux / aarch64 / clone.S
blob74984aabbe8f3906526a1ff4826a1d79ecc6afb8
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.  */
20 #include <sysdep.h>
21 #define _ERRNO_H        1
22 #include <bits/errno.h>
24 /* int clone(int (*fn)(void *arg),            x0
25              void *child_stack,               x1
26              int flags,                       x2
27              void *arg,                       x3
28              pid_t *ptid,                     x4
29              struct user_desc *tls,           x5
30              pid_t *ctid);                    x6
31  */
32         .text
33 ENTRY(__clone)
34         /* Save args for the child.  */
35         mov     x10, x0
36         mov     x11, x2
37         mov     x12, x3
39         /* Sanity check args.  */
40         mov     x0, #-EINVAL
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.  */
48         mov     x2, x4                  /* ptid  */
49         mov     x3, x5                  /* tls  */
50         mov     x4, x6                  /* ctid  */
51         mov     x8, #SYS_ify(clone)
52         svc     0x0
54         cmp     x0, #0
55         beq     thread_start
56         blt     .Lsyscall_error
57         RET
58 PSEUDO_END (__clone)
60         .align 4
61         .type thread_start, %function
62 thread_start:
63         cfi_startproc
64         cfi_undefined (x30)
65         mov     x29, 0
67         /* Pick the function arg and execute.  */
68         mov     x0, x12
69         blr     x10
71         /* We are done, pass the return value through x0.  */
72         b       HIDDEN_JUMPTARGET(_exit)
73         cfi_endproc
74         .size thread_start, .-thread_start
76 libc_hidden_def (__clone)
77 weak_alias (__clone, clone)