141841Sbostic/*- 241841Sbostic * Copyright (c) 1990 The Regents of the University of California. 341841Sbostic * All rights reserved. 441841Sbostic * 541841Sbostic * This code is derived from software contributed to Berkeley by 641841Sbostic * the Systems Programming Group of the University of Utah Computer 741841Sbostic * Science Department. 841841Sbostic * 941841Sbostic * %sccs.include.redist.c% 1041841Sbostic */ 1141841Sbostic 1241841Sbostic#if defined(LIBC_SCCS) && !defined(lint) 13*62565Sbostic .asciz "@(#)Ovfork.s 5.2 (Berkeley) 06/07/93" 1441841Sbostic#endif /* LIBC_SCCS and not lint */ 1541841Sbostic 1641841Sbostic/* 1741841Sbostic * @(#)vfork.s 4.1 (Berkeley) 12/21/80 1841841Sbostic * C library -- vfork 1941841Sbostic */ 2041841Sbostic 2141841Sbostic/* 2241841Sbostic * pid = vfork(); 2341841Sbostic * 2441841Sbostic * d1 == 0 in parent process, d1 == 1 in child process. 2541841Sbostic * d0 == pid of child in parent, d0 == pid of parent in child. 2641841Sbostic * 2741841Sbostic * trickery here, due to keith sklower, uses ret to clear the stack, 2841841Sbostic * and then returns with a jump indirect, since only one person can return 2941841Sbostic * with a ret off this stack... we do the ret before we vfork! 3041841Sbostic */ 3141841Sbostic 3241841Sbostic vfork = 66 33*62565SbosticENTRY(vfork) 3441841Sbostic movl sp@+,a0 3541841Sbostic movl #vfork,d0 3641841Sbostic trap #0 3741841Sbostic jcc vforkok 3841841Sbostic jmp verror 3941841Sbosticvforkok: 4041841Sbostic tstl d1 /* child process ? */ 4141841Sbostic jne child /* yes */ 4241841Sbostic jcc parent /* if c-bit not set, fork ok */ 4341841Sbostic .globl _errno 4441841Sbosticverror: 4541841Sbostic movl d0,_errno 4641841Sbostic moveq #-1,d0 4741841Sbostic jmp a0@ 4841841Sbosticchild: 4941841Sbostic clrl d0 5041841Sbosticparent: 5141841Sbostic jmp a0@ 52