mips: PROF is never defined, kill dead code
[uclibc-ng.git] / libc / sysdeps / linux / mips / vfork.S
blob494c34fd06a5fa3f1244a2be4b3ea67ae5fc1c0c
1 /* Copyright (C) 2005 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
18 /* vfork() is just a special case of clone().  */
20 #include <sys/syscall.h>
21 #include <sys/asm.h>
22 #include <sysdep.h>
24 #ifndef SAVE_PID
25 #define SAVE_PID
26 #endif
28 #ifndef RESTORE_PID
29 #define RESTORE_PID
30 #endif
32 #ifdef __NR_fork
34 /* int vfork() */
36         .text
37         .hidden __vfork
38 LOCALSZ= 1
39 FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
40 GPOFF= FRAMESZ-(1*SZREG)
41 NESTED(__vfork,FRAMESZ,sp)
42 #ifdef __PIC__
43         SETUP_GP
44 #endif
45         PTR_SUBU sp, FRAMESZ
46         SETUP_GP64 (a5, __vfork)
47 #ifdef __PIC__
48         SAVE_GP (GPOFF)
49 #endif
51         PTR_ADDU        sp, FRAMESZ
53         SAVE_PID
55         li              a0, 0x4112      /* CLONE_VM | CLONE_VFORK | SIGCHLD */
56         move            a1, sp
58         /* Do the system call */
59         li              v0,__NR_clone
60         syscall
62         RESTORE_PID
64         bnez            a3,L(error)
66         /* Successful return from the parent or child.  */
67         RESTORE_GP64
68         j               ra
69         nop
71         /* Something bad happened -- no child created.  */
72 L(error):
73         move    a0, v0
74 #ifdef __PIC__
75         PTR_LA          t9, __syscall_error
76         RESTORE_GP64
77         jr              t9
78 #else
79         RESTORE_GP64
80         j               __syscall_error
81 #endif
82         END(__vfork)
84 weak_alias(__vfork,vfork)
85 libc_hidden_def(vfork)
87 #endif