2009-03-04 04:28:35 +01:00
|
|
|
#include <sys/linux-syscalls.h>
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
/*
|
|
|
|
* int __pthread_clone(int (*fn)(void*), void *tls, int flags,
|
|
|
|
* void *arg);
|
|
|
|
*/
|
|
|
|
.globl __pthread_clone
|
|
|
|
.type __pthread_clone, @function
|
|
|
|
.align 4
|
|
|
|
__pthread_clone:
|
|
|
|
pushl %ebx
|
|
|
|
pushl %ecx
|
|
|
|
movl 16(%esp), %ecx
|
2012-03-21 10:48:13 +01:00
|
|
|
|
|
|
|
# save tls
|
|
|
|
movl %ecx, %ebx
|
|
|
|
# 16-byte alignment on child stack
|
|
|
|
andl $~15, %ecx
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
# insert arguments onto the child stack
|
|
|
|
movl 12(%esp), %eax
|
2012-03-21 10:48:13 +01:00
|
|
|
movl %eax, -16(%ecx)
|
2009-03-04 04:28:35 +01:00
|
|
|
movl 24(%esp), %eax
|
2012-03-21 10:48:13 +01:00
|
|
|
movl %eax, -12(%ecx)
|
|
|
|
movl %ebx, -8(%ecx)
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2011-09-21 12:44:11 +02:00
|
|
|
subl $16, %ecx
|
2012-03-21 10:48:13 +01:00
|
|
|
movl 20(%esp), %ebx
|
2009-03-04 04:28:35 +01:00
|
|
|
movl $__NR_clone, %eax
|
|
|
|
int $0x80
|
|
|
|
test %eax, %eax
|
|
|
|
jns 1f
|
|
|
|
|
|
|
|
# an error occured, set errno and return -1
|
|
|
|
negl %eax
|
|
|
|
call __set_errno
|
|
|
|
orl $-1, %eax
|
|
|
|
jmp 2f
|
|
|
|
|
|
|
|
1:
|
|
|
|
jnz 2f
|
|
|
|
|
|
|
|
# we're in the child thread now, call __thread_entry
|
|
|
|
# with the appropriate arguments on the child stack
|
|
|
|
# we already placed most of them
|
2012-03-21 10:48:13 +01:00
|
|
|
call __thread_entry
|
2009-03-04 04:28:35 +01:00
|
|
|
hlt
|
|
|
|
|
|
|
|
2:
|
|
|
|
popl %ecx
|
|
|
|
popl %ebx
|
|
|
|
ret
|
2010-01-23 03:59:05 +01:00
|
|
|
|
|
|
|
/* XXX: TODO: Add __bionic_clone here
|
|
|
|
* See bionic/bionic_clone.c and arch-arm/bionic/clone.S
|
|
|
|
* for more details...
|
2010-06-25 18:02:10 +02:00
|
|
|
*/
|