]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/m68k/clone.S
* sysdeps/unix/sysv/linux/m68k/sysdep.h (SYSCALL_ERROR_LABEL): New
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / m68k / clone.S
1 /* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
2 Contributed by Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
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. */
21
22 #include <sysdep.h>
23 #define _ERRNO_H 1
24 #include <bits/errno.h>
25
26 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
27
28 .text
29 ENTRY (__clone)
30
31 /* Sanity check arguments. */
32 movel #-EINVAL, %d0
33 movel 4(%sp), %a0 /* no NULL function pointers */
34 tstl %a0
35 jeq SYSCALL_ERROR_LABEL
36 movel 8(%sp), %a1 /* no NULL stack pointers */
37 tstl %a1
38 jeq SYSCALL_ERROR_LABEL
39
40 /* Allocate space and copy the argument onto the new stack. */
41 movel 16(%sp), -(%a1)
42
43 /* Do the system call */
44 exg %d2, %a1 /* save %d2 and get stack pointer */
45 movel 12(%sp), %d1 /* get flags */
46 movel #SYS_ify (clone), %d0
47 trap #0
48 exg %d2, %a1 /* restore %d2 */
49
50 tstl %d0
51 jmi SYSCALL_ERROR_LABEL
52 jeq thread_start
53
54 rts
55
56 thread_start:
57 subl %fp, %fp /* terminate the stack frame */
58 jsr (%a0)
59 movel %d0, -(%sp)
60 jbsr JUMPTARGET (_exit)
61
62 PSEUDO_END (__clone)
63
64 weak_alias (__clone, clone)