summaryrefslogtreecommitdiff
path: root/lib/sys/syscall+openbsd-x64.s
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sys/syscall+openbsd-x64.s')
-rw-r--r--lib/sys/syscall+openbsd-x64.s28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/sys/syscall+openbsd-x64.s b/lib/sys/syscall+openbsd-x64.s
index 827f25c..ea4a9b7 100644
--- a/lib/sys/syscall+openbsd-x64.s
+++ b/lib/sys/syscall+openbsd-x64.s
@@ -22,3 +22,31 @@ sys$syscall:
.success:
ret
+
+/* __tfork_thread(tfp : tforkparams#, sz : size, fn : void#, arg : void#-> tid) */
+.globl sys$__tfork_thread
+sys$__tfork_thread:
+ /* syscall */
+ movq %rdx, %r8
+ movq %rcx, %r9
+ movq $8, %rax
+ syscall
+ jb .failparent
+
+ /* are we in the parent? */
+ cmpq $0,%rax
+ jnz .doneparent
+
+ /* call the function and __threxit */
+ movq %r9, %rdi
+ callq *%r8
+
+ movq $302,%rax
+ xorq %rdi,%rdi
+ syscall
+
+.failparent:
+ negq %rax
+
+.doneparent:
+ ret