1 /* Copyright (C) 2003, 2004 Free Software Foudnation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>, 2003.
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
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. */
24 #include <asm/unistd.h>
26 #include <bits/errno.h>
31 /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg) */
33 /* Sanity check arguments. */
42 setlos #__NR_clone, gr7
48 beq icc0, #0, .Lthread_start
52 sethi.p #gotofffuncdeschi(__syscall_error), gr14
53 setlo #gotofffuncdesclo(__syscall_error), gr14
54 ldd @(gr14, gr15), gr14
58 setlos.p #-EINVAL, gr8
61 ###############################################################################
63 # come here as the new thread [GR4 is fn, GR5 is arg]
65 ###############################################################################
67 /* Save the PIC register. */
70 /* Call the user's function. */
71 ldd.p @(gr4, gr0), gr14
75 /* Call _exit, rather simply inlining the syscall, such that
79 call HIDDEN_JUMPTARGET(_exit)
81 /* Should never get here. */