xref: /original-bsd/lib/libc/tahoe/sys/Ovfork.s (revision 5d3a6356)
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific written prior permission. This software
10 * is provided ``as is'' without express or implied warranty.
11 */
12
13#if defined(SYSLIBC_SCCS) && !defined(lint)
14_sccsid:.asciz	"@(#)Ovfork.s	5.2 (Berkeley) 05/20/88"
15#endif /* SYSLIBC_SCCS and not lint */
16
17/*
18 * C library -- vfork
19 * pid = vfork();
20 *
21 * r1 == 0 in parent process, r1 == 1 in child process.
22 * r0 == pid of child in parent, r0 == pid of parent in child.
23 *
24 * trickery here, due to keith sklower, uses ret to clear the stack,
25 * and then returns with a jump indirect, since only one person can return
26 * with a ret off this stack... we do the ret before we vfork!
27 *
28 */
29
30	.set	vfork,66
31.globl	_vfork
32
33_vfork:
34	.word	0x0000
35	movl	-8(fp),r2
36	movab	here,-8(fp)
37	ret
38here:
39	kcall	$vfork
40	bcc	vforkok
41	jmp	verror
42vforkok:
43	tstl	r1		# child process ?
44	bneq	child	# yes
45	jbr 	parent
46.globl	_errno
47verror:
48	movl	r0,_errno
49	mnegl	$1,r0
50	jmp	(r2)
51child:
52	clrl	r0
53parent:
54	jmp	(r2)
55