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