mirror of
https://github.com/fluencelabs/musl
synced 2025-06-05 19:11:34 +00:00
the old code worked in qemu app-level emulation, but not on real kernels where the clone syscall does not copy the register values to the new thread. save arguments on the new thread stack instead.
30 lines
488 B
ArmAsm
30 lines
488 B
ArmAsm
.set noreorder
|
|
.global __clone
|
|
.type __clone,@function
|
|
__clone:
|
|
# Save function pointer and argument pointer on new thread stack
|
|
subu $5, $5, 16
|
|
sw $4, 0($5)
|
|
sw $7, 4($5)
|
|
# Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
|
|
move $4, $6
|
|
lw $6, 16($sp)
|
|
lw $7, 20($sp)
|
|
lw $9, 24($sp)
|
|
sw $9, 16($sp)
|
|
li $2, 4120
|
|
syscall
|
|
beq $7, $0, 1f
|
|
nop
|
|
jr $ra
|
|
subu $2, $0, $2
|
|
1: beq $2, $0, 1f
|
|
nop
|
|
jr $ra
|
|
nop
|
|
1: lw $25, 0($sp)
|
|
lw $4, 4($sp)
|
|
jr $25
|
|
addu $sp, $sp, 16
|
|
nop
|