xref: /netbsd-src/lib/libc/arch/mips/sys/fork.S (revision 22882071611a5c00787326883b2dec6842e4ad38)
1*22882071Smatt/*	$NetBSD: fork.S,v 1.12 2009/12/14 01:07:42 matt Exp $	*/
281b108b4Sjonathan
3ae1bfcddSglass/*-
4ae1bfcddSglass * Copyright (c) 1991, 1993
5ae1bfcddSglass *	The Regents of the University of California.  All rights reserved.
6ae1bfcddSglass *
7ae1bfcddSglass * This code is derived from software contributed to Berkeley by
8ae1bfcddSglass * Ralph Campbell.
9ae1bfcddSglass *
10ae1bfcddSglass * Redistribution and use in source and binary forms, with or without
11ae1bfcddSglass * modification, are permitted provided that the following conditions
12ae1bfcddSglass * are met:
13ae1bfcddSglass * 1. Redistributions of source code must retain the above copyright
14ae1bfcddSglass *    notice, this list of conditions and the following disclaimer.
15ae1bfcddSglass * 2. Redistributions in binary form must reproduce the above copyright
16ae1bfcddSglass *    notice, this list of conditions and the following disclaimer in the
17ae1bfcddSglass *    documentation and/or other materials provided with the distribution.
18eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors
19ae1bfcddSglass *    may be used to endorse or promote products derived from this software
20ae1bfcddSglass *    without specific prior written permission.
21ae1bfcddSglass *
22ae1bfcddSglass * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23ae1bfcddSglass * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24ae1bfcddSglass * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25ae1bfcddSglass * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26ae1bfcddSglass * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27ae1bfcddSglass * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28ae1bfcddSglass * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29ae1bfcddSglass * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30ae1bfcddSglass * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31ae1bfcddSglass * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32ae1bfcddSglass * SUCH DAMAGE.
33ae1bfcddSglass */
34ae1bfcddSglass
35ae1bfcddSglass#include "SYS.h"
36ae1bfcddSglass
37ae1bfcddSglass#if defined(LIBC_SCCS) && !defined(lint)
38*22882071Smatt#if 0
39*22882071Smatt	RCSID("from: @(#)fork.s	8.1 (Berkeley) 6/4/93")
40*22882071Smatt#else
41*22882071Smatt	RCSID("$NetBSD: fork.S,v 1.12 2009/12/14 01:07:42 matt Exp $")
42*22882071Smatt#endif
43ae1bfcddSglass#endif /* LIBC_SCCS and not lint */
44ae1bfcddSglass
454fb740b8SnathanwLEAF(__fork)
46*22882071Smatt	PIC_PROLOGUE(__fork)
47*22882071Smatt
48*22882071Smatt	SYSTRAP(fork)		# pid = fork()
49ae1bfcddSglass	bne	a3, zero, 2f
50ae1bfcddSglass	beq	v1, zero, 1f	# v1 == 0 in parent, 1 in child
51ae1bfcddSglass	move	v0, zero
52ae1bfcddSglass1:
53*22882071Smatt	PIC_RETURN()
54ae1bfcddSglass2:
55*22882071Smatt	PIC_TAILCALL(__cerror)
564fb740b8SnathanwEND(__fork)
57