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#ifdef __NR_vfork
12#define __VFORK_NR __NR_vfork
13#else
14#define __VFORK_NR __NR_fork
15#endif
16
17/* Clone the calling process, but without copying the whole address space.
18   The calling process is suspended until the new process exits or is
19   replaced by a call to `execve'.  Return -1 for errors, 0 to the new process,
20   and the process ID of the new process to the old process.  */
21
22	.balign 4
23	.global	___vfork
24	.hidden	___vfork
25	.type	___vfork, @function
26___vfork:
27
28	MOV	D1Ar1, #0x4111	/* CLONE_VM | CLONE_VFORK | SIGCHLD */
29	MOV	D0Ar2, #0
30	MOV	D1Ar3, #0
31	MOV	D0Ar4, #0
32	MOV	D1Ar5, #0
33	MOV	D0Ar6, #0
34	MOV	D1Re0, #__NR_clone
35	SWITCH  #0x440001
36
37	MOVT	D1Re0, #HI(-4096)
38	ADD	D1Re0, D1Re0, #LO(-4096)
39	CMP	D1Re0, D0Re0
40	BCS	error
41
42	/* Syscall worked. Return to child/parent */
43	MOV	PC, D1RtP
44
45error:
46	MOV	D1Ar1, D0Re0
47#ifdef __PIC__
48	B	___syscall_error@PLT
49#else
50	B	___syscall_error
51#endif
52	.size ___vfork,.-___vfork
53
54weak_alias(__vfork,vfork)
55libc_hidden_weak(vfork)
56