xref: /csrg-svn/lib/libc/vax/sys/Ovfork.s (revision 9426)
1*9426Smckusick/*
2*9426Smckusick * @(#)vfork.s	4.1 (Berkeley) 12/21/80
3*9426Smckusick * C library -- vfork
4*9426Smckusick */
5*9426Smckusick
6*9426Smckusick/*
7*9426Smckusick * pid = vfork();
8*9426Smckusick *
9*9426Smckusick * r1 == 0 in parent process, r1 == 1 in child process.
10*9426Smckusick * r0 == pid of child in parent, r0 == pid of parent in child.
11*9426Smckusick *
12*9426Smckusick * trickery here, due to keith sklower, uses ret to clear the stack,
13*9426Smckusick * and then returns with a jump indirect, since only one person can return
14*9426Smckusick * with a ret off this stack... we do the ret before we vfork!
15*9426Smckusick */
16*9426Smckusick
17*9426Smckusick	.set	vfork,66
18*9426Smckusick.globl	_vfork
19*9426Smckusick
20*9426Smckusick_vfork:
21*9426Smckusick	.word	0x0000
22*9426Smckusick	movl	16(fp),r2
23*9426Smckusick	movab	here,16(fp)
24*9426Smckusick	ret
25*9426Smckusickhere:
26*9426Smckusick	chmk	$vfork
27*9426Smckusick	bcc	vforkok
28*9426Smckusick	jmp	verror
29*9426Smckusickvforkok:
30*9426Smckusick	tstl	r1		# child process ?
31*9426Smckusick	bneq	child	# yes
32*9426Smckusick	bcc 	parent		# if c-bit not set, fork ok
33*9426Smckusick.globl	_errno
34*9426Smckusickverror:
35*9426Smckusick	movl	r0,_errno
36*9426Smckusick	mnegl	$1,r0
37*9426Smckusick	jmp	(r2)
38*9426Smckusickchild:
39*9426Smckusick	clrl	r0
40*9426Smckusickparent:
41*9426Smckusick	jmp	(r2)
42