overhaul clone syscall wrapping
[musl] / src / thread / i386 / clone.s
1 .text
2 .global __clone
3 .weak clone
4 .type   __clone,@function
5 .type   clone,@function
6 __clone:
7 clone:
8         push %ebp
9         mov %esp,%ebp
10         push %ebx
11         push %esi
12         push %edi
13
14         xor %eax,%eax
15         push $0x51
16         mov %gs,%ax
17         push $0xfffff
18         shr $3,%eax
19         push 28(%ebp)
20         push %eax
21         mov $120,%al
22
23         mov 12(%ebp),%ecx
24         mov 16(%ebp),%ebx
25         and $-16,%ecx
26         sub $16,%ecx
27         mov 20(%ebp),%edi
28         mov %edi,(%ecx)
29         mov 24(%ebp),%edx
30         mov %esp,%esi
31         mov 32(%ebp),%edi
32         mov 8(%ebp),%ebp
33         int $128
34         test %eax,%eax
35         jnz 1f
36
37         mov %ebp,%eax
38         xor %ebp,%ebp
39         call *%eax
40         mov %eax,%ebx
41         xor %eax,%eax
42         inc %eax
43         int $128
44         hlt
45
46 1:      add $16,%esp
47         pop %edi
48         pop %esi
49         pop %ebx
50         pop %ebp
51         ret