xref: /netbsd-src/lib/libc/compat/arch/sh3/sys/compat_Ovfork.S (revision 553d6ca3ede8b05d4be7347fb477bf23e01d499d)
1*553d6ca3Suwe/*	$NetBSD: compat_Ovfork.S,v 1.2 2006/01/06 04:30:33 uwe Exp $	*/
2bdfc6e2eSuwe
3bdfc6e2eSuwe/*-
4bdfc6e2eSuwe * Copyright (c) 1990 The Regents of the University of California.
5bdfc6e2eSuwe * All rights reserved.
6bdfc6e2eSuwe *
7bdfc6e2eSuwe * This code is derived from software contributed to Berkeley by
8bdfc6e2eSuwe * William Jolitz.
9bdfc6e2eSuwe *
10bdfc6e2eSuwe * Redistribution and use in source and binary forms, with or without
11bdfc6e2eSuwe * modification, are permitted provided that the following conditions
12bdfc6e2eSuwe * are met:
13bdfc6e2eSuwe * 1. Redistributions of source code must retain the above copyright
14bdfc6e2eSuwe *    notice, this list of conditions and the following disclaimer.
15bdfc6e2eSuwe * 2. Redistributions in binary form must reproduce the above copyright
16bdfc6e2eSuwe *    notice, this list of conditions and the following disclaimer in the
17bdfc6e2eSuwe *    documentation and/or other materials provided with the distribution.
18bdfc6e2eSuwe * 3. Neither the name of the University nor the names of its contributors
19bdfc6e2eSuwe *    may be used to endorse or promote products derived from this software
20bdfc6e2eSuwe *    without specific prior written permission.
21bdfc6e2eSuwe *
22bdfc6e2eSuwe * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23bdfc6e2eSuwe * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24bdfc6e2eSuwe * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25bdfc6e2eSuwe * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26bdfc6e2eSuwe * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27bdfc6e2eSuwe * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28bdfc6e2eSuwe * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29bdfc6e2eSuwe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30bdfc6e2eSuwe * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31bdfc6e2eSuwe * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32bdfc6e2eSuwe * SUCH DAMAGE.
33bdfc6e2eSuwe *
34bdfc6e2eSuwe *	from: @(#)Ovfork.s	5.1 (Berkeley) 4/23/90
35bdfc6e2eSuwe */
36bdfc6e2eSuwe
37bdfc6e2eSuwe#include <machine/asm.h>
38bdfc6e2eSuwe#if defined(SYSLIBC_SCCS) && !defined(lint)
39*553d6ca3Suwe	RCSID("$NetBSD: compat_Ovfork.S,v 1.2 2006/01/06 04:30:33 uwe Exp $")
40bdfc6e2eSuwe#endif /* SYSLIBC_SCCS and not lint */
41bdfc6e2eSuwe
42bdfc6e2eSuwe#include "SYS.h"
43bdfc6e2eSuwe
44*553d6ca3SuweWARN_REFERENCES(vfork, \
45*553d6ca3Suwe    "warning: reference to compatibility vfork(); include <unistd.h> for correct reference")
46*553d6ca3Suwe
47bdfc6e2eSuwe/*
48bdfc6e2eSuwe * pid = vfork();
49bdfc6e2eSuwe *
50bdfc6e2eSuwe * r1 == 0 in parent process, r1 == 1 in child process.
51bdfc6e2eSuwe * r0 == pid of child in parent, r0 == pid of parent in child.
52bdfc6e2eSuwe *
53bdfc6e2eSuwe */
54bdfc6e2eSuweENTRY(vfork)
55*553d6ca3Suwe	mov	#SYS_vfork, r0
56bdfc6e2eSuwe	trapa	#0x80
57bdfc6e2eSuwe	bf	err
58bdfc6e2eSuwe
59*553d6ca3Suwe	add	#0xff, r1	/* from 1 to 0 in child, 0 to -1 in parent */
60*553d6ca3Suwe	rts
61*553d6ca3Suwe	 and	r1, r0		/* 0 in child, child pid in parent */
62*553d6ca3Suwe
63*553d6ca3Suweerr:
64*553d6ca3Suwe	JUMP_CERROR
65*553d6ca3Suwe
66*553d6ca3Suwe	SET_ENTRY_SIZE(vfork)
67