xref: /original-bsd/lib/libc/tahoe/sys/Ovfork.s (revision 8f26171a)
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.  The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 */
6
7#ifdef SYSLIBC_SCCS
8_sccsid:.asciz	"@(#)Ovfork.s	5.1 (Berkeley) 07/02/86"
9#endif SYSLIBC_SCCS
10
11/*
12 * C library -- vfork
13 * pid = vfork();
14 *
15 * r1 == 0 in parent process, r1 == 1 in child process.
16 * r0 == pid of child in parent, r0 == pid of parent in child.
17 *
18 * trickery here, due to keith sklower, uses ret to clear the stack,
19 * and then returns with a jump indirect, since only one person can return
20 * with a ret off this stack... we do the ret before we vfork!
21 *
22 */
23
24	.set	vfork,66
25.globl	_vfork
26
27_vfork:
28	.word	0x0000
29	movl	-8(fp),r2
30	movab	here,-8(fp)
31	ret
32here:
33	kcall	$vfork
34	bcc	vforkok
35	jmp	verror
36vforkok:
37	tstl	r1		# child process ?
38	bneq	child	# yes
39	jbr 	parent
40.globl	_errno
41verror:
42	movl	r0,_errno
43	mnegl	$1,r0
44	jmp	(r2)
45child:
46	clrl	r0
47parent:
48	jmp	(r2)
49