]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/vax/clone.S
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / vax / clone.S
1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2
3    The GNU C Library is free software; you can redistribute it and/or
4    modify it under the terms of the GNU Library General Public License as
5    published by the Free Software Foundation; either version 2 of the
6    License, or (at your option) any later version.
7
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    Library General Public License for more details.
12
13    You should have received a copy of the GNU Library General Public
14    License along with the GNU C Library; see the file COPYING.LIB.  If not,
15    see <http://www.gnu.org/licenses/>.  */
16
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.  */
19
20 #include <sys/syscall.h>
21
22 #warning "This file contains a hardcoded constant for SYS_clone"
23
24 .section        .rodata
25                 .align 2
26 .LC0:           .long 120       /* SYS_clone */
27 .align 4
28 .text
29 .type   clone,@function
30 .globl  clone;
31 clone:
32         .word 0x0040
33         /* subl2        $8, %sp */
34         movl    4(%ap), %r1
35         movl    8(%ap), %r0
36         mcoml   $21, %r6
37
38         /* Sanity check args.  */
39         tstl    %r1
40         jeql    CLONE_ERROR_LABEL
41         tstl    %r0
42         jeql    CLONE_ERROR_LABEL
43
44         /* Need to setup the child stack the same as the parent.  */
45         subl2   $24, %r0
46         movl    16(%ap), 20(%r0)
47         movl    %r1, 16(%r0)
48         movl    %r0, %r1
49         addl2   $16, %r1
50         movl    %r1, 12(%r0)
51
52         /* Do the system call.  */
53         pushl   %ap
54         pushl   %r0
55         pushl   12(%ap)
56         pushl   $0x2
57         movl    %sp, %ap
58         chmk    .LC0    /* %r0 .LC0 -4(%fp) -8(%fp) */
59         addl2   $12, %sp
60         movl    (%sp)+, %ap
61         movl    %r0, %r6
62         jneq    CLONE_ERROR_LABEL
63
64         movl    $0, %fp
65         pushl   4(%ap)
66         movl    (%r1), %r0
67         calls   $1, (%r0)
68         pushl   %r0
69         calls   $1, HIDDEN_JUMPTARGET(_exit)
70
71 CLONE_ERROR_LABEL:
72         cmpl    %r6, $-126      /* -ENOKEY?!?! Fuck, this must be wrong! FIXME */
73         jlequ   CLONE_RETURN_LABEL
74         calls   $0, __errno_location
75         mnegl   %r6, (%r0)
76         mcoml   $0, %r6
77         movl    %r6, %r0
78         ret
79
80 CLONE_RETURN_LABEL:
81         ret
82
83 .size clone,.-clone
84