OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [microblaze/] [clone.c] - Blame information for rev 1325

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*
2
 * libc/sysdeps/linux/microblaze/clone.c -- `clone' syscall for linux/microblaze
3
 *
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>
7
 *
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.
11
 *
12
 * Written by Miles Bader <miles@gnu.org>
13
 * Microblaze port by John Williams
14
 */
15
 
16
#include <errno.h>
17
#include <sys/syscall.h>
18
 
19
int
20
clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
21
{
22
  register unsigned long rval asm (SYSCALL_RET) = -EINVAL;
23
 
24
  if (fn && child_stack)
25
    {
26
      register unsigned long syscall asm (SYSCALL_NUM);
27
      register unsigned long arg0 asm (SYSCALL_ARG0);
28
      register unsigned long arg1 asm (SYSCALL_ARG1);
29
 
30
      /* Clone this thread.  */
31
      arg0 = flags;
32
      arg1 = (unsigned long)child_stack;
33
      syscall = __NR_clone;
34
      asm volatile ("bralid r17, trap;nop;"
35
                    : "=r" (rval), "=r" (syscall)
36
                    : "1" (syscall), "r" (arg0), "r" (arg1)
37
                    : SYSCALL_CLOBBERS);
38
 
39
      if (rval == 0)
40
        /* In child thread, call FN and exit.  */
41
        {
42
          arg0 = (*fn) (arg);
43
          syscall = __NR_exit;
44
          asm volatile ("bralid r17, trap;nop;"
45
                        : "=r" (rval), "=r" (syscall)
46
                        : "1" (syscall), "r" (arg0)
47
                        : SYSCALL_CLOBBERS);
48
        }
49
    }
50
 
51
  __syscall_return (int, rval);
52
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.