summaryrefslogtreecommitdiff
path: root/lib/thread
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-05-27 18:25:09 +1200
committerOri Bernstein <ori@eigenstate.org>2016-05-27 18:25:29 +1200
commitd0e4fdbfed4d69c60e5d431accbcb6e08e014344 (patch)
tree256c7c5887290835eb8111e037794fa65359573c /lib/thread
parentfdbd75fad30016627aa740bfeaa8592d0ec80d44 (diff)
downloadmc-d0e4fdbfed4d69c60e5d431accbcb6e08e014344.tar.gz
Add missing file.
Diffstat (limited to 'lib/thread')
-rw-r--r--lib/thread/exit+openbsd-x64.s23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/thread/exit+openbsd-x64.s b/lib/thread/exit+openbsd-x64.s
new file mode 100644
index 0000000..23f92b5
--- /dev/null
+++ b/lib/thread/exit+openbsd-x64.s
@@ -0,0 +1,23 @@
+/*
+const thread.exit : (stacksz : std.size -> void)
+NOTE: must be called from the bottom of the stack, since
+we assume that %rbp is in the top 4k of the stack.
+*/
+.globl thread$exit
+thread$exit:
+ /* find top of stack */
+ movq %rbp,%rdi /* addr */
+ andq $~0xfff,%rdi /* align it */
+ addq $0x1000,%rdi
+
+ /* munmap(base, size) */
+ movq $73,%rax /* munmap */
+ movq -8(%rdi),%rsi /* size */
+ subq %rsi,%rdi /* move to base ptr */
+ syscall
+
+ /* __threxit(0) */
+ movq $302,%rax /* exit */
+ xorq %rdi,%rdi /* 0 */
+ syscall
+