musl/src/thread/i386/clone.s
Rich Felker 3f72cdac73 overhaul clone syscall wrapping
several things are changed. first, i have removed the old __uniclone
function signature and replaced it with the "standard" linux
__clone/clone signature. this was necessary to expose clone to
applications anyway, and it makes it easier to port __clone to new
archs, since it's now testable independently of pthread_create.

secondly, i have removed all references to the ugly ldt descriptor
structure (i386 only) from the c code and pthread structure. in places
where it is needed, it is now created on the stack just when it's
needed, in assembly code. thus, the i386 __clone function takes the
desired thread pointer as its argument, rather than an ldt descriptor
pointer, just like on all other sane archs. this should not affect
applications since there is really no way an application can use clone
with threads/tls in a way that doesn't horribly conflict with and
clobber the underlying implementation's use. applications are expected
to use clone only for creating actual processes, possibly with new
namespace features and whatnot.
2011-09-18 10:14:37 -04:00

51 lines
637 B
ArmAsm

.text
.global __clone
.weak clone
.type __clone,@function
.type clone,@function
__clone:
clone:
push %ebp
mov %esp,%ebp
push %ebx
push %esi
push %edi
xor %eax,%eax
push $0x51
mov %gs,%ax
push $0xfffff
shr $3,%eax
push 28(%ebp)
push %eax
mov $120,%al
mov 12(%ebp),%ecx
mov 16(%ebp),%ebx
and $-16,%ecx
sub $16,%ecx
mov 20(%ebp),%edi
mov %edi,(%ecx)
mov 24(%ebp),%edx
mov %esp,%esi
mov 32(%ebp),%edi
mov 8(%ebp),%ebp
int $128
test %eax,%eax
jnz 1f
mov %ebp,%eax
xor %ebp,%ebp
call *%eax
mov %eax,%ebx
xor %eax,%eax
inc %eax
int $128
hlt
1: add $16,%esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret