xref: /csrg-svn/lib/libc/tahoe/sys/Ovfork.s (revision 61190)
129441Ssam/*
2*61190Sbostic * Copyright (c) 1983, 1993
3*61190Sbostic *	The Regents of the University of California.  All rights reserved.
434389Sbostic *
542648Sbostic * %sccs.include.redist.c%
629441Ssam */
729441Ssam
834389Sbostic#if defined(SYSLIBC_SCCS) && !defined(lint)
9*61190Sbostic	.asciz "@(#)Ovfork.s	8.1 (Berkeley) 06/04/93"
1034389Sbostic#endif /* SYSLIBC_SCCS and not lint */
1129441Ssam
1229441Ssam/*
1329441Ssam * C library -- vfork
1429441Ssam * pid = vfork();
1529441Ssam *
1629441Ssam * r1 == 0 in parent process, r1 == 1 in child process.
1729441Ssam * r0 == pid of child in parent, r0 == pid of parent in child.
1829441Ssam *
1929441Ssam * trickery here, due to keith sklower, uses ret to clear the stack,
2029441Ssam * and then returns with a jump indirect, since only one person can return
2129441Ssam * with a ret off this stack... we do the ret before we vfork!
2229441Ssam *
2329441Ssam */
2429441Ssam
2529441Ssam	.set	vfork,66
2629441Ssam.globl	_vfork
2729441Ssam
2829441Ssam_vfork:
2929441Ssam	.word	0x0000
3029441Ssam	movl	-8(fp),r2
3129441Ssam	movab	here,-8(fp)
3229441Ssam	ret
3329441Ssamhere:
3429441Ssam	kcall	$vfork
3529441Ssam	bcc	vforkok
3629441Ssam	jmp	verror
3729441Ssamvforkok:
3829441Ssam	tstl	r1		# child process ?
3929441Ssam	bneq	child	# yes
4029441Ssam	jbr 	parent
4129441Ssam.globl	_errno
4229441Ssamverror:
4329441Ssam	movl	r0,_errno
4429441Ssam	mnegl	$1,r0
4529441Ssam	jmp	(r2)
4629441Ssamchild:
4729441Ssam	clrl	r0
4829441Ssamparent:
4929441Ssam	jmp	(r2)
50