BSD 4_4 release
[unix-history] / usr / src / lib / libc / vax / sys / cache.lib / Ovfork.c
CommitLineData
a4fc57ac 1/*-
7217fa4b
KB
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
ffed8673 4 *
c0567266
KB
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
ffed8673
KB
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
ad787160 35 .asciz "@(#)Ovfork.c 8.1 (Berkeley) 6/4/93"
ffed8673
KB
36#endif /* LIBC_SCCS and not lint */
37
38/*
39 * @(#)vfork.s 4.1 (Berkeley) 12/21/80
40 * C library -- vfork
41 */
42
43/*
44 * pid = vfork();
45 *
46 * r1 == 0 in parent process, r1 == 1 in child process.
47 * r0 == pid of child in parent, r0 == pid of parent in child.
48 *
49 * trickery here, due to keith sklower, uses ret to clear the stack,
50 * and then returns with a jump indirect, since only one person can return
51 * with a ret off this stack... we do the ret before we vfork!
52 */
53
54 .set vfork,66
55 .globl _vfork
56 .globl mypid, myppid
57
58_vfork:
59 .word 0x0000
60 movl 16(fp),r2
61 movab here,16(fp)
62 ret
63here:
64 chmk $vfork
65 bcc vforkok
66 jmp verror
67vforkok:
68 tstl r1 # child process ?
69 bneq child # yes
70 bcc parent # if c-bit not set, fork ok
71.globl _errno
72verror:
73 movl r0,_errno
74 mnegl $1,r0
75 jmp (r2)
76child:
77 movl r0,myppid
78 clrl r0
79 clrl mypid
80parent:
81 jmp (r2)