19ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes/*
25386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert * Copyright (C) 2008 The Android Open Source Project
39ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * All rights reserved.
49ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *
59ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * Redistribution and use in source and binary forms, with or without
69ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * modification, are permitted provided that the following conditions
79ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * are met:
89ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *  * Redistributions of source code must retain the above copyright
99ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *    notice, this list of conditions and the following disclaimer.
109ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *  * Redistributions in binary form must reproduce the above copyright
119ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *    notice, this list of conditions and the following disclaimer in
129ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *    the documentation and/or other materials provided with the
139ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *    distribution.
149ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes *
159ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
169ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
179ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
189ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
199ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
209ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
219ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
229ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
239ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
249ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
259ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
269ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes * SUCH DAMAGE.
279ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes */
289ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes
295386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert#include <private/bionic_asm.h>
305386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert#include <linux/sched.h>
319ea4d5f3a852a03b5a2c5676da148a2779821518Elliott Hughes
325386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert// TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__.
335386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert// #include <asm/signal.h>
345386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert#define SIGCHLD 18
355386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert
365386a741e77bfff4e72ca6861fdd3fe2208452ceDan AlbertENTRY(vfork)
375386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	.set	noreorder
385386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	.cpload	t9
395386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert
405386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	li	a0, (CLONE_VM | CLONE_VFORK | SIGCHLD)
415386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	li	a1, 0
425386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	li	a2, 0
435386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	li	a3, 0
445386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	subu	sp, 8
455386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	sw	$0, 16(sp)
465386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	li	v0, __NR_clone
475386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	syscall
485386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	addu	sp, 8
495386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	bnez	a3, 1f
505386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	 move	a0, v0
515386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert
525386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	j	ra
535386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	 nop
545386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert1:
557efad83d430f4d824f2aaa75edea5106f6ff8aaeElliott Hughes	la	t9, __set_errno_internal
565386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	j	t9
575386a741e77bfff4e72ca6861fdd3fe2208452ceDan Albert	 nop
585386a741e77bfff4e72ca6861fdd3fe2208452ceDan AlbertEND(vfork)
59