X-Git-Url: https://rtime.felk.cvut.cz/gitweb/l4.git/blobdiff_plain/846ee6a4a27b3178b23b551e333750133da39d27..7d8b3f45f98773ba02057b81b90c31a12320c09e:/l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/clone.c diff --git a/l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/clone.c b/l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/clone.c index a47ee8c68..d92100865 100644 --- a/l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/clone.c +++ b/l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/microblaze/clone.c @@ -1,52 +1,47 @@ /* - * libc/sysdeps/linux/microblaze/clone.c -- `clone' syscall for linux/microblaze + * Copyright (C) 2004 Atmel Corporation * - * Copyright (C) 2003 John Williams - * Copyright (C) 2002,03 NEC Electronics Corporation - * Copyright (C) 2002,03 Miles Bader - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License. See the file COPYING.LIB in the main - * directory of this archive for more details. - * - * Written by Miles Bader - * Microblaze port by John Williams + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License. See the file "COPYING.LIB" in the main directory of this + * archive for more details. */ - +#include #include #include +#include -int -clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg) +int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg, ...) { - register unsigned long rval __asm__ (SYSCALL_RET) = -EINVAL; + int rval = -EINVAL; + if (fn && child_stack) + rval = INTERNAL_SYSCALL(clone, 0, 2, flags, child_stack); + + if (rval == 0) + { + int exitCode = fn(arg); + rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode); + } - if (fn && child_stack) - { - register unsigned long syscall __asm__ (SYSCALL_NUM); - register unsigned long arg0 __asm__ (SYSCALL_ARG0); - register unsigned long arg1 __asm__ (SYSCALL_ARG1); + return rval; +} - /* Clone this thread. */ - arg0 = flags; - arg1 = (unsigned long)child_stack; - syscall = __NR_clone; - __asm__ __volatile__ ("bralid r17, trap;nop;" - : "=r" (rval), "=r" (syscall) - : "1" (syscall), "r" (arg0), "r" (arg1) - : SYSCALL_CLOBBERS); +#ifdef __NR_clone2 +int +__clone2(int (*fn)(void *arg), void *child_stack, size_t stack_size, + int flags, void *arg, ...) +{ + int rval = -EINVAL; + if (fn && child_stack) + { + rval = INTERNAL_SYSCALL(clone2, 0, 3, flags, child_stack, stack_size); + } - if (rval == 0) - /* In child thread, call FN and exit. */ + if (rval == 0) { - arg0 = (*fn) (arg); - syscall = __NR_exit; - __asm__ __volatile__ ("bralid r17, trap;nop;" - : "=r" (rval), "=r" (syscall) - : "1" (syscall), "r" (arg0) - : SYSCALL_CLOBBERS); + int exitCode = fn(arg); + rval = INTERNAL_SYSCALL(exit, 0, 1, exitCode); } - } - __syscall_return (int, rval); + return rval; } +#endif