]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/mips/vfork.S
Replace FSF snail mail address by URL.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / mips / vfork.S
CommitLineData
4abf7dea
AJ
1/* Copyright (C) 2005 Free Software Foundation, Inc.
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
37LOCALSZ= 1
38FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK
39GPOFF= FRAMESZ-(1*SZREG)
40NESTED(__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
64
65 PTR_ADDU sp, FRAMESZ
66
67 SAVE_PID
68
69 li a0, 0x4112 /* CLONE_VM | CLONE_VFORK | SIGCHLD */
70 move a1, sp
71
72 /* Do the system call */
73 li v0,__NR_clone
74 syscall
75
76 RESTORE_PID
77
78 bnez a3,L(error)
79
80 /* Successful return from the parent or child. */
81 RESTORE_GP64
82 ret
83
84 /* Something bad happened -- no child created. */
85L(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)
95
96libc_hidden_def(__vfork)
8796ce21 97weak_alias (__vfork, vfork)