fstatat: add wrapper that uses statx for non-legacy arch
[uclibc-ng.git] / libc / sysdeps / linux / avr32 / clone.c
blob06e3388b86a9011925e48b2a55e5f2bc9341dd6e
1 /*
2 * Copyright (C) 2004 Atmel Corporation
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>
14 * I don't know if we can be absolutely certain that the fn and arg
15 * parameters are preserved when returning as the child. If the
16 * compiler stores them in registers (r0-r7), they should be.
18 int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...)
20 register int (*_fn)(void *arg) = fn;
21 register void *_arg = arg;
22 int err;
24 /* Sanity check the arguments */
25 err = -EINVAL;
26 if (!fn)
27 goto syscall_error;
28 if (!child_stack)
29 goto syscall_error;
31 err = INLINE_SYSCALL(clone, 2, flags, child_stack);
32 if (err < 0)
33 goto syscall_error;
34 else if (err != 0)
35 return err;
37 _exit(_fn(_arg));
39 syscall_error:
40 __set_errno (-err);
41 return -1;