xref: /original-bsd/lib/libc/vax/sys/Ovfork.s (revision be29bfce)
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.4 (Berkeley) 05/20/88"
15#endif /* SYSLIBC_SCCS and not lint */
16
17/*
18 * @(#)vfork.s	4.1 (Berkeley) 12/21/80
19 * C library -- vfork
20 */
21
22/*
23 * pid = vfork();
24 *
25 * r1 == 0 in parent process, r1 == 1 in child process.
26 * r0 == pid of child in parent, r0 == pid of parent in child.
27 *
28 * trickery here, due to keith sklower, uses ret to clear the stack,
29 * and then returns with a jump indirect, since only one person can return
30 * with a ret off this stack... we do the ret before we vfork!
31 */
32
33	.set	vfork,66
34.globl	_vfork
35
36_vfork:
37	.word	0x0000
38	movl	16(fp),r2
39	movab	here,16(fp)
40	ret
41here:
42	chmk	$vfork
43	bcc	vforkok
44	jmp	verror
45vforkok:
46	tstl	r1		# child process ?
47	bneq	child	# yes
48	bcc 	parent		# if c-bit not set, fork ok
49.globl	_errno
50verror:
51	movl	r0,_errno
52	mnegl	$1,r0
53	jmp	(r2)
54child:
55	clrl	r0
56parent:
57	jmp	(r2)
58