(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / unix / sysv / linux / m68k / clone.S
blob6baf723d9b14fc208cebd3f69a06774ebcb91d1c
1 /* Copyright (C) 1996,97,98,2002 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Andreas Schwab (schwab@issan.informatik.uni-dortmund.de)
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, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
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.  */
23 #include <sysdep.h>
24 #define _ERRNO_H        1
25 #include <bits/errno.h>
27 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
29         .text
30 ENTRY (__clone)
32         /* Sanity check arguments.  */
33         movel   #-EINVAL, %d0
34         movel   4(%sp), %a0             /* no NULL function pointers */
35         tstl    %a0
36         jeq     SYSCALL_ERROR_LABEL
37         movel   8(%sp), %a1             /* no NULL stack pointers */
38         tstl    %a1
39         jeq     SYSCALL_ERROR_LABEL
41         /* Allocate space and copy the argument onto the new stack.  */
42         movel   16(%sp), -(%a1)
44         /* Do the system call */
45         exg     %d2, %a1                /* save %d2 and get stack pointer */
46         movel   12(%sp), %d1            /* get flags */
47         movel   #SYS_ify (clone), %d0
48         trap    #0
49         exg     %d2, %a1                /* restore %d2 */
51         tstl    %d0
52         jmi     SYSCALL_ERROR_LABEL
53         jeq     thread_start
55         rts
57 thread_start:
58         subl    %fp, %fp        /* terminate the stack frame */
59         jsr     (%a0)
60         movel   %d0, %d1
61         movel   #SYS_ify (exit), %d0
62         trap    #0
64 PSEUDO_END (__clone)
66 weak_alias (__clone, clone)