2 * libc/sysdeps/linux/v850/clone.c -- `clone' syscall for linux/v850
4 * Copyright (C) 2002,03 NEC Electronics Corporation
5 * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
7 * This file is subject to the terms and conditions of the GNU Lesser
8 * General Public License. See the file COPYING.LIB in the main
9 * directory of this archive for more details.
11 * Written by Miles Bader <miles@gnu.org>
15 #include <sys/syscall.h>
18 clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
20 register unsigned long rval __asm__ (SYSCALL_RET) = -EINVAL;
22 if (fn && child_stack)
24 register unsigned long syscall __asm__ (SYSCALL_NUM);
25 register unsigned long arg0 __asm__ (SYSCALL_ARG0);
26 register unsigned long arg1 __asm__ (SYSCALL_ARG1);
28 /* Clone this thread. */
30 arg1 = (unsigned long)child_stack;
32 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP
33 : "=r" (rval), "=r" (syscall)
34 : "1" (syscall), "r" (arg0), "r" (arg1)
35 : SYSCALL_SHORT_CLOBBERS);
38 /* In child thread, call FN and exit. */
42 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP
43 : "=r" (rval), "=r" (syscall)
44 : "1" (syscall), "r" (arg0)
45 : SYSCALL_SHORT_CLOBBERS);
49 __syscall_return (int, rval);