overhaul clone syscall wrapping
[musl] / src / thread / x86_64 / clone.s
1 .text
2 .global __clone
3 .weak clone
4 .type   __clone,@function
5 .type   clone,@function
6 __clone:
7 clone:
8         xor %eax,%eax
9         mov $56,%al
10         mov %rdi,%r11
11         mov %rdx,%rdi
12         mov %r8,%rdx
13         mov %r9,%r8
14         mov 8(%rsp),%r10
15         mov %r11,%r9
16         and $-16,%rsi
17         sub $8,%rsi
18         mov %rcx,(%rsi)
19         syscall
20         test %eax,%eax
21         jnz 1f
22         xor %ebp,%ebp
23         pop %rdi
24         call *%r9
25         mov %eax,%edi
26         xor %eax,%eax
27         mov $60,%al
28         syscall
29         hlt
30 1:      ret