summaryrefslogtreecommitdiff
path: root/lib/sys/syscall+openbsd-x64.s
diff options
context:
space:
mode:
authorAndrew Chambers <andrewchamberss@gmail.com>2016-01-16 13:35:11 +1300
committerOri Bernstein <ori@eigenstate.org>2016-05-08 17:20:43 +1200
commit79c93065bf8467896e078459a91e36dc66ddaaeb (patch)
tree029fdf5f2761fc8a82c112d8bde84d9212cb287e /lib/sys/syscall+openbsd-x64.s
parentb332e98485d1c22cb93f3302b83ead9e004d5160 (diff)
downloadmc-79c93065bf8467896e078459a91e36dc66ddaaeb.tar.gz
Add initial openbsd skeleton
Diffstat (limited to 'lib/sys/syscall+openbsd-x64.s')
-rw-r--r--lib/sys/syscall+openbsd-x64.s43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/sys/syscall+openbsd-x64.s b/lib/sys/syscall+openbsd-x64.s
new file mode 100644
index 0000000..8e560c2
--- /dev/null
+++ b/lib/sys/syscall+openbsd-x64.s
@@ -0,0 +1,43 @@
+.globl sys$syscall
+sys$syscall:
+ /*
+ hack: We load 6 args regardless of
+ how many we actually have. This may
+ load junk values, but if the syscall
+ doesn't use them, it's going to be
+ harmless.
+ */
+ movq %rdi,%rax
+ /* 8(%rsp): hidden type arg */
+ movq 16(%rsp),%rdi
+ movq 24(%rsp),%rsi
+ movq 32(%rsp),%rdx
+ movq 40(%rsp),%r10
+ movq 48(%rsp),%r8
+ movq 56(%rsp),%r9
+
+ syscall
+ jae .success
+ negq %rax
+
+.success:
+ ret
+
+/*
+ * pipe() syscall returns the pipes created in eax:edx, and
+ * needs to copy them to the destination locations manually.
+ */
+.globl sys$__freebsd_pipe
+sys$__freebsd_pipe:
+ movq $0x2a,%rax
+ syscall
+
+ jae .pipesuccess
+ negq %rax
+
+.pipesuccess:
+ movl %eax,(%rdi)
+ movl %edx,4(%rdi)
+ xorq %rax,%rax
+ ret
+