]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/hppa/clone.S
Update.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / hppa / clone.S
1 /* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by David Huggins-Daines <dhd@debian.org>, 2000.
4 Based on the Alpha version by Richard Henderson <rth@tamu.edu>, 1996.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
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 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21 /* clone() is even more special than fork() as it mucks with stacks
22 and invokes a function in the right context after its all over. */
23
24 #include <asm/unistd.h>
25 #include <sysdep.h>
26 #define _ERRNO_H 1
27 #include <bits/errno.h>
28
29 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
30
31 .text
32 ENTRY(__clone)
33 /* FIXME: I have no idea how profiling works on hppa. */
34
35 /* Sanity check arguments. */
36 comib,= 0,%arg0,.Lerror /* no NULL function pointers */
37 ldi -EINVAL,%ret0
38 comib,= 0,%arg1,.Lerror /* no NULL stack pointers */
39 nop
40
41 /* Save the fn ptr and arg on the new stack. */
42 stwm %arg0,64(%arg1)
43 stw %arg3,-60(%arg1)
44
45 /* Save the PIC register. */
46 #ifdef PIC
47 stw %r19,-32(%sr0, %sp) /* parent */
48 #endif
49
50 /* Do the system call */
51 copy %arg2,%arg0
52 ble 0x100(%sr2,%r0)
53 ldi __NR_clone,%r20
54
55 ldi -4096,%r1
56 comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
57 b,n .Lerror
58
59 comib,=,n 0,%ret0,thread_start
60
61 /* Successful return from the parent
62 No need to restore the PIC register,
63 since we return immediately. */
64
65 bv %r0(%rp)
66 nop
67
68 /* Something bad happened -- no child created */
69 .Lerror:
70
71 /* Restore the PIC register on error */
72 #ifdef PIC
73 ldw -32(%sr0, %sp), %r19 /* parent */
74 #endif
75
76 b __syscall_error
77 sub %r0,%ret0,%arg0
78
79 thread_start:
80
81 /* Load up the arguments. */
82 ldw -60(%sr0, %sp),%arg0
83 ldw -64(%sr0, %sp),%r22
84
85 /* $$dyncall fixes childs PIC register */
86
87 /* Call the user's function */
88 bl $$dyncall,%r31
89 copy %r31,%rp
90
91 bl _exit,%rp
92 copy %ret0,%arg0
93
94 /* Die horribly. */
95 iitlbp %r0,(%r0)
96
97 PSEUDO_END(__clone)
98
99 weak_alias(__clone, clone)