Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / unix / sysv / linux / mips / vfork.S
blob6d2c65ad0b9416eaf810322f2661c9ce9fb18cb8
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/asm.h>
21 #include <sysdep.h>
22 #include <asm/unistd.h>
23 #include <sgidefs.h>
25 #ifndef SAVE_PID
26 #define SAVE_PID
27 #endif
29 #ifndef RESTORE_PID
30 #define RESTORE_PID
31 #endif
34 /* int vfork() */
36         .text
37 LOCALSZ= 1
38 FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
39 GPOFF= FRAMESZ-(1*SZREG)
40 NESTED(__vfork,FRAMESZ,sp)
41 #ifdef __PIC__
42         SETUP_GP
43 #endif
44         PTR_SUBU sp, FRAMESZ
45         SETUP_GP64 (a5, __vfork)
46 #ifdef __PIC__
47         SAVE_GP (GPOFF)
48 #endif
49 #ifdef PROF
50 # if (_MIPS_SIM != _ABIO32)
51         PTR_S           a5, GPOFF(sp)
52 # endif
53         .set            noat
54         move            $1, ra
55 # if (_MIPS_SIM == _ABIO32)
56         subu            sp,sp,8
57 # endif
58         jal             _mcount
59         .set            at
60 # if (_MIPS_SIM != _ABIO32)
61         PTR_L           a5, GPOFF(sp)
62 # endif
63 #endif
65         PTR_ADDU        sp, FRAMESZ
67         SAVE_PID
69         li              a0, 0x4112      /* CLONE_VM | CLONE_VFORK | SIGCHLD */
70         move            a1, sp
72         /* Do the system call */
73         li              v0,__NR_clone
74         syscall
76         RESTORE_PID
78         bnez            a3,L(error)
80         /* Successful return from the parent or child.  */
81         RESTORE_GP64
82         ret
84         /* Something bad happened -- no child created.  */
85 L(error):
86 #ifdef __PIC__
87         PTR_LA          t9, __syscall_error
88         RESTORE_GP64
89         jr              t9
90 #else
91         RESTORE_GP64
92         j               __syscall_error
93 #endif
94         END(__vfork)
96 libc_hidden_def(__vfork)
97 weak_alias (__vfork, vfork)