xref: /original-bsd/lib/libc/vax/sys/Ovfork.s (revision c3e32dec)
1/*
2 * Copyright (c) 1983, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#if defined(SYSLIBC_SCCS) && !defined(lint)
9	.asciz "@(#)Ovfork.s	8.1 (Berkeley) 06/04/93"
10#endif /* SYSLIBC_SCCS and not lint */
11
12/*
13 * @(#)vfork.s	4.1 (Berkeley) 12/21/80
14 * C library -- vfork
15 */
16
17#include "SYS.h"
18
19/*
20 * pid = vfork();
21 *
22 * r1 == 0 in parent process, r1 == 1 in child process.
23 * r0 == pid of child in parent, r0 == pid of parent in child.
24 *
25 * trickery here, due to keith sklower, uses ret to clear the stack,
26 * and then returns with a jump indirect, since only one person can return
27 * with a ret off this stack... we do the ret before we vfork!
28 */
29
30ENTRY(vfork)
31	movl	16(fp),r2	# save return address before we smash it
32	movab	here,16(fp)
33	ret
34here:
35	chmk	$SYS_vfork
36	bcs	err		# if failed, set errno and return -1
37	/* this next trick is Chris Torek's fault */
38	mnegl	r1,r1		# r1 = 0xffffffff if child, 0 if parent
39	bicl2	r1,r0		# r0 &= ~r1, i.e., 0 if child, else unchanged
40	jmp	(r2)
41
42err:
43	movl	r0,_errno
44	mnegl	$1,r0
45	jmp	(r2)
46