1/* 2 * @(#)vfork.s 4.1 (Berkeley) 12/21/80 3 * C library -- vfork 4 */ 5 6/* 7 * pid = vfork(); 8 * 9 * r1 == 0 in parent process, r1 == 1 in child process. 10 * r0 == pid of child in parent, r0 == pid of parent in child. 11 * 12 * trickery here, due to keith sklower, uses ret to clear the stack, 13 * and then returns with a jump indirect, since only one person can return 14 * with a ret off this stack... we do the ret before we vfork! 15 */ 16 17 .set vfork,66 18.globl _vfork 19 20_vfork: 21 .word 0x0000 22 movl 16(fp),r2 23 movab here,16(fp) 24 ret 25here: 26 chmk $vfork 27 bcc vforkok 28 jmp verror 29vforkok: 30 tstl r1 # child process ? 31 bneq child # yes 32 bcc parent # if c-bit not set, fork ok 33.globl _errno 34verror: 35 movl r0,_errno 36 mnegl $1,r0 37 jmp (r2) 38child: 39 clrl r0 40parent: 41 jmp (r2) 42