]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/clone.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / microblaze / clone.c
1 /*
2  * Copyright (C) 2004 Atmel Corporation
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License.  See the file "COPYING.LIB" in the main directory of this
6  * archive for more details.
7  */
8 #include <sched.h>
9 #include <errno.h>
10 #include <sys/syscall.h>
11 #include <unistd.h>
12
13 int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
14 {
15         int rval = -EINVAL;
16         if (fn && child_stack)
17                 rval = INTERNAL_SYSCALL(clone, 0, 2, flags, child_stack);
18
19         if (rval == 0)
20         {
21                 int exitCode = fn(arg);
22                 rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode);
23         }
24
25         return rval;
26 }
27
28 #ifdef __NR_clone2
29 int
30 __clone2(int (*fn)(void *arg), void *child_stack, size_t stack_size,
31          int flags, void *arg, ...)
32 {
33         int rval = -EINVAL;
34         if (fn && child_stack)
35         {
36                 rval = INTERNAL_SYSCALL(clone2, 0, 3, flags, child_stack, stack_size);
37         }
38
39         if (rval == 0)
40         {
41                 int exitCode = fn(arg);
42                 rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode);
43         }
44
45         return rval;
46 }
47 #endif