]>
Commit | Line | Data |
---|---|---|
568035b7 | 1 | /* Copyright (C) 2005-2013 Free Software Foundation, Inc. |
4abf7dea AJ |
2 | This file is part of the GNU C Library. |
3 | ||
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. | |
8 | ||
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. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
15 | License along with the GNU C Library. If not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
4abf7dea AJ |
17 | |
18 | /* vfork() is just a special case of clone(). */ | |
19 | ||
20 | #include <sys/asm.h> | |
21 | #include <sysdep.h> | |
22 | #include <asm/unistd.h> | |
23 | #include <sgidefs.h> | |
24 | ||
25 | #ifndef SAVE_PID | |
26 | #define SAVE_PID | |
27 | #endif | |
28 | ||
29 | #ifndef RESTORE_PID | |
30 | #define RESTORE_PID | |
31 | #endif | |
32 | ||
33 | ||
34 | /* int vfork() */ | |
35 | ||
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 | |
aea7a9b9 JM |
45 | cfi_adjust_cfa_offset (FRAMESZ) |
46 | SETUP_GP64_REG (a5, __vfork) | |
4abf7dea AJ |
47 | #ifdef __PIC__ |
48 | SAVE_GP (GPOFF) | |
49 | #endif | |
50 | #ifdef PROF | |
51 | # if (_MIPS_SIM != _ABIO32) | |
52 | PTR_S a5, GPOFF(sp) | |
53 | # endif | |
54 | .set noat | |
55 | move $1, ra | |
56 | # if (_MIPS_SIM == _ABIO32) | |
57 | subu sp,sp,8 | |
58 | # endif | |
59 | jal _mcount | |
60 | .set at | |
61 | # if (_MIPS_SIM != _ABIO32) | |
62 | PTR_L a5, GPOFF(sp) | |
63 | # endif | |
64 | #endif | |
65 | ||
66 | PTR_ADDU sp, FRAMESZ | |
aea7a9b9 | 67 | cfi_adjust_cfa_offset (-FRAMESZ) |
4abf7dea AJ |
68 | |
69 | SAVE_PID | |
70 | ||
71 | li a0, 0x4112 /* CLONE_VM | CLONE_VFORK | SIGCHLD */ | |
72 | move a1, sp | |
73 | ||
74 | /* Do the system call */ | |
75 | li v0,__NR_clone | |
76 | syscall | |
77 | ||
78 | RESTORE_PID | |
79 | ||
aea7a9b9 | 80 | cfi_remember_state |
4abf7dea AJ |
81 | bnez a3,L(error) |
82 | ||
83 | /* Successful return from the parent or child. */ | |
aea7a9b9 | 84 | RESTORE_GP64_REG |
4abf7dea AJ |
85 | ret |
86 | ||
87 | /* Something bad happened -- no child created. */ | |
88 | L(error): | |
aea7a9b9 | 89 | cfi_restore_state |
4abf7dea AJ |
90 | #ifdef __PIC__ |
91 | PTR_LA t9, __syscall_error | |
aea7a9b9 | 92 | RESTORE_GP64_REG |
4abf7dea AJ |
93 | jr t9 |
94 | #else | |
aea7a9b9 | 95 | RESTORE_GP64_REG |
4abf7dea AJ |
96 | j __syscall_error |
97 | #endif | |
98 | END(__vfork) | |
99 | ||
100 | libc_hidden_def(__vfork) | |
8796ce21 | 101 | weak_alias (__vfork, vfork) |