	.file "vfork.s"
/* $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
# Sequent Computer Systems, Inc.   All rights reserved.
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.
 */

	.ident	"$Header: vfork.s 1.1 89/03/08 $"

/ C library -- vfork

/ pid = vfork()
/	%ecx == 0 in parent, == 1 in child
/	%eax == pid of child in parent, == pid of parent in child
/
/ Since only one process can do a ret off this stack, save return
/ address in %edx before doing syscall and jump indirect when done!
/
/ Assumes %edx is saved/restored across syscall

#include "sys.s"
#include "sysseq.s"

	.globl vfork
	.text
	.align 4
vfork:
	popl	%edx			/ return PC
	SVC(0,vfork)
	jc	err

	testl	%ecx, %ecx		/ is parent ?
	jz	parent
	xorl	%eax, %eax		/ child returns 0
parent:
	jmp	*%edx
err:
	movl	%eax, errno
	movl	$-1, %eax
	jmp	*%edx
