]>
Commit | Line | Data |
---|---|---|
63d143a2 CM |
1 | /* Copyright (C) 2011 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. | |
3 | Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
16 | License along with the GNU C Library. If not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
63d143a2 CM |
18 | |
19 | #include <sysdep.h> | |
20 | #define __ASSEMBLY__ /* for kernel headers */ | |
21 | #include <linux/sched.h> | |
22 | #include <asm/signal.h> | |
23 | #include <tcb-offsets.h> | |
24 | ||
25 | /* Clone the calling process, but without copying the whole address space. | |
26 | The calling process is suspended until the new process exits or is | |
27 | replaced by a call to `execve'. Return -1 for errors, 0 to the new process, | |
28 | and the process ID of the new process to the old process. */ | |
29 | ||
30 | .text | |
31 | ENTRY (__vfork) | |
32 | { | |
33 | addli r11, tp, PID_OFFSET /* Point at PID. */ | |
34 | movei r13, 1 | |
35 | } | |
36 | { | |
37 | LD4U r12, r11 /* Load the saved PID. */ | |
38 | shli r13, r13, 31 /* Build 0x80000000. */ | |
39 | } | |
40 | sub r12, zero, r12 /* Negate it. */ | |
41 | #ifndef PT_VFORK | |
42 | CMOVEQZ r12, r12, r13 /* Replace zero pids. */ | |
43 | #endif | |
44 | ST4 r11, r12 /* Store the temporary PID. */ | |
45 | ||
46 | { | |
47 | moveli r0, CLONE_VFORK | CLONE_VM | SIGCHLD | |
48 | move r1, zero | |
49 | } | |
50 | { | |
51 | move r2, zero | |
52 | move r3, zero | |
53 | } | |
54 | moveli TREG_SYSCALL_NR_NAME, __NR_clone | |
55 | swint1 | |
56 | ||
57 | BEQZ r0, 1f /* If we are the parent... */ | |
58 | { | |
59 | addli r11, tp, PID_OFFSET /* Point at PID. */ | |
60 | movei r13, 1 | |
61 | } | |
62 | { | |
63 | LD4U r12, r11 /* Load the saved PID. */ | |
64 | shli r13, r13, 31 /* Build 0x80000000. */ | |
65 | } | |
66 | { | |
67 | CMPEQ r13, r12, r12 /* Test for that value. */ | |
68 | sub r12, zero, r12 /* Re-negate it. */ | |
69 | } | |
70 | #ifndef PT_VFORK | |
71 | CMOVNEZ r12, r13, zero /* Replace zero pids. */ | |
72 | #endif | |
73 | ST4 r11, r12 /* Restore the PID. */ | |
74 | 1: | |
75 | BNEZ r1, 0f | |
76 | jrp lr | |
77 | PSEUDO_END (__vfork) | |
78 | libc_hidden_def (__vfork) | |
79 | ||
80 | weak_alias (__vfork, vfork) |