2 * libc/sysdeps/linux/microblaze/clone.c -- `clone' syscall for linux/microblaze
4 * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
5 * Copyright (C) 2002,03 NEC Electronics Corporation
6 * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
8 * This file is subject to the terms and conditions of the GNU Lesser
9 * General Public License. See the file COPYING.LIB in the main
10 * directory of this archive for more details.
12 * Written by Miles Bader <miles@gnu.org>
13 * Microblaze port by John Williams
17 #include <sys/syscall.h>
20 clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
22 register unsigned long rval __asm__ (SYSCALL_RET) = -EINVAL;
24 if (fn && child_stack)
26 register unsigned long syscall __asm__ (SYSCALL_NUM);
27 register unsigned long arg0 __asm__ (SYSCALL_ARG0);
28 register unsigned long arg1 __asm__ (SYSCALL_ARG1);
30 /* Clone this thread. */
32 arg1 = (unsigned long)child_stack;
34 __asm__ __volatile__ ("bralid r17, trap;nop;"
35 : "=r" (rval), "=r" (syscall)
36 : "1" (syscall), "r" (arg0), "r" (arg1)
40 /* In child thread, call FN and exit. */
44 __asm__ __volatile__ ("bralid r17, trap;nop;"
45 : "=r" (rval), "=r" (syscall)
46 : "1" (syscall), "r" (arg0)
51 __syscall_return (int, rval);