1 /*- 2 * Copyright (c) 1983 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 .asciz "@(#)Ovfork.c 5.2 (Berkeley) 04/12/91" 10 #endif /* LIBC_SCCS and not lint */ 11 12 /* 13 * @(#)vfork.s 4.1 (Berkeley) 12/21/80 14 * C library -- vfork 15 */ 16 17 /* 18 * pid = vfork(); 19 * 20 * r1 == 0 in parent process, r1 == 1 in child process. 21 * r0 == pid of child in parent, r0 == pid of parent in child. 22 * 23 * trickery here, due to keith sklower, uses ret to clear the stack, 24 * and then returns with a jump indirect, since only one person can return 25 * with a ret off this stack... we do the ret before we vfork! 26 */ 27 28 .set vfork,66 29 .globl _vfork 30 .globl mypid, myppid 31 32 _vfork: 33 .word 0x0000 34 movl 16(fp),r2 35 movab here,16(fp) 36 ret 37 here: 38 chmk $vfork 39 bcc vforkok 40 jmp verror 41 vforkok: 42 tstl r1 # child process ? 43 bneq child # yes 44 bcc parent # if c-bit not set, fork ok 45 .globl _errno 46 verror: 47 movl r0,_errno 48 mnegl $1,r0 49 jmp (r2) 50 child: 51 movl r0,myppid 52 clrl r0 53 clrl mypid 54 parent: 55 jmp (r2) 56