]>
Commit | Line | Data |
---|---|---|
de96d148 | 1 | /* Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc. |
74804c97 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Philip Blundell <philb@gnu.org>. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
3214b89b AJ |
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. | |
74804c97 UD |
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 | |
3214b89b | 13 | Lesser General Public License for more details. |
74804c97 | 14 | |
3214b89b | 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/>. */ | |
74804c97 UD |
18 | |
19 | #include <sysdep.h> | |
20 | #define _ERRNO_H 1 | |
21 | #include <bits/errno.h> | |
227de9dd | 22 | #include <kernel-features.h> |
74804c97 UD |
23 | |
24 | /* Clone the calling process, but without copying the whole address space. | |
25 | The calling process is suspended until the new process exits or is | |
26 | replaced by a call to `execve'. Return -1 for errors, 0 to the new process, | |
27 | and the process ID of the new process to the old process. */ | |
28 | ||
29 | ENTRY (__vfork) | |
30 | ||
31 | #ifdef __NR_vfork | |
02a9f771 DJ |
32 | #ifdef SAVE_PID |
33 | SAVE_PID | |
34 | #endif | |
73886008 UW |
35 | #ifdef __ARM_EABI__ |
36 | /* The DO_CALL macro saves r7 on the stack, to enable generation | |
37 | of ARM unwind info. Since the stack is initially shared between | |
38 | parent and child of vfork, that saved value could be corrupted. | |
39 | To avoid this problem, we save r7 into ip as well, and restore | |
40 | from there. */ | |
41 | mov ip, r7 | |
42 | cfi_register (r7, ip) | |
43 | .fnstart | |
44 | str r7, [sp, #-4]! | |
45 | cfi_adjust_cfa_offset (4) | |
46 | .save { r7 } | |
47 | ldr r7, =SYS_ify (vfork) | |
48 | swi 0x0 | |
49 | .fnend | |
50 | add sp, sp, #4 | |
51 | cfi_adjust_cfa_offset (-4) | |
52 | mov r7, ip | |
53 | cfi_restore (r7); | |
54 | #else | |
55 | swi SYS_ify(vfork) | |
56 | #endif | |
02a9f771 DJ |
57 | #ifdef RESTORE_PID |
58 | RESTORE_PID | |
59 | #endif | |
74804c97 | 60 | cmn a1, #4096 |
47f0752a | 61 | RETINSTR(cc, lr) |
74804c97 | 62 | |
227de9dd | 63 | # ifdef __ASSUME_VFORK_SYSCALL |
02a9f771 | 64 | b PLTJMP(SYSCALL_ERROR) |
227de9dd | 65 | # else |
74804c97 | 66 | /* Check if vfork syscall is known at all. */ |
02a9f771 DJ |
67 | cmn a1, #ENOSYS |
68 | bne PLTJMP(SYSCALL_ERROR) | |
227de9dd | 69 | # endif |
74804c97 UD |
70 | #endif |
71 | ||
227de9dd | 72 | #ifndef __ASSUME_VFORK_SYSCALL |
74804c97 | 73 | /* If we don't have vfork, fork is close enough. */ |
de96d148 | 74 | DO_CALL (fork, 0) |
74804c97 | 75 | cmn a1, #4096 |
47f0752a | 76 | RETINSTR(cc, lr) |
02a9f771 | 77 | b PLTJMP(SYSCALL_ERROR) |
011f9a85 UD |
78 | #elif !defined __NR_vfork |
79 | # error "__NR_vfork not available and __ASSUME_VFORK_SYSCALL defined" | |
227de9dd | 80 | #endif |
c505de0a | 81 | |
74804c97 | 82 | PSEUDO_END (__vfork) |
db160231 | 83 | libc_hidden_def (__vfork) |
74804c97 UD |
84 | |
85 | weak_alias (__vfork, vfork) |