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.
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.
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.
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
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. */
24 #include <asm/unistd.h>
27 #include <bits/errno.h>
29 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
33 /* FIXME: I have no idea how profiling works on hppa. */
35 /* Sanity check arguments. */
36 comib,= 0,%arg0,.Lerror /* no NULL function pointers */
38 comib,= 0,%arg1,.Lerror /* no NULL stack pointers */
41 /* Save the fn ptr and arg on the new stack. */
45 /* Save the PIC register. */
47 stw %r19,-32(%sr0, %sp) /* parent */
50 /* Do the system call */
56 comclr,>>= %r1,%ret0,%r0 /* Note: unsigned compare. */
59 comib,=,n 0,%ret0,thread_start
61 /* Successful return from the parent
62 No need to restore the PIC register,
63 since we return immediately. */
68 /* Something bad happened -- no child created */
71 /* Restore the PIC register on error */
73 ldw -32(%sr0, %sp), %r19 /* parent */
81 /* Load up the arguments. */
82 ldw -60(%sr0, %sp),%arg0
83 ldw -64(%sr0, %sp),%r22
85 /* $$dyncall fixes childs PIC register */
87 /* Call the user's function */
99 weak_alias (__clone, clone)