]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/metag/vfork.S
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / metag / vfork.S
1 !    Copyright (C) 2013 Imagination Technologies Ltd.
2
3 !    Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
4
5 #include <asm/unistd.h>
6
7 #define _ERRNO_H
8 #include <bits/errno.h>
9 #include <sys/syscall.h>
10
11 #ifndef SAVE_PID
12 #define SAVE_PID
13 #endif
14
15 #ifndef RESTORE_PID
16 #define RESTORE_PID
17 #endif
18
19 #ifdef __NR_vfork
20 #define __VFORK_NR __NR_vfork
21 #else
22 #define __VFORK_NR __NR_fork
23 #endif
24
25 /* Clone the calling process, but without copying the whole address space.
26    The calling process is suspended until the new process exits or is
27    replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
28    and the process ID of the new process to the old process.  */
29
30         .balign 4
31         .global ___vfork
32         .hidden ___vfork
33         .type   ___vfork, @function
34 ___vfork:
35
36         SAVE_PID
37
38         MOV     D1Ar1, #0x4111  /* CLONE_VM | CLONE_VFORK | SIGCHLD */
39         MOV     D0Ar2, #0
40         MOV     D1Ar3, #0
41         MOV     D0Ar4, #0
42         MOV     D1Ar5, #0
43         MOV     D0Ar6, #0
44         MOV     D1Re0, #__NR_clone
45         SWITCH  #0x440001
46
47         RESTORE_PID
48
49         MOVT    D1Re0, #HI(-4096)
50         ADD     D1Re0, D1Re0, #LO(-4096)
51         CMP     D1Re0, D0Re0
52         BCS     error
53
54         /* Syscall worked. Return to child/parent */
55         MOV     PC, D1RtP
56
57 error:
58         MOV     D1Ar1, D0Re0
59 #ifdef __PIC__
60         B       ___syscall_error@PLT
61 #else
62         B       ___syscall_error
63 #endif
64         .size ___vfork,.-___vfork
65
66 weak_alias(__vfork,vfork)
67 libc_hidden_weak(vfork)