blob: 352d23c5c8442ee575a5c5021f0162b408690fc8 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001#include <sys/linux-syscalls.h>
2
3.text
4
5/*
6 * int __pthread_clone(int (*fn)(void*), void *tls, int flags,
7 * void *arg);
8 */
9.globl __pthread_clone
10.type __pthread_clone, @function
11.align 4
12__pthread_clone:
13 pushl %ebx
14 pushl %ecx
15 movl 16(%esp), %ecx
Jack Rencb082042012-03-21 17:48:13 +080016
17 # save tls
18 movl %ecx, %ebx
19 # 16-byte alignment on child stack
20 andl $~15, %ecx
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080021
22 # insert arguments onto the child stack
23 movl 12(%esp), %eax
Jack Rencb082042012-03-21 17:48:13 +080024 movl %eax, -16(%ecx)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080025 movl 24(%esp), %eax
Jack Rencb082042012-03-21 17:48:13 +080026 movl %eax, -12(%ecx)
27 movl %ebx, -8(%ecx)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080028
Jack Rene480fc82011-09-21 12:44:11 +020029 subl $16, %ecx
Jack Rencb082042012-03-21 17:48:13 +080030 movl 20(%esp), %ebx
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080031 movl $__NR_clone, %eax
32 int $0x80
33 test %eax, %eax
34 jns 1f
35
36 # an error occured, set errno and return -1
37 negl %eax
38 call __set_errno
39 orl $-1, %eax
40 jmp 2f
41
421:
43 jnz 2f
44
45 # we're in the child thread now, call __thread_entry
46 # with the appropriate arguments on the child stack
47 # we already placed most of them
Jack Rencb082042012-03-21 17:48:13 +080048 call __thread_entry
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080049 hlt
50
512:
52 popl %ecx
53 popl %ebx
54 ret
David 'Digit' Turner97cf7f32010-01-22 18:59:05 -080055
56/* XXX: TODO: Add __bionic_clone here
57 * See bionic/bionic_clone.c and arch-arm/bionic/clone.S
58 * for more details...
Bruce Beare16984422010-06-25 09:02:10 -070059 */