1/* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8#if defined(SYSLIBC_SCCS) && !defined(lint) 9 .asciz "@(#)Ovfork.s 5.6 (Berkeley) 06/01/90" 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/* 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 31_vfork: 32 .word 0x0000 33 movl 16(fp),r2 34 movab here,16(fp) 35 ret 36here: 37 chmk $vfork 38 bcc vforkok 39 jmp verror 40vforkok: 41 tstl r1 # child process ? 42 bneq child # yes 43 bcc parent # if c-bit not set, fork ok 44.globl _errno 45verror: 46 movl r0,_errno 47 mnegl $1,r0 48 jmp (r2) 49child: 50 clrl r0 51parent: 52 jmp (r2) 53