xref: /csrg-svn/lib/libc/vax/sys/cache.lib/Ovfork.c (revision 47911)
1*47911Sbostic /*
2*47911Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*47911Sbostic  * All rights reserved.
4*47911Sbostic  *
5*47911Sbostic  * Redistribution and use in source and binary forms are permitted
6*47911Sbostic  * provided that the above copyright notice and this paragraph are
7*47911Sbostic  * duplicated in all such forms and that any documentation,
8*47911Sbostic  * advertising materials, and other materials related to such
9*47911Sbostic  * distribution and use acknowledge that the software was developed
10*47911Sbostic  * by the University of California, Berkeley.  The name of the
11*47911Sbostic  * University may not be used to endorse or promote products derived
12*47911Sbostic  * from this software without specific prior written permission.
13*47911Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*47911Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*47911Sbostic  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*47911Sbostic  */
17*47911Sbostic 
18*47911Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*47911Sbostic 	.asciz "@(#)Ovfork.c	5.1 (Berkeley) 04/12/91"
20*47911Sbostic #endif /* LIBC_SCCS and not lint */
21*47911Sbostic 
22*47911Sbostic /*
23*47911Sbostic  * @(#)vfork.s	4.1 (Berkeley) 12/21/80
24*47911Sbostic  * C library -- vfork
25*47911Sbostic  */
26*47911Sbostic 
27*47911Sbostic /*
28*47911Sbostic  * pid = vfork();
29*47911Sbostic  *
30*47911Sbostic  * r1 == 0 in parent process, r1 == 1 in child process.
31*47911Sbostic  * r0 == pid of child in parent, r0 == pid of parent in child.
32*47911Sbostic  *
33*47911Sbostic  * trickery here, due to keith sklower, uses ret to clear the stack,
34*47911Sbostic  * and then returns with a jump indirect, since only one person can return
35*47911Sbostic  * with a ret off this stack... we do the ret before we vfork!
36*47911Sbostic  */
37*47911Sbostic 
38*47911Sbostic 	.set	vfork,66
39*47911Sbostic 	.globl	_vfork
40*47911Sbostic 	.globl	mypid, myppid
41*47911Sbostic 
42*47911Sbostic _vfork:
43*47911Sbostic 	.word	0x0000
44*47911Sbostic 	movl	16(fp),r2
45*47911Sbostic 	movab	here,16(fp)
46*47911Sbostic 	ret
47*47911Sbostic here:
48*47911Sbostic 	chmk	$vfork
49*47911Sbostic 	bcc	vforkok
50*47911Sbostic 	jmp	verror
51*47911Sbostic vforkok:
52*47911Sbostic 	tstl	r1		# child process ?
53*47911Sbostic 	bneq	child	# yes
54*47911Sbostic 	bcc 	parent		# if c-bit not set, fork ok
55*47911Sbostic .globl	_errno
56*47911Sbostic verror:
57*47911Sbostic 	movl	r0,_errno
58*47911Sbostic 	mnegl	$1,r0
59*47911Sbostic 	jmp	(r2)
60*47911Sbostic child:
61*47911Sbostic 	movl	r0,myppid
62*47911Sbostic 	clrl	r0
63*47911Sbostic 	clrl	mypid
64*47911Sbostic parent:
65*47911Sbostic 	jmp	(r2)
66