123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #define _ERRNO_H 1
- #include <bits/errno.h>
- #include <sys/syscall.h>
- #define LINKAGE 4
- #define PTR_SIZE 4
- #define PARMS LINKAGE
- #define FUNC PARMS
- #define STACK FUNC+4
- #define FLAGS STACK+PTR_SIZE
- #define ARG FLAGS+4
- #define PTID ARG+PTR_SIZE
- #define TLS PTID+PTR_SIZE
- #define CTID TLS+PTR_SIZE
- .text
- .global clone
- .type clone,%function
- clone:
-
- movl $-EINVAL,%eax
-
- movl FUNC(%esp),%ecx
- #ifdef __PIC__
- jecxz __error
- #else
- testl %ecx,%ecx
- jz __error
- #endif
-
- movl STACK(%esp),%ecx
- #ifdef __PIC__
- jecxz __error
- #else
- testl %ecx,%ecx
- jz __error
- #endif
-
- andl $0xfffffff0, %ecx
- subl $28,%ecx
- movl ARG(%esp),%eax
- movl %eax,12(%ecx)
-
- movl FUNC(%esp),%eax
- movl %eax,8(%ecx)
-
- movl $0,4(%ecx)
-
- pushl %ebx
- pushl %esi
- pushl %edi
- movl TLS+12(%esp),%esi
- movl PTID+12(%esp),%edx
- movl FLAGS+12(%esp),%ebx
- movl CTID+12(%esp),%edi
- movl $__NR_clone,%eax
- int $0x80
- popl %edi
- popl %esi
- popl %ebx
- test %eax,%eax
- jl __error
- jz .Lthread_start
- ret
- .Lthread_start:
-
- movl %esi,%ebp
- call *%ebx
- #ifdef __PIC__
- call .Lhere
- .Lhere:
- popl %ebx
- addl $_GLOBAL_OFFSET_TABLE_+[.-.Lhere], %ebx
- #endif
- movl %eax, %ebx
- movl $__NR_exit, %eax
- int $0x80
- __error:
- jmp __syscall_error
- .size clone,.-clone
- weak_alias(clone, __clone)
|