about summary refs log tree commit diff
path: root/src/thread/mips/clone.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/mips/clone.s')
-rw-r--r--src/thread/mips/clone.s27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/thread/mips/clone.s b/src/thread/mips/clone.s
new file mode 100644
index 00000000..09a1a83f
--- /dev/null
+++ b/src/thread/mips/clone.s
@@ -0,0 +1,27 @@
+.set noreorder
+.global __clone
+.type   __clone,@function
+__clone:
+	# Save function pointer and argument pointer
+	move $25, $4
+	move $8, $7
+	# Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (sp,fl,ptid,tls,ctid)
+	move $4, $5
+	move $5, $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:	move $4, $8
+	jr $25
+	nop