OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / bionic / libc / arch-x86 / bionic / clone.S
1 #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
16         movl    20(%esp), %ebx
17
18         # insert arguments onto the child stack
19         movl    12(%esp), %eax
20         movl    %eax, -12(%ecx)
21         movl    24(%esp), %eax
22         movl    %eax, -8(%ecx)
23         lea     (%ecx), %eax
24         movl    %eax, -4(%ecx)
25
26         movl    $__NR_clone, %eax
27         int     $0x80
28         test    %eax, %eax
29         jns     1f
30
31         # an error occured, set errno and return -1
32         negl    %eax
33         call    __set_errno
34         orl     $-1, %eax
35         jmp     2f
36
37 1:
38         jnz     2f
39
40         # we're in the child thread now, call __thread_entry
41         # with the appropriate arguments on the child stack
42         # we already placed most of them
43         subl    $16, %esp
44         jmp     __thread_entry
45         hlt
46
47 2:
48         popl    %ecx
49         popl    %ebx
50         ret
51
52 /* XXX: TODO: Add __bionic_clone here
53  *            See bionic/bionic_clone.c and arch-arm/bionic/clone.S
54  *            for more details...
55  */