1*4d12bfcdSjoerg/* $NetBSD: compat_Ovfork.S,v 1.3 2013/09/12 15:36:16 joerg Exp $ */ 2eebf1202Schristos 3eebf1202Schristos/*- 4eebf1202Schristos * Copyright (c) 1990 The Regents of the University of California. 5eebf1202Schristos * All rights reserved. 6eebf1202Schristos * 7eebf1202Schristos * This code is derived from software contributed to Berkeley by 8eebf1202Schristos * the Systems Programming Group of the University of Utah Computer 9eebf1202Schristos * Science Department. 10eebf1202Schristos * 11eebf1202Schristos * Redistribution and use in source and binary forms, with or without 12eebf1202Schristos * modification, are permitted provided that the following conditions 13eebf1202Schristos * are met: 14eebf1202Schristos * 1. Redistributions of source code must retain the above copyright 15eebf1202Schristos * notice, this list of conditions and the following disclaimer. 16eebf1202Schristos * 2. Redistributions in binary form must reproduce the above copyright 17eebf1202Schristos * notice, this list of conditions and the following disclaimer in the 18eebf1202Schristos * documentation and/or other materials provided with the distribution. 19eebf1202Schristos * 3. Neither the name of the University nor the names of its contributors 20eebf1202Schristos * may be used to endorse or promote products derived from this software 21eebf1202Schristos * without specific prior written permission. 22eebf1202Schristos * 23eebf1202Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24eebf1202Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25eebf1202Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26eebf1202Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27eebf1202Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28eebf1202Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29eebf1202Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30eebf1202Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31eebf1202Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32eebf1202Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33eebf1202Schristos * SUCH DAMAGE. 34eebf1202Schristos */ 35eebf1202Schristos 36eebf1202Schristos#include "SYS.h" 37eebf1202Schristos 38eebf1202Schristos#if defined(LIBC_SCCS) && !defined(lint) 39eebf1202Schristos#if 0 40eebf1202Schristos RCSID("from: @(#)Ovfork.s 5.1 (Berkeley) 5/12/90") 41eebf1202Schristos#else 42*4d12bfcdSjoerg RCSID("$NetBSD: compat_Ovfork.S,v 1.3 2013/09/12 15:36:16 joerg Exp $") 43eebf1202Schristos#endif 44eebf1202Schristos#endif /* LIBC_SCCS and not lint */ 45eebf1202Schristos 46eebf1202Schristos/* 47eebf1202Schristos * @(#)vfork.s 4.1 (Berkeley) 12/21/80 48eebf1202Schristos * C library -- vfork 49eebf1202Schristos */ 50eebf1202Schristos 51eebf1202SchristosWARN_REFERENCES(vfork, \ 52eebf1202Schristos "warning: reference to compatibility vfork(); include <unistd.h> for correct reference") 53eebf1202Schristos 54eebf1202Schristos/* 55eebf1202Schristos * pid = vfork(); 56eebf1202Schristos * 57eebf1202Schristos * d1 == 0 in parent process, d1 == 1 in child process. 58eebf1202Schristos * d0 == pid of child in parent, d0 == pid of parent in child. 59eebf1202Schristos * 60eebf1202Schristos * trickery here, due to keith sklower, uses ret to clear the stack, 61eebf1202Schristos * and then returns with a jump indirect, since only one person can return 62eebf1202Schristos * with a ret off this stack... we do the ret before we vfork! 63eebf1202Schristos */ 64eebf1202Schristos 65eebf1202SchristosENTRY(vfork) 662d913a7cSmatt movl (%sp)+,%a1 672d913a7cSmatt SYSTRAP(vfork) 68eebf1202Schristos jcs err 69eebf1202Schristos subql #1,%d1 /* from 1 to 0 in child, 0 to -1 in parent */ 70eebf1202Schristos andl %d1,%d0 712d913a7cSmatt jmp (%a1) 72eebf1202Schristoserr: 73eebf1202Schristos#ifdef _REENTRANT 74eebf1202Schristos .globl _C_LABEL(__errno) 752d913a7cSmatt movl %a1,-(%sp) 762d913a7cSmatt movl %d0,-(%sp) 77eebf1202Schristos jbsr PIC_PLT(_C_LABEL(__errno)) 78eebf1202Schristos#ifdef __SVR4_ABI__ 792d913a7cSmatt movl (%sp)+,(%a0) 80eebf1202Schristos#else 81eebf1202Schristos movl %d0,%a1 822d913a7cSmatt movl (%sp)+,(%a1) 83eebf1202Schristos#endif /* __SVR4_ABI__ */ 842d913a7cSmatt movl (%sp)+,%a1 85eebf1202Schristos#else 86eebf1202Schristos .globl _C_LABEL(errno) 87*4d12bfcdSjoerg#ifdef __PIC__ 882d913a7cSmatt GOT_SETUP(%a0) 892d913a7cSmatt movl _C_LABEL(errno)@GOT:w(%a0),%a0 902d913a7cSmatt movl %d0,(%a0) 91eebf1202Schristos#else 92eebf1202Schristos movl %d0,_C_LABEL(errno) 93*4d12bfcdSjoerg#endif /* __PIC__ */ 94eebf1202Schristos#endif /* _REENTRANT */ 95eebf1202Schristos moveq #-1,%d0 962d913a7cSmatt jmp (%a1) 972d913a7cSmattEND(vfork) 98