1 /* Copyright 2001-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>.
4 Based on ../i386/clone.S.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
20 /* clone() is even more special than fork() as it mucks with stacks
21 and invokes a function in the right context after its all over. */
25 #include <bits/errno.h>
26 #include <asm-syntax.h>
28 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
32 /* Sanity check arguments. */
33 cmp 0,d0 /* no NULL function pointers */
35 cmp 0,d1 /* no NULL stack pointers */
38 /* Allocate room for a function call in the new stack, and
39 store fn and arg in it. They will be read back in
47 /* Do the system call */
55 blt L(to_SYSCALL_ERROR_LABEL)
62 L(to_SYSCALL_ERROR_LABEL):
63 jmp SYSCALL_ERROR_LABEL
66 mov 0,a3 /* terminate the stack frame */
73 add _GLOBAL_OFFSET_TABLE_-(L(here) - .),a2
75 call JUMPTARGET (_exit),[],0
79 weak_alias (__clone, clone)