1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * the Systems Programming Group of the University of Utah Computer 7 * Science Department. 8 * 9 * %sccs.include.redist.c% 10 */ 11 12#if defined(LIBC_SCCS) && !defined(lint) 13 .asciz "@(#)Ovfork.s 5.1 (Berkeley) 05/12/90" 14#endif /* LIBC_SCCS and not lint */ 15 16/* 17 * @(#)vfork.s 4.1 (Berkeley) 12/21/80 18 * C library -- vfork 19 */ 20 21/* 22 * pid = vfork(); 23 * 24 * d1 == 0 in parent process, d1 == 1 in child process. 25 * d0 == pid of child in parent, d0 == pid of parent in child. 26 * 27 * trickery here, due to keith sklower, uses ret to clear the stack, 28 * and then returns with a jump indirect, since only one person can return 29 * with a ret off this stack... we do the ret before we vfork! 30 */ 31 32 vfork = 66 33.globl _vfork 34 35_vfork: 36 movl sp@+,a0 37 movl #vfork,d0 38 trap #0 39 jcc vforkok 40 jmp verror 41vforkok: 42 tstl d1 /* child process ? */ 43 jne child /* yes */ 44 jcc parent /* if c-bit not set, fork ok */ 45 .globl _errno 46verror: 47 movl d0,_errno 48 moveq #-1,d0 49 jmp a0@ 50child: 51 clrl d0 52parent: 53 jmp a0@ 54