]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/vfork.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / vfork.c
1 /*
2  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
3  *
4  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5  */
6
7 #include <sys/syscall.h>
8
9 #if (defined __NR_vfork || defined __NR_clone || (defined __ARCH_USE_MMU__ && defined __NR_fork)) && (defined __USE_BSD || defined __USE_XOPEN_EXTENDED)
10 # include <unistd.h>
11 extern __typeof(vfork) __vfork attribute_hidden;
12
13 # if defined __NR_clone && !defined __NR_vfork
14 # include <signal.h>
15 # include <sys/types.h>
16
17 pid_t __vfork(void)
18 {
19         pid_t pid = INLINE_SYSCALL(clone, 4, SIGCHLD,
20                                    NULL, NULL, NULL);
21
22         if (pid < 0)
23                 return -1;
24
25         return pid;
26 }
27
28 # elif defined __NR_vfork
29 #  define __NR___vfork __NR_vfork
30 _syscall0(pid_t, __vfork)
31 # else
32 /* Trivial implementation for arches that lack vfork */
33 pid_t __vfork(void)
34 {
35     return fork();
36 }
37 # endif
38 strong_alias(__vfork,vfork)
39 libc_hidden_weak(vfork)
40 #endif