about summary refs log tree commit diff
path: root/src/thread/mipsn32/clone.s
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-04-18 05:19:13 +0000
committerRich Felker <dalias@aerifal.cx>2016-04-18 05:19:13 +0000
commit5972c4a4113e2a4de5edf519faf15296ae1eb3ed (patch)
tree6e808f23bb96a9b8a82eb505e2a719f4f42a758d /src/thread/mipsn32/clone.s
parent6d99ad91e869aab35a4d76d34c3c9eaf29482bad (diff)
downloadmusl-5972c4a4113e2a4de5edf519faf15296ae1eb3ed.tar.gz
musl-5972c4a4113e2a4de5edf519faf15296ae1eb3ed.tar.xz
musl-5972c4a4113e2a4de5edf519faf15296ae1eb3ed.zip
add mips n32 port (ILP32 ABI for mips64)
based on patch submitted by Jaydeep Patil, with minor changes.
Diffstat (limited to 'src/thread/mipsn32/clone.s')
-rw-r--r--src/thread/mipsn32/clone.s30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/thread/mipsn32/clone.s b/src/thread/mipsn32/clone.s
new file mode 100644
index 00000000..51035852
--- /dev/null
+++ b/src/thread/mipsn32/clone.s
@@ -0,0 +1,30 @@
+.set	noreorder
+.global	__clone
+.type	__clone,@function
+__clone:
+	# Save function pointer and argument pointer on new thread stack
+	and	$5, $5, -16	# aligning stack to double word
+	subu	$5, $5, 16
+	sw	$4, 0($5)	# save function pointer
+	sw	$7, 4($5)	# save argument pointer
+
+	# Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
+	# sys_clone(u64 flags, u64 ustack_base, u64 parent_tidptr, u64 child_tidptr, u64 tls)
+	move	$4, $6
+	move	$6, $8
+	move	$7, $9
+	move	$8, $10
+	li	$2, 6055
+	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)	# function pointer
+	lw	$4, 4($sp)	# argument pointer
+	jr	$25		# call the user's function
+	nop