2012-07-26 03:16:42 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2013-03-22 06:52:25 +01:00
|
|
|
|
2014-02-20 01:53:20 +01:00
|
|
|
#include <private/bionic_asm.h>
|
2012-07-26 03:16:42 +02:00
|
|
|
#include <linux/errno.h>
|
2013-03-22 06:52:25 +01:00
|
|
|
#include <linux/sched.h>
|
2013-02-15 03:59:37 +01:00
|
|
|
|
2013-11-15 20:51:07 +01:00
|
|
|
// pid_t __bionic_clone(int flags, void* child_stack, pid_t* parent_tid, void* tls, pid_t* child_tid, int (*fn)(void*), void* arg);
|
2014-02-20 01:53:20 +01:00
|
|
|
ENTRY(__bionic_clone)
|
2012-07-26 03:16:42 +02:00
|
|
|
.set noreorder
|
2014-02-20 01:53:20 +01:00
|
|
|
.cpload t9
|
2012-07-26 03:16:42 +02:00
|
|
|
.set reorder
|
|
|
|
|
|
|
|
# set up child stack
|
2014-02-20 01:53:20 +01:00
|
|
|
subu a1,16
|
|
|
|
lw t0,20(sp) # fn
|
|
|
|
lw t1,24(sp) # arg
|
|
|
|
sw t0,0(a1) # fn
|
|
|
|
sw t1,4(a1) # arg
|
2012-07-26 03:16:42 +02:00
|
|
|
|
|
|
|
# remainder of arguments are correct for clone system call
|
2014-02-20 01:53:20 +01:00
|
|
|
li v0,__NR_clone
|
2012-07-26 03:16:42 +02:00
|
|
|
syscall
|
|
|
|
|
2014-02-20 01:53:20 +01:00
|
|
|
bnez a3,.L__error_bc
|
2012-07-26 03:16:42 +02:00
|
|
|
|
2014-02-20 01:53:20 +01:00
|
|
|
beqz v0,.L__thread_start_bc
|
2013-02-15 03:59:37 +01:00
|
|
|
|
2014-02-20 01:53:20 +01:00
|
|
|
j ra
|
2012-07-26 03:16:42 +02:00
|
|
|
|
|
|
|
.L__thread_start_bc:
|
2014-05-28 00:47:32 +02:00
|
|
|
# Clear return address in child so we don't unwind further.
|
|
|
|
li ra,0
|
|
|
|
|
2014-02-20 01:53:20 +01:00
|
|
|
lw a0,0(sp) # fn
|
|
|
|
lw a1,4(sp) # arg
|
2012-07-26 03:16:42 +02:00
|
|
|
|
2014-06-07 00:18:54 +02:00
|
|
|
# void __start_thread(int (*func)(void*), void *arg)
|
|
|
|
la t9,__start_thread
|
2014-02-20 01:53:20 +01:00
|
|
|
j t9
|
2012-07-26 03:16:42 +02:00
|
|
|
|
|
|
|
.L__error_bc:
|
2014-02-20 01:53:20 +01:00
|
|
|
move a0,v0
|
|
|
|
la t9,__set_errno
|
|
|
|
j t9
|
|
|
|
END(__bionic_clone)
|
2014-05-09 04:00:23 +02:00
|
|
|
.hidden __bionic_clone
|