xref: /csrg-svn/lib/libc/vax/sys/Ovfork.s (revision 21542)
19426Smckusick/*
2*21542Sdist * Copyright (c) 1983 Regents of the University of California.
3*21542Sdist * All rights reserved.  The Berkeley software License Agreement
4*21542Sdist * specifies the terms and conditions for redistribution.
5*21542Sdist */
6*21542Sdist
7*21542Sdist#ifndef lint
8*21542Sdiststatic char sccsid[] = "@(#)Ovfork.s	5.1 (Berkeley) 05/31/85";
9*21542Sdist#endif not lint
10*21542Sdist
11*21542Sdist/*
129426Smckusick * @(#)vfork.s	4.1 (Berkeley) 12/21/80
139426Smckusick * C library -- vfork
149426Smckusick */
159426Smckusick
169426Smckusick/*
179426Smckusick * pid = vfork();
189426Smckusick *
199426Smckusick * r1 == 0 in parent process, r1 == 1 in child process.
209426Smckusick * r0 == pid of child in parent, r0 == pid of parent in child.
219426Smckusick *
229426Smckusick * trickery here, due to keith sklower, uses ret to clear the stack,
239426Smckusick * and then returns with a jump indirect, since only one person can return
249426Smckusick * with a ret off this stack... we do the ret before we vfork!
259426Smckusick */
269426Smckusick
279426Smckusick	.set	vfork,66
289426Smckusick.globl	_vfork
299426Smckusick
309426Smckusick_vfork:
319426Smckusick	.word	0x0000
329426Smckusick	movl	16(fp),r2
339426Smckusick	movab	here,16(fp)
349426Smckusick	ret
359426Smckusickhere:
369426Smckusick	chmk	$vfork
379426Smckusick	bcc	vforkok
389426Smckusick	jmp	verror
399426Smckusickvforkok:
409426Smckusick	tstl	r1		# child process ?
419426Smckusick	bneq	child	# yes
429426Smckusick	bcc 	parent		# if c-bit not set, fork ok
439426Smckusick.globl	_errno
449426Smckusickverror:
459426Smckusick	movl	r0,_errno
469426Smckusick	mnegl	$1,r0
479426Smckusick	jmp	(r2)
489426Smckusickchild:
499426Smckusick	clrl	r0
509426Smckusickparent:
519426Smckusick	jmp	(r2)
52