summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/thread/mips64
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 13:54:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 13:54:38 +0000
commit8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch)
treedf55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-top-half/musl/src/thread/mips64
parentInitial commit. (diff)
downloadwasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.tar.xz
wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.zip
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/src/thread/mips64')
-rw-r--r--libc-top-half/musl/src/thread/mips64/__unmapself.s9
-rw-r--r--libc-top-half/musl/src/thread/mips64/clone.s34
-rw-r--r--libc-top-half/musl/src/thread/mips64/syscall_cp.s52
3 files changed, 95 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/thread/mips64/__unmapself.s b/libc-top-half/musl/src/thread/mips64/__unmapself.s
new file mode 100644
index 0000000..f6795cd
--- /dev/null
+++ b/libc-top-half/musl/src/thread/mips64/__unmapself.s
@@ -0,0 +1,9 @@
+.set noreorder
+.global __unmapself
+.type __unmapself, @function
+__unmapself:
+ li $2, 5011
+ syscall
+ li $4, 0
+ li $2, 5058
+ syscall
diff --git a/libc-top-half/musl/src/thread/mips64/clone.s b/libc-top-half/musl/src/thread/mips64/clone.s
new file mode 100644
index 0000000..2d86899
--- /dev/null
+++ b/libc-top-half/musl/src/thread/mips64/clone.s
@@ -0,0 +1,34 @@
+.set noreorder
+.global __clone
+.hidden __clone
+.type __clone,@function
+__clone:
+ # Save function pointer and argument pointer on new thread stack
+ and $5, $5, -16 # aligning stack to double word
+ dsubu $5, $5, 16
+ sd $4, 0($5) # save function pointer
+ sd $7, 8($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, 5055
+ syscall
+ beq $7, $0, 1f
+ nop
+ jr $ra
+ dsubu $2, $0, $2
+1: beq $2, $0, 1f
+ nop
+ jr $ra
+ nop
+1: ld $25, 0($sp) # function pointer
+ ld $4, 8($sp) # argument pointer
+ jalr $25 # call the user's function
+ nop
+ move $4, $2
+ li $2, 5058
+ syscall
diff --git a/libc-top-half/musl/src/thread/mips64/syscall_cp.s b/libc-top-half/musl/src/thread/mips64/syscall_cp.s
new file mode 100644
index 0000000..0d4ede7
--- /dev/null
+++ b/libc-top-half/musl/src/thread/mips64/syscall_cp.s
@@ -0,0 +1,52 @@
+.set noreorder
+.global __cp_begin
+.hidden __cp_begin
+.type __cp_begin,@function
+.global __cp_end
+.hidden __cp_end
+.type __cp_end,@function
+.global __cp_cancel
+.hidden __cp_cancel
+.type __cp_cancel,@function
+.global __cp_cancel_data
+.hidden __cp_cancel_data
+.type __cp_cancel_data,@function
+.hidden __cancel
+.global __syscall_cp_asm
+.hidden __syscall_cp_asm
+.type __syscall_cp_asm,@function
+__syscall_cp_asm:
+__cp_begin:
+ lw $4, 0($4)
+ bne $4, $0, __cp_cancel
+ move $2, $5
+ move $4, $6
+ move $5, $7
+ move $6, $8
+ move $7, $9
+ move $8, $10
+ move $9, $11
+ ld $10, 0($sp)
+ syscall
+__cp_end:
+ beq $7, $0, 1f
+ nop
+ dsubu $2, $0, $2
+1: jr $ra
+ nop
+
+ # if cancellation flag is 1 then call __cancel
+__cp_cancel:
+ move $2, $ra
+.align 8
+ bal 1f
+ nop
+__cp_cancel_data:
+ .gpdword __cp_cancel_data
+ .gpdword __cancel
+1: ld $3, ($ra)
+ dsubu $3, $ra, $3
+ ld $25, 8($ra)
+ daddu $25, $25, $3
+ jr $25
+ move $ra, $2