aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/conf/files.amd644
-rw-r--r--sys/conf/files.arm644
-rw-r--r--sys/contrib/cloudabi/cloudabi_vdso_aarch64.S491
-rw-r--r--sys/contrib/cloudabi/cloudabi_vdso_aarch64.c1058
-rw-r--r--sys/contrib/cloudabi/cloudabi_vdso_x86_64.S511
-rw-r--r--sys/contrib/cloudabi/cloudabi_vdso_x86_64.c950
-rw-r--r--sys/modules/cloudabi64/Makefile8
7 files changed, 1009 insertions, 2017 deletions
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index b9c6c67f9665..7adceccdb64f 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -9,8 +9,8 @@
#
#
cloudabi64_vdso.o optional compat_cloudabi64 \
- dependency "$S/contrib/cloudabi/cloudabi_vdso_x86_64.c" \
- compile-with "${CC} -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi64/cloudabi64_vdso.lds.s -D_KERNEL -I. -I$S -I$S/contrib/cloudabi -O2 -fomit-frame-pointer $S/contrib/cloudabi/cloudabi_vdso_x86_64.c -o ${.TARGET}" \
+ dependency "$S/contrib/cloudabi/cloudabi_vdso_x86_64.S" \
+ compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi64/cloudabi64_vdso.lds.s $S/contrib/cloudabi/cloudabi_vdso_x86_64.S -o ${.TARGET}" \
no-obj no-implicit-rule \
clean "cloudabi64_vdso.o"
#
diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64
index 31acaf9ce32f..631dab2cb1f2 100644
--- a/sys/conf/files.arm64
+++ b/sys/conf/files.arm64
@@ -1,7 +1,7 @@
# $FreeBSD$
cloudabi64_vdso.o optional compat_cloudabi64 \
- dependency "$S/contrib/cloudabi/cloudabi_vdso_aarch64.c" \
- compile-with "${CC} -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi64/cloudabi64_vdso.lds.s -D_KERNEL -I. -I$S -I$S/contrib/cloudabi -O2 -fomit-frame-pointer $S/contrib/cloudabi/cloudabi_vdso_aarch64.c -o ${.TARGET}" \
+ dependency "$S/contrib/cloudabi/cloudabi_vdso_aarch64.S" \
+ compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi64/cloudabi64_vdso.lds.s $S/contrib/cloudabi/cloudabi_vdso_aarch64.S -o ${.TARGET}" \
no-obj no-implicit-rule \
clean "cloudabi64_vdso.o"
#
diff --git a/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S b/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S
new file mode 100644
index 000000000000..3acebc1b11ae
--- /dev/null
+++ b/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S
@@ -0,0 +1,491 @@
+// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+// This file is automatically generated. Do not edit.
+//
+// Source: https://github.com/NuxiNL/cloudabi
+
+#define ENTRY(name) \
+ .text; \
+ .p2align 2; \
+ .global name; \
+ .type name, @function; \
+name:
+
+#define END(name) .size name, . - name
+
+ENTRY(cloudabi_sys_clock_res_get)
+ str x1, [sp, #-8]
+ mov w8, #0
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_clock_res_get)
+
+ENTRY(cloudabi_sys_clock_time_get)
+ str x2, [sp, #-8]
+ mov w8, #1
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_clock_time_get)
+
+ENTRY(cloudabi_sys_condvar_signal)
+ mov w8, #2
+ svc #0
+ ret
+END(cloudabi_sys_condvar_signal)
+
+ENTRY(cloudabi_sys_fd_close)
+ mov w8, #3
+ svc #0
+ ret
+END(cloudabi_sys_fd_close)
+
+ENTRY(cloudabi_sys_fd_create1)
+ str x1, [sp, #-8]
+ mov w8, #4
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str w0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_create1)
+
+ENTRY(cloudabi_sys_fd_create2)
+ stp x1, x2, [sp, #-16]
+ mov w8, #5
+ svc #0
+ ldp x2, x3, [sp, #-16]
+ b.cs 1f
+ str w0, [x2]
+ str w1, [x3]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_create2)
+
+ENTRY(cloudabi_sys_fd_datasync)
+ mov w8, #6
+ svc #0
+ ret
+END(cloudabi_sys_fd_datasync)
+
+ENTRY(cloudabi_sys_fd_dup)
+ str x1, [sp, #-8]
+ mov w8, #7
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str w0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_dup)
+
+ENTRY(cloudabi_sys_fd_pread)
+ str x4, [sp, #-8]
+ mov w8, #8
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_pread)
+
+ENTRY(cloudabi_sys_fd_pwrite)
+ str x4, [sp, #-8]
+ mov w8, #9
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_pwrite)
+
+ENTRY(cloudabi_sys_fd_read)
+ str x3, [sp, #-8]
+ mov w8, #10
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_read)
+
+ENTRY(cloudabi_sys_fd_replace)
+ mov w8, #11
+ svc #0
+ ret
+END(cloudabi_sys_fd_replace)
+
+ENTRY(cloudabi_sys_fd_seek)
+ str x3, [sp, #-8]
+ mov w8, #12
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_seek)
+
+ENTRY(cloudabi_sys_fd_stat_get)
+ mov w8, #13
+ svc #0
+ ret
+END(cloudabi_sys_fd_stat_get)
+
+ENTRY(cloudabi_sys_fd_stat_put)
+ mov w8, #14
+ svc #0
+ ret
+END(cloudabi_sys_fd_stat_put)
+
+ENTRY(cloudabi_sys_fd_sync)
+ mov w8, #15
+ svc #0
+ ret
+END(cloudabi_sys_fd_sync)
+
+ENTRY(cloudabi_sys_fd_write)
+ str x3, [sp, #-8]
+ mov w8, #16
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_fd_write)
+
+ENTRY(cloudabi_sys_file_advise)
+ mov w8, #17
+ svc #0
+ ret
+END(cloudabi_sys_file_advise)
+
+ENTRY(cloudabi_sys_file_allocate)
+ mov w8, #18
+ svc #0
+ ret
+END(cloudabi_sys_file_allocate)
+
+ENTRY(cloudabi_sys_file_create)
+ mov w8, #19
+ svc #0
+ ret
+END(cloudabi_sys_file_create)
+
+ENTRY(cloudabi_sys_file_link)
+ mov w8, #20
+ svc #0
+ ret
+END(cloudabi_sys_file_link)
+
+ENTRY(cloudabi_sys_file_open)
+ str x5, [sp, #-8]
+ mov w8, #21
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str w0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_file_open)
+
+ENTRY(cloudabi_sys_file_readdir)
+ str x4, [sp, #-8]
+ mov w8, #22
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_file_readdir)
+
+ENTRY(cloudabi_sys_file_readlink)
+ str x5, [sp, #-8]
+ mov w8, #23
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_file_readlink)
+
+ENTRY(cloudabi_sys_file_rename)
+ mov w8, #24
+ svc #0
+ ret
+END(cloudabi_sys_file_rename)
+
+ENTRY(cloudabi_sys_file_stat_fget)
+ mov w8, #25
+ svc #0
+ ret
+END(cloudabi_sys_file_stat_fget)
+
+ENTRY(cloudabi_sys_file_stat_fput)
+ mov w8, #26
+ svc #0
+ ret
+END(cloudabi_sys_file_stat_fput)
+
+ENTRY(cloudabi_sys_file_stat_get)
+ mov w8, #27
+ svc #0
+ ret
+END(cloudabi_sys_file_stat_get)
+
+ENTRY(cloudabi_sys_file_stat_put)
+ mov w8, #28
+ svc #0
+ ret
+END(cloudabi_sys_file_stat_put)
+
+ENTRY(cloudabi_sys_file_symlink)
+ mov w8, #29
+ svc #0
+ ret
+END(cloudabi_sys_file_symlink)
+
+ENTRY(cloudabi_sys_file_unlink)
+ mov w8, #30
+ svc #0
+ ret
+END(cloudabi_sys_file_unlink)
+
+ENTRY(cloudabi_sys_lock_unlock)
+ mov w8, #31
+ svc #0
+ ret
+END(cloudabi_sys_lock_unlock)
+
+ENTRY(cloudabi_sys_mem_advise)
+ mov w8, #32
+ svc #0
+ ret
+END(cloudabi_sys_mem_advise)
+
+ENTRY(cloudabi_sys_mem_lock)
+ mov w8, #33
+ svc #0
+ ret
+END(cloudabi_sys_mem_lock)
+
+ENTRY(cloudabi_sys_mem_map)
+ str x6, [sp, #-8]
+ mov w8, #34
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_mem_map)
+
+ENTRY(cloudabi_sys_mem_protect)
+ mov w8, #35
+ svc #0
+ ret
+END(cloudabi_sys_mem_protect)
+
+ENTRY(cloudabi_sys_mem_sync)
+ mov w8, #36
+ svc #0
+ ret
+END(cloudabi_sys_mem_sync)
+
+ENTRY(cloudabi_sys_mem_unlock)
+ mov w8, #37
+ svc #0
+ ret
+END(cloudabi_sys_mem_unlock)
+
+ENTRY(cloudabi_sys_mem_unmap)
+ mov w8, #38
+ svc #0
+ ret
+END(cloudabi_sys_mem_unmap)
+
+ENTRY(cloudabi_sys_poll)
+ str x3, [sp, #-8]
+ mov w8, #39
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_poll)
+
+ENTRY(cloudabi_sys_poll_fd)
+ str x6, [sp, #-8]
+ mov w8, #40
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str x0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_poll_fd)
+
+ENTRY(cloudabi_sys_proc_exec)
+ mov w8, #41
+ svc #0
+ ret
+END(cloudabi_sys_proc_exec)
+
+ENTRY(cloudabi_sys_proc_exit)
+ mov w8, #42
+ svc #0
+END(cloudabi_sys_proc_exit)
+
+ENTRY(cloudabi_sys_proc_fork)
+ stp x0, x1, [sp, #-16]
+ mov w8, #43
+ svc #0
+ ldp x2, x3, [sp, #-16]
+ b.cs 1f
+ str w0, [x2]
+ str w1, [x3]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_proc_fork)
+
+ENTRY(cloudabi_sys_proc_raise)
+ mov w8, #44
+ svc #0
+ ret
+END(cloudabi_sys_proc_raise)
+
+ENTRY(cloudabi_sys_random_get)
+ mov w8, #45
+ svc #0
+ ret
+END(cloudabi_sys_random_get)
+
+ENTRY(cloudabi_sys_sock_accept)
+ str x2, [sp, #-8]
+ mov w8, #46
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str w0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_sock_accept)
+
+ENTRY(cloudabi_sys_sock_bind)
+ mov w8, #47
+ svc #0
+ ret
+END(cloudabi_sys_sock_bind)
+
+ENTRY(cloudabi_sys_sock_connect)
+ mov w8, #48
+ svc #0
+ ret
+END(cloudabi_sys_sock_connect)
+
+ENTRY(cloudabi_sys_sock_listen)
+ mov w8, #49
+ svc #0
+ ret
+END(cloudabi_sys_sock_listen)
+
+ENTRY(cloudabi_sys_sock_recv)
+ mov w8, #50
+ svc #0
+ ret
+END(cloudabi_sys_sock_recv)
+
+ENTRY(cloudabi_sys_sock_send)
+ mov w8, #51
+ svc #0
+ ret
+END(cloudabi_sys_sock_send)
+
+ENTRY(cloudabi_sys_sock_shutdown)
+ mov w8, #52
+ svc #0
+ ret
+END(cloudabi_sys_sock_shutdown)
+
+ENTRY(cloudabi_sys_sock_stat_get)
+ mov w8, #53
+ svc #0
+ ret
+END(cloudabi_sys_sock_stat_get)
+
+ENTRY(cloudabi_sys_thread_create)
+ str x1, [sp, #-8]
+ mov w8, #54
+ svc #0
+ ldr x2, [sp, #-8]
+ b.cs 1f
+ str w0, [x2]
+ mov w0, wzr
+1:
+ ret
+END(cloudabi_sys_thread_create)
+
+ENTRY(cloudabi_sys_thread_exit)
+ mov w8, #55
+ svc #0
+END(cloudabi_sys_thread_exit)
+
+ENTRY(cloudabi_sys_thread_yield)
+ mov w8, #56
+ svc #0
+ ret
+END(cloudabi_sys_thread_yield)
diff --git a/sys/contrib/cloudabi/cloudabi_vdso_aarch64.c b/sys/contrib/cloudabi/cloudabi_vdso_aarch64.c
deleted file mode 100644
index e6e14342d454..000000000000
--- a/sys/contrib/cloudabi/cloudabi_vdso_aarch64.c
+++ /dev/null
@@ -1,1058 +0,0 @@
-// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-//
-// This file is automatically generated. Do not edit.
-//
-// Source: https://github.com/NuxiNL/cloudabi
-
-#include <cloudabi_types.h>
-
-cloudabi_errno_t cloudabi_sys_clock_res_get(cloudabi_clockid_t clock_id,
- cloudabi_timestamp_t *resolution) {
- register uint64_t reg_x8 asm("x8") = 0;
- register uint64_t reg_x0 asm("x0") = (uint64_t)clock_id;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- if (okay) {
- *resolution = (cloudabi_timestamp_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_clock_time_get(cloudabi_clockid_t clock_id,
- cloudabi_timestamp_t precision,
- cloudabi_timestamp_t *time) {
- register uint64_t reg_x8 asm("x8") = 1;
- register uint64_t reg_x0 asm("x0") = (uint64_t)clock_id;
- register uint64_t reg_x1 asm("x1") = (uint64_t)precision;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *time = (cloudabi_timestamp_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_condvar_signal(_Atomic(cloudabi_condvar_t) *
- condvar,
- cloudabi_scope_t scope,
- cloudabi_nthreads_t nwaiters) {
- register uint64_t reg_x8 asm("x8") = 2;
- register uint64_t reg_x0 asm("x0") = (uint64_t)condvar;
- register uint64_t reg_x1 asm("x1") = (uint64_t)scope;
- register uint64_t reg_x2 asm("x2") = (uint64_t)nwaiters;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_close(cloudabi_fd_t fd) {
- register uint64_t reg_x8 asm("x8") = 3;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9",
- "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18",
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_create1(cloudabi_filetype_t type,
- cloudabi_fd_t *fd) {
- register uint64_t reg_x8 asm("x8") = 4;
- register uint64_t reg_x0 asm("x0") = (uint64_t)type;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_create2(cloudabi_filetype_t type,
- cloudabi_fd_t *fd1,
- cloudabi_fd_t *fd2) {
- register uint64_t reg_x8 asm("x8") = 5;
- register uint64_t reg_x0 asm("x0") = (uint64_t)type;
- register uint64_t reg_x1 asm("x1");
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0), "=r"(reg_x1)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *fd1 = (cloudabi_fd_t)reg_x0;
- *fd2 = (cloudabi_fd_t)reg_x1;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_datasync(cloudabi_fd_t fd) {
- register uint64_t reg_x8 asm("x8") = 6;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9",
- "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18",
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_dup(cloudabi_fd_t from, cloudabi_fd_t *fd) {
- register uint64_t reg_x8 asm("x8") = 7;
- register uint64_t reg_x0 asm("x0") = (uint64_t)from;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_pread(cloudabi_fd_t fd,
- const cloudabi_iovec_t *iov,
- size_t iovcnt,
- cloudabi_filesize_t offset,
- size_t *nread) {
- register uint64_t reg_x8 asm("x8") = 8;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
- register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
- register uint64_t reg_x3 asm("x3") = (uint64_t)offset;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5",
- "d6", "d7");
- if (okay) {
- *nread = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_pwrite(cloudabi_fd_t fd,
- const cloudabi_ciovec_t *iov,
- size_t iovcnt,
- cloudabi_filesize_t offset,
- size_t *nwritten) {
- register uint64_t reg_x8 asm("x8") = 9;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
- register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
- register uint64_t reg_x3 asm("x3") = (uint64_t)offset;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5",
- "d6", "d7");
- if (okay) {
- *nwritten = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_read(cloudabi_fd_t fd,
- const cloudabi_iovec_t *iov,
- size_t iovcnt, size_t *nread) {
- register uint64_t reg_x8 asm("x8") = 10;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
- register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *nread = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_replace(cloudabi_fd_t from, cloudabi_fd_t to) {
- register uint64_t reg_x8 asm("x8") = 11;
- register uint64_t reg_x0 asm("x0") = (uint64_t)from;
- register uint64_t reg_x1 asm("x1") = (uint64_t)to;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_seek(cloudabi_fd_t fd,
- cloudabi_filedelta_t offset,
- cloudabi_whence_t whence,
- cloudabi_filesize_t *newoffset) {
- register uint64_t reg_x8 asm("x8") = 12;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)offset;
- register uint64_t reg_x2 asm("x2") = (uint64_t)whence;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *newoffset = (cloudabi_filesize_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_stat_get(cloudabi_fd_t fd,
- cloudabi_fdstat_t *buf) {
- register uint64_t reg_x8 asm("x8") = 13;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_stat_put(cloudabi_fd_t fd,
- const cloudabi_fdstat_t *buf,
- cloudabi_fdsflags_t flags) {
- register uint64_t reg_x8 asm("x8") = 14;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_sync(cloudabi_fd_t fd) {
- register uint64_t reg_x8 asm("x8") = 15;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9",
- "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18",
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_write(cloudabi_fd_t fd,
- const cloudabi_ciovec_t *iov,
- size_t iovcnt, size_t *nwritten) {
- register uint64_t reg_x8 asm("x8") = 16;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)iov;
- register uint64_t reg_x2 asm("x2") = (uint64_t)iovcnt;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *nwritten = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_advise(cloudabi_fd_t fd,
- cloudabi_filesize_t offset,
- cloudabi_filesize_t len,
- cloudabi_advice_t advice) {
- register uint64_t reg_x8 asm("x8") = 17;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)offset;
- register uint64_t reg_x2 asm("x2") = (uint64_t)len;
- register uint64_t reg_x3 asm("x3") = (uint64_t)advice;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2",
- "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_allocate(cloudabi_fd_t fd,
- cloudabi_filesize_t offset,
- cloudabi_filesize_t len) {
- register uint64_t reg_x8 asm("x8") = 18;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)offset;
- register uint64_t reg_x2 asm("x2") = (uint64_t)len;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_create(cloudabi_fd_t fd, const char *path,
- size_t pathlen,
- cloudabi_filetype_t type) {
- register uint64_t reg_x8 asm("x8") = 19;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path;
- register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)type;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2",
- "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_link(cloudabi_lookup_t fd1,
- const char *path1, size_t path1len,
- cloudabi_fd_t fd2, const char *path2,
- size_t path2len) {
- register uint64_t reg_x8 asm("x8") = 20;
- register uint64_t reg_x0 asm("x0") = *(uint64_t *)&fd1;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path1;
- register uint64_t reg_x2 asm("x2") = (uint64_t)path1len;
- register uint64_t reg_x3 asm("x3") = (uint64_t)fd2;
- register uint64_t reg_x4 asm("x4") = (uint64_t)path2;
- register uint64_t reg_x5 asm("x5") = (uint64_t)path2len;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2),
- "r"(reg_x3), "r"(reg_x4), "r"(reg_x5)
- : "memory", "x6", "x7", "x9", "x10", "x11", "x12", "x13", "x14",
- "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5",
- "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_open(cloudabi_lookup_t dirfd,
- const char *path, size_t pathlen,
- cloudabi_oflags_t oflags,
- const cloudabi_fdstat_t *fds,
- cloudabi_fd_t *fd) {
- register uint64_t reg_x8 asm("x8") = 21;
- register uint64_t reg_x0 asm("x0") = *(uint64_t *)&dirfd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path;
- register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)oflags;
- register uint64_t reg_x4 asm("x4") = (uint64_t)fds;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3),
- "r"(reg_x4)
- : "memory", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13", "x14",
- "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5", "d6",
- "d7");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_readdir(cloudabi_fd_t fd, void *buf,
- size_t nbyte,
- cloudabi_dircookie_t cookie,
- size_t *bufused) {
- register uint64_t reg_x8 asm("x8") = 22;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- register uint64_t reg_x2 asm("x2") = (uint64_t)nbyte;
- register uint64_t reg_x3 asm("x3") = (uint64_t)cookie;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5",
- "d6", "d7");
- if (okay) {
- *bufused = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_readlink(cloudabi_fd_t fd, const char *path,
- size_t pathlen, char *buf,
- size_t bufsize, size_t *bufused) {
- register uint64_t reg_x8 asm("x8") = 23;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path;
- register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)buf;
- register uint64_t reg_x4 asm("x4") = (uint64_t)bufsize;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3),
- "r"(reg_x4)
- : "memory", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13", "x14",
- "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5", "d6",
- "d7");
- if (okay) {
- *bufused = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_rename(cloudabi_fd_t oldfd, const char *old,
- size_t oldlen, cloudabi_fd_t newfd,
- const char *new, size_t newlen) {
- register uint64_t reg_x8 asm("x8") = 24;
- register uint64_t reg_x0 asm("x0") = (uint64_t)oldfd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)old;
- register uint64_t reg_x2 asm("x2") = (uint64_t)oldlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)newfd;
- register uint64_t reg_x4 asm("x4") = (uint64_t) new;
- register uint64_t reg_x5 asm("x5") = (uint64_t)newlen;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2),
- "r"(reg_x3), "r"(reg_x4), "r"(reg_x5)
- : "memory", "x6", "x7", "x9", "x10", "x11", "x12", "x13", "x14",
- "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5",
- "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_fget(cloudabi_fd_t fd,
- cloudabi_filestat_t *buf) {
- register uint64_t reg_x8 asm("x8") = 25;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_fput(cloudabi_fd_t fd,
- const cloudabi_filestat_t *buf,
- cloudabi_fsflags_t flags) {
- register uint64_t reg_x8 asm("x8") = 26;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_get(cloudabi_lookup_t fd,
- const char *path, size_t pathlen,
- cloudabi_filestat_t *buf) {
- register uint64_t reg_x8 asm("x8") = 27;
- register uint64_t reg_x0 asm("x0") = *(uint64_t *)&fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path;
- register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)buf;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2",
- "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_put(cloudabi_lookup_t fd,
- const char *path, size_t pathlen,
- const cloudabi_filestat_t *buf,
- cloudabi_fsflags_t flags) {
- register uint64_t reg_x8 asm("x8") = 28;
- register uint64_t reg_x0 asm("x0") = *(uint64_t *)&fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path;
- register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)buf;
- register uint64_t reg_x4 asm("x4") = (uint64_t)flags;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2),
- "r"(reg_x3), "r"(reg_x4)
- : "memory", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_symlink(const char *path1, size_t path1len,
- cloudabi_fd_t fd, const char *path2,
- size_t path2len) {
- register uint64_t reg_x8 asm("x8") = 29;
- register uint64_t reg_x0 asm("x0") = (uint64_t)path1;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path1len;
- register uint64_t reg_x2 asm("x2") = (uint64_t)fd;
- register uint64_t reg_x3 asm("x3") = (uint64_t)path2;
- register uint64_t reg_x4 asm("x4") = (uint64_t)path2len;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2),
- "r"(reg_x3), "r"(reg_x4)
- : "memory", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_file_unlink(cloudabi_fd_t fd, const char *path,
- size_t pathlen,
- cloudabi_ulflags_t flags) {
- register uint64_t reg_x8 asm("x8") = 30;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)path;
- register uint64_t reg_x2 asm("x2") = (uint64_t)pathlen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)flags;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2",
- "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_lock_unlock(_Atomic(cloudabi_lock_t) * lock,
- cloudabi_scope_t scope) {
- register uint64_t reg_x8 asm("x8") = 31;
- register uint64_t reg_x0 asm("x0") = (uint64_t)lock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)scope;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_advise(void *addr, size_t len,
- cloudabi_advice_t advice) {
- register uint64_t reg_x8 asm("x8") = 32;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- register uint64_t reg_x2 asm("x2") = (uint64_t)advice;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_lock(const void *addr, size_t len) {
- register uint64_t reg_x8 asm("x8") = 33;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_map(void *addr, size_t len,
- cloudabi_mprot_t prot,
- cloudabi_mflags_t flags, cloudabi_fd_t fd,
- cloudabi_filesize_t off, void **mem) {
- register uint64_t reg_x8 asm("x8") = 34;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- register uint64_t reg_x2 asm("x2") = (uint64_t)prot;
- register uint64_t reg_x3 asm("x3") = (uint64_t)flags;
- register uint64_t reg_x4 asm("x4") = (uint64_t)fd;
- register uint64_t reg_x5 asm("x5") = (uint64_t)off;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3),
- "r"(reg_x4), "r"(reg_x5)
- : "memory", "x6", "x7", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
- "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- if (okay) {
- *mem = (void *)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_protect(void *addr, size_t len,
- cloudabi_mprot_t prot) {
- register uint64_t reg_x8 asm("x8") = 35;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- register uint64_t reg_x2 asm("x2") = (uint64_t)prot;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_sync(void *addr, size_t len,
- cloudabi_msflags_t flags) {
- register uint64_t reg_x8 asm("x8") = 36;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_unlock(const void *addr, size_t len) {
- register uint64_t reg_x8 asm("x8") = 37;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_unmap(void *addr, size_t len) {
- register uint64_t reg_x8 asm("x8") = 38;
- register uint64_t reg_x0 asm("x0") = (uint64_t)addr;
- register uint64_t reg_x1 asm("x1") = (uint64_t)len;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_poll(const cloudabi_subscription_t *in,
- cloudabi_event_t *out, size_t nsubscriptions,
- size_t *nevents) {
- register uint64_t reg_x8 asm("x8") = 39;
- register uint64_t reg_x0 asm("x0") = (uint64_t)in;
- register uint64_t reg_x1 asm("x1") = (uint64_t)out;
- register uint64_t reg_x2 asm("x2") = (uint64_t)nsubscriptions;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *nevents = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_poll_fd(cloudabi_fd_t fd,
- const cloudabi_subscription_t *in,
- size_t nin, cloudabi_event_t *out,
- size_t nout,
- const cloudabi_subscription_t *timeout,
- size_t *nevents) {
- register uint64_t reg_x8 asm("x8") = 40;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)in;
- register uint64_t reg_x2 asm("x2") = (uint64_t)nin;
- register uint64_t reg_x3 asm("x3") = (uint64_t)out;
- register uint64_t reg_x4 asm("x4") = (uint64_t)nout;
- register uint64_t reg_x5 asm("x5") = (uint64_t)timeout;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3),
- "r"(reg_x4), "r"(reg_x5)
- : "memory", "x6", "x7", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
- "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- if (okay) {
- *nevents = (size_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_proc_exec(cloudabi_fd_t fd, const void *data,
- size_t datalen,
- const cloudabi_fd_t *fds,
- size_t fdslen) {
- register uint64_t reg_x8 asm("x8") = 41;
- register uint64_t reg_x0 asm("x0") = (uint64_t)fd;
- register uint64_t reg_x1 asm("x1") = (uint64_t)data;
- register uint64_t reg_x2 asm("x2") = (uint64_t)datalen;
- register uint64_t reg_x3 asm("x3") = (uint64_t)fds;
- register uint64_t reg_x4 asm("x4") = (uint64_t)fdslen;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2),
- "r"(reg_x3), "r"(reg_x4)
- : "memory", "x5", "x6", "x7", "x9", "x10", "x11", "x12", "x13",
- "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-_Noreturn void cloudabi_sys_proc_exit(cloudabi_exitcode_t rval) {
- register uint64_t reg_x8 asm("x8") = 42;
- register uint64_t reg_x0 asm("x0") = (uint64_t)rval;
- asm volatile("\tsvc 0\n"
- :
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9",
- "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18",
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- for (;;)
- ;
-}
-
-cloudabi_errno_t cloudabi_sys_proc_fork(cloudabi_fd_t *fd,
- cloudabi_tid_t *tid) {
- register uint64_t reg_x8 asm("x8") = 43;
- register uint64_t reg_x0 asm("x0");
- register uint64_t reg_x1 asm("x1");
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0), "=r"(reg_x1)
- : "r"(reg_x8)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_x0;
- *tid = (cloudabi_tid_t)reg_x1;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_proc_raise(cloudabi_signal_t sig) {
- register uint64_t reg_x8 asm("x8") = 44;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sig;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9",
- "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18",
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_random_get(void *buf, size_t nbyte) {
- register uint64_t reg_x8 asm("x8") = 45;
- register uint64_t reg_x0 asm("x0") = (uint64_t)buf;
- register uint64_t reg_x1 asm("x1") = (uint64_t)nbyte;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_accept(cloudabi_fd_t sock,
- cloudabi_sockstat_t *buf,
- cloudabi_fd_t *conn) {
- register uint64_t reg_x8 asm("x8") = 46;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3", "d4",
- "d5", "d6", "d7");
- if (okay) {
- *conn = (cloudabi_fd_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_bind(cloudabi_fd_t sock, cloudabi_fd_t fd,
- const char *path, size_t pathlen) {
- register uint64_t reg_x8 asm("x8") = 47;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)fd;
- register uint64_t reg_x2 asm("x2") = (uint64_t)path;
- register uint64_t reg_x3 asm("x3") = (uint64_t)pathlen;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2",
- "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_connect(cloudabi_fd_t sock, cloudabi_fd_t fd,
- const char *path, size_t pathlen) {
- register uint64_t reg_x8 asm("x8") = 48;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)fd;
- register uint64_t reg_x2 asm("x2") = (uint64_t)path;
- register uint64_t reg_x3 asm("x3") = (uint64_t)pathlen;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2), "r"(reg_x3)
- : "memory", "x4", "x5", "x6", "x7", "x9", "x10", "x11", "x12",
- "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2",
- "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_listen(cloudabi_fd_t sock,
- cloudabi_backlog_t backlog) {
- register uint64_t reg_x8 asm("x8") = 49;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)backlog;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_recv(cloudabi_fd_t sock,
- const cloudabi_recv_in_t *in,
- cloudabi_recv_out_t *out) {
- register uint64_t reg_x8 asm("x8") = 50;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)in;
- register uint64_t reg_x2 asm("x2") = (uint64_t)out;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_send(cloudabi_fd_t sock,
- const cloudabi_send_in_t *in,
- cloudabi_send_out_t *out) {
- register uint64_t reg_x8 asm("x8") = 51;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)in;
- register uint64_t reg_x2 asm("x2") = (uint64_t)out;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_shutdown(cloudabi_fd_t sock,
- cloudabi_sdflags_t how) {
- register uint64_t reg_x8 asm("x8") = 52;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)how;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_stat_get(cloudabi_fd_t sock,
- cloudabi_sockstat_t *buf,
- cloudabi_ssflags_t flags) {
- register uint64_t reg_x8 asm("x8") = 53;
- register uint64_t reg_x0 asm("x0") = (uint64_t)sock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)buf;
- register uint64_t reg_x2 asm("x2") = (uint64_t)flags;
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1), "r"(reg_x2)
- : "memory", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1",
- "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
-
-cloudabi_errno_t cloudabi_sys_thread_create(cloudabi_threadattr_t *attr,
- cloudabi_tid_t *tid) {
- register uint64_t reg_x8 asm("x8") = 54;
- register uint64_t reg_x0 asm("x0") = (uint64_t)attr;
- register uint64_t okay;
- asm volatile(
- "\tsvc 0\n"
- "\tcset %0, cc\n"
- : "=r"(okay), "=r"(reg_x0)
- : "r"(reg_x8), "r"(reg_x0)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10", "x11",
- "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0", "d1", "d2", "d3",
- "d4", "d5", "d6", "d7");
- if (okay) {
- *tid = (cloudabi_tid_t)reg_x0;
- return 0;
- }
- return reg_x0;
-}
-
-_Noreturn void cloudabi_sys_thread_exit(_Atomic(cloudabi_lock_t) * lock,
- cloudabi_scope_t scope) {
- register uint64_t reg_x8 asm("x8") = 55;
- register uint64_t reg_x0 asm("x0") = (uint64_t)lock;
- register uint64_t reg_x1 asm("x1") = (uint64_t)scope;
- asm volatile("\tsvc 0\n"
- :
- : "r"(reg_x8), "r"(reg_x0), "r"(reg_x1)
- : "memory", "x2", "x3", "x4", "x5", "x6", "x7", "x9", "x10",
- "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "d0",
- "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- for (;;)
- ;
-}
-
-cloudabi_errno_t cloudabi_sys_thread_yield(void) {
- register uint64_t reg_x8 asm("x8") = 56;
- register uint64_t reg_x0 asm("x0");
- asm volatile("\tsvc 0\n"
- : "=r"(reg_x0)
- : "r"(reg_x8)
- : "memory", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x9",
- "x10", "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18",
- "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7");
- return reg_x0;
-}
diff --git a/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S b/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S
new file mode 100644
index 000000000000..049cb0d8a0cf
--- /dev/null
+++ b/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S
@@ -0,0 +1,511 @@
+// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE.
+//
+// This file is automatically generated. Do not edit.
+//
+// Source: https://github.com/NuxiNL/cloudabi
+
+#define ENTRY(name) \
+ .text; \
+ .p2align 4, 0x90; \
+ .global name; \
+ .type name, @function; \
+name:
+
+#define END(name) .size name, . - name
+
+ENTRY(cloudabi_sys_clock_res_get)
+ push %rsi
+ mov $0, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_clock_res_get)
+
+ENTRY(cloudabi_sys_clock_time_get)
+ push %rdx
+ mov $1, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_clock_time_get)
+
+ENTRY(cloudabi_sys_condvar_signal)
+ mov $2, %eax
+ syscall
+ ret
+END(cloudabi_sys_condvar_signal)
+
+ENTRY(cloudabi_sys_fd_close)
+ mov $3, %eax
+ syscall
+ ret
+END(cloudabi_sys_fd_close)
+
+ENTRY(cloudabi_sys_fd_create1)
+ push %rsi
+ mov $4, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_create1)
+
+ENTRY(cloudabi_sys_fd_create2)
+ push %rsi
+ push %rdx
+ mov $5, %eax
+ syscall
+ pop %rsi
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ mov %edx, (%rsi)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_create2)
+
+ENTRY(cloudabi_sys_fd_datasync)
+ mov $6, %eax
+ syscall
+ ret
+END(cloudabi_sys_fd_datasync)
+
+ENTRY(cloudabi_sys_fd_dup)
+ push %rsi
+ mov $7, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_dup)
+
+ENTRY(cloudabi_sys_fd_pread)
+ mov %rcx, %r10
+ push %r8
+ mov $8, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_pread)
+
+ENTRY(cloudabi_sys_fd_pwrite)
+ mov %rcx, %r10
+ push %r8
+ mov $9, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_pwrite)
+
+ENTRY(cloudabi_sys_fd_read)
+ push %rcx
+ mov $10, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_read)
+
+ENTRY(cloudabi_sys_fd_replace)
+ mov $11, %eax
+ syscall
+ ret
+END(cloudabi_sys_fd_replace)
+
+ENTRY(cloudabi_sys_fd_seek)
+ push %rcx
+ mov $12, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_seek)
+
+ENTRY(cloudabi_sys_fd_stat_get)
+ mov $13, %eax
+ syscall
+ ret
+END(cloudabi_sys_fd_stat_get)
+
+ENTRY(cloudabi_sys_fd_stat_put)
+ mov $14, %eax
+ syscall
+ ret
+END(cloudabi_sys_fd_stat_put)
+
+ENTRY(cloudabi_sys_fd_sync)
+ mov $15, %eax
+ syscall
+ ret
+END(cloudabi_sys_fd_sync)
+
+ENTRY(cloudabi_sys_fd_write)
+ push %rcx
+ mov $16, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_fd_write)
+
+ENTRY(cloudabi_sys_file_advise)
+ mov %rcx, %r10
+ mov $17, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_advise)
+
+ENTRY(cloudabi_sys_file_allocate)
+ mov $18, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_allocate)
+
+ENTRY(cloudabi_sys_file_create)
+ mov %rcx, %r10
+ mov $19, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_create)
+
+ENTRY(cloudabi_sys_file_link)
+ mov %rcx, %r10
+ mov $20, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_link)
+
+ENTRY(cloudabi_sys_file_open)
+ mov %rcx, %r10
+ push %r9
+ mov $21, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_file_open)
+
+ENTRY(cloudabi_sys_file_readdir)
+ mov %rcx, %r10
+ push %r8
+ mov $22, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_file_readdir)
+
+ENTRY(cloudabi_sys_file_readlink)
+ mov %rcx, %r10
+ push %r9
+ mov $23, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_file_readlink)
+
+ENTRY(cloudabi_sys_file_rename)
+ mov %rcx, %r10
+ mov $24, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_rename)
+
+ENTRY(cloudabi_sys_file_stat_fget)
+ mov $25, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_stat_fget)
+
+ENTRY(cloudabi_sys_file_stat_fput)
+ mov $26, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_stat_fput)
+
+ENTRY(cloudabi_sys_file_stat_get)
+ mov %rcx, %r10
+ mov $27, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_stat_get)
+
+ENTRY(cloudabi_sys_file_stat_put)
+ mov %rcx, %r10
+ mov $28, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_stat_put)
+
+ENTRY(cloudabi_sys_file_symlink)
+ mov %rcx, %r10
+ mov $29, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_symlink)
+
+ENTRY(cloudabi_sys_file_unlink)
+ mov %rcx, %r10
+ mov $30, %eax
+ syscall
+ ret
+END(cloudabi_sys_file_unlink)
+
+ENTRY(cloudabi_sys_lock_unlock)
+ mov $31, %eax
+ syscall
+ ret
+END(cloudabi_sys_lock_unlock)
+
+ENTRY(cloudabi_sys_mem_advise)
+ mov $32, %eax
+ syscall
+ ret
+END(cloudabi_sys_mem_advise)
+
+ENTRY(cloudabi_sys_mem_lock)
+ mov $33, %eax
+ syscall
+ ret
+END(cloudabi_sys_mem_lock)
+
+ENTRY(cloudabi_sys_mem_map)
+ mov %rcx, %r10
+ mov $34, %eax
+ syscall
+ jc 1f
+ mov 8(%rsp), %rcx
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_mem_map)
+
+ENTRY(cloudabi_sys_mem_protect)
+ mov $35, %eax
+ syscall
+ ret
+END(cloudabi_sys_mem_protect)
+
+ENTRY(cloudabi_sys_mem_sync)
+ mov $36, %eax
+ syscall
+ ret
+END(cloudabi_sys_mem_sync)
+
+ENTRY(cloudabi_sys_mem_unlock)
+ mov $37, %eax
+ syscall
+ ret
+END(cloudabi_sys_mem_unlock)
+
+ENTRY(cloudabi_sys_mem_unmap)
+ mov $38, %eax
+ syscall
+ ret
+END(cloudabi_sys_mem_unmap)
+
+ENTRY(cloudabi_sys_poll)
+ push %rcx
+ mov $39, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_poll)
+
+ENTRY(cloudabi_sys_poll_fd)
+ mov %rcx, %r10
+ mov $40, %eax
+ syscall
+ jc 1f
+ mov 8(%rsp), %rcx
+ mov %rax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_poll_fd)
+
+ENTRY(cloudabi_sys_proc_exec)
+ mov %rcx, %r10
+ mov $41, %eax
+ syscall
+ ret
+END(cloudabi_sys_proc_exec)
+
+ENTRY(cloudabi_sys_proc_exit)
+ mov $42, %eax
+ syscall
+END(cloudabi_sys_proc_exit)
+
+ENTRY(cloudabi_sys_proc_fork)
+ push %rdi
+ push %rsi
+ mov $43, %eax
+ syscall
+ pop %rsi
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ mov %edx, (%rsi)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_proc_fork)
+
+ENTRY(cloudabi_sys_proc_raise)
+ mov $44, %eax
+ syscall
+ ret
+END(cloudabi_sys_proc_raise)
+
+ENTRY(cloudabi_sys_random_get)
+ mov $45, %eax
+ syscall
+ ret
+END(cloudabi_sys_random_get)
+
+ENTRY(cloudabi_sys_sock_accept)
+ push %rdx
+ mov $46, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_sock_accept)
+
+ENTRY(cloudabi_sys_sock_bind)
+ mov %rcx, %r10
+ mov $47, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_bind)
+
+ENTRY(cloudabi_sys_sock_connect)
+ mov %rcx, %r10
+ mov $48, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_connect)
+
+ENTRY(cloudabi_sys_sock_listen)
+ mov $49, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_listen)
+
+ENTRY(cloudabi_sys_sock_recv)
+ mov $50, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_recv)
+
+ENTRY(cloudabi_sys_sock_send)
+ mov $51, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_send)
+
+ENTRY(cloudabi_sys_sock_shutdown)
+ mov $52, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_shutdown)
+
+ENTRY(cloudabi_sys_sock_stat_get)
+ mov $53, %eax
+ syscall
+ ret
+END(cloudabi_sys_sock_stat_get)
+
+ENTRY(cloudabi_sys_thread_create)
+ push %rsi
+ mov $54, %eax
+ syscall
+ pop %rcx
+ jc 1f
+ mov %eax, (%rcx)
+ xor %eax, %eax
+1:
+ ret
+END(cloudabi_sys_thread_create)
+
+ENTRY(cloudabi_sys_thread_exit)
+ mov $55, %eax
+ syscall
+END(cloudabi_sys_thread_exit)
+
+ENTRY(cloudabi_sys_thread_yield)
+ mov $56, %eax
+ syscall
+ ret
+END(cloudabi_sys_thread_yield)
diff --git a/sys/contrib/cloudabi/cloudabi_vdso_x86_64.c b/sys/contrib/cloudabi/cloudabi_vdso_x86_64.c
deleted file mode 100644
index a493d716bb52..000000000000
--- a/sys/contrib/cloudabi/cloudabi_vdso_x86_64.c
+++ /dev/null
@@ -1,950 +0,0 @@
-// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-// 1. Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE.
-//
-// This file is automatically generated. Do not edit.
-//
-// Source: https://github.com/NuxiNL/cloudabi
-
-#include <cloudabi_types.h>
-
-cloudabi_errno_t cloudabi_sys_clock_res_get(cloudabi_clockid_t clock_id,
- cloudabi_timestamp_t *resolution) {
- register uint64_t reg_rax asm("rax") = 0;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)clock_id;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- if (okay) {
- *resolution = (cloudabi_timestamp_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_clock_time_get(cloudabi_clockid_t clock_id,
- cloudabi_timestamp_t precision,
- cloudabi_timestamp_t *time) {
- register uint64_t reg_rax asm("rax") = 1;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)clock_id;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)precision;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- if (okay) {
- *time = (cloudabi_timestamp_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_condvar_signal(_Atomic(cloudabi_condvar_t) *
- condvar,
- cloudabi_scope_t scope,
- cloudabi_nthreads_t nwaiters) {
- register uint64_t reg_rax asm("rax") = 2;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)condvar;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)scope;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)nwaiters;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_close(cloudabi_fd_t fd) {
- register uint64_t reg_rax asm("rax") = 3;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_create1(cloudabi_filetype_t type,
- cloudabi_fd_t *fd) {
- register uint64_t reg_rax asm("rax") = 4;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)type;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_create2(cloudabi_filetype_t type,
- cloudabi_fd_t *fd1,
- cloudabi_fd_t *fd2) {
- register uint64_t reg_rax asm("rax") = 5;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)type;
- register uint64_t reg_rdx asm("rdx");
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax), "=r"(reg_rdx)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- if (okay) {
- *fd1 = (cloudabi_fd_t)reg_rax;
- *fd2 = (cloudabi_fd_t)reg_rdx;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_datasync(cloudabi_fd_t fd) {
- register uint64_t reg_rax asm("rax") = 6;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_dup(cloudabi_fd_t from, cloudabi_fd_t *fd) {
- register uint64_t reg_rax asm("rax") = 7;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)from;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_pread(cloudabi_fd_t fd,
- const cloudabi_iovec_t *iov,
- size_t iovcnt,
- cloudabi_filesize_t offset,
- size_t *nread) {
- register uint64_t reg_rax asm("rax") = 8;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)iov;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)iovcnt;
- register uint64_t reg_r10 asm("r10") = (uint64_t)offset;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- if (okay) {
- *nread = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_pwrite(cloudabi_fd_t fd,
- const cloudabi_ciovec_t *iov,
- size_t iovcnt,
- cloudabi_filesize_t offset,
- size_t *nwritten) {
- register uint64_t reg_rax asm("rax") = 9;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)iov;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)iovcnt;
- register uint64_t reg_r10 asm("r10") = (uint64_t)offset;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- if (okay) {
- *nwritten = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_read(cloudabi_fd_t fd,
- const cloudabi_iovec_t *iov,
- size_t iovcnt, size_t *nread) {
- register uint64_t reg_rax asm("rax") = 10;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)iov;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)iovcnt;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- if (okay) {
- *nread = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_replace(cloudabi_fd_t from, cloudabi_fd_t to) {
- register uint64_t reg_rax asm("rax") = 11;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)from;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)to;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_seek(cloudabi_fd_t fd,
- cloudabi_filedelta_t offset,
- cloudabi_whence_t whence,
- cloudabi_filesize_t *newoffset) {
- register uint64_t reg_rax asm("rax") = 12;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)offset;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)whence;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- if (okay) {
- *newoffset = (cloudabi_filesize_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_stat_get(cloudabi_fd_t fd,
- cloudabi_fdstat_t *buf) {
- register uint64_t reg_rax asm("rax") = 13;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_stat_put(cloudabi_fd_t fd,
- const cloudabi_fdstat_t *buf,
- cloudabi_fdsflags_t flags) {
- register uint64_t reg_rax asm("rax") = 14;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)flags;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_sync(cloudabi_fd_t fd) {
- register uint64_t reg_rax asm("rax") = 15;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_fd_write(cloudabi_fd_t fd,
- const cloudabi_ciovec_t *iov,
- size_t iovcnt, size_t *nwritten) {
- register uint64_t reg_rax asm("rax") = 16;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)iov;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)iovcnt;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- if (okay) {
- *nwritten = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_advise(cloudabi_fd_t fd,
- cloudabi_filesize_t offset,
- cloudabi_filesize_t len,
- cloudabi_advice_t advice) {
- register uint64_t reg_rax asm("rax") = 17;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)offset;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)len;
- register uint64_t reg_r10 asm("r10") = (uint64_t)advice;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_allocate(cloudabi_fd_t fd,
- cloudabi_filesize_t offset,
- cloudabi_filesize_t len) {
- register uint64_t reg_rax asm("rax") = 18;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)offset;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)len;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_create(cloudabi_fd_t fd, const char *path,
- size_t pathlen,
- cloudabi_filetype_t type) {
- register uint64_t reg_rax asm("rax") = 19;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)pathlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)type;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_link(cloudabi_lookup_t fd1,
- const char *path1, size_t path1len,
- cloudabi_fd_t fd2, const char *path2,
- size_t path2len) {
- register uint64_t reg_rax asm("rax") = 20;
- register uint64_t reg_rdi asm("rdi") = *(uint64_t *)&fd1;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path1;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)path1len;
- register uint64_t reg_r10 asm("r10") = (uint64_t)fd2;
- register uint64_t reg_r8 asm("r8") = (uint64_t)path2;
- register uint64_t reg_r9 asm("r9") = (uint64_t)path2len;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10), "r"(reg_r8), "r"(reg_r9)
- : "memory", "rcx", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_open(cloudabi_lookup_t dirfd,
- const char *path, size_t pathlen,
- cloudabi_oflags_t oflags,
- const cloudabi_fdstat_t *fds,
- cloudabi_fd_t *fd) {
- register uint64_t reg_rax asm("rax") = 21;
- register uint64_t reg_rdi asm("rdi") = *(uint64_t *)&dirfd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)pathlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)oflags;
- register uint64_t reg_r8 asm("r8") = (uint64_t)fds;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10),
- "r"(reg_r8)
- : "memory", "rcx", "r9", "r11");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_readdir(cloudabi_fd_t fd, void *buf,
- size_t nbyte,
- cloudabi_dircookie_t cookie,
- size_t *bufused) {
- register uint64_t reg_rax asm("rax") = 22;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)nbyte;
- register uint64_t reg_r10 asm("r10") = (uint64_t)cookie;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- if (okay) {
- *bufused = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_readlink(cloudabi_fd_t fd, const char *path,
- size_t pathlen, char *buf,
- size_t bufsize, size_t *bufused) {
- register uint64_t reg_rax asm("rax") = 23;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)pathlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)buf;
- register uint64_t reg_r8 asm("r8") = (uint64_t)bufsize;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10),
- "r"(reg_r8)
- : "memory", "rcx", "r9", "r11");
- if (okay) {
- *bufused = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_rename(cloudabi_fd_t oldfd, const char *old,
- size_t oldlen, cloudabi_fd_t newfd,
- const char *new, size_t newlen) {
- register uint64_t reg_rax asm("rax") = 24;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)oldfd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)old;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)oldlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)newfd;
- register uint64_t reg_r8 asm("r8") = (uint64_t) new;
- register uint64_t reg_r9 asm("r9") = (uint64_t)newlen;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10), "r"(reg_r8), "r"(reg_r9)
- : "memory", "rcx", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_fget(cloudabi_fd_t fd,
- cloudabi_filestat_t *buf) {
- register uint64_t reg_rax asm("rax") = 25;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_fput(cloudabi_fd_t fd,
- const cloudabi_filestat_t *buf,
- cloudabi_fsflags_t flags) {
- register uint64_t reg_rax asm("rax") = 26;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)flags;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_get(cloudabi_lookup_t fd,
- const char *path, size_t pathlen,
- cloudabi_filestat_t *buf) {
- register uint64_t reg_rax asm("rax") = 27;
- register uint64_t reg_rdi asm("rdi") = *(uint64_t *)&fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)pathlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)buf;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_stat_put(cloudabi_lookup_t fd,
- const char *path, size_t pathlen,
- const cloudabi_filestat_t *buf,
- cloudabi_fsflags_t flags) {
- register uint64_t reg_rax asm("rax") = 28;
- register uint64_t reg_rdi asm("rdi") = *(uint64_t *)&fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)pathlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)buf;
- register uint64_t reg_r8 asm("r8") = (uint64_t)flags;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10), "r"(reg_r8)
- : "memory", "rcx", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_symlink(const char *path1, size_t path1len,
- cloudabi_fd_t fd, const char *path2,
- size_t path2len) {
- register uint64_t reg_rax asm("rax") = 29;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)path1;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path1len;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)fd;
- register uint64_t reg_r10 asm("r10") = (uint64_t)path2;
- register uint64_t reg_r8 asm("r8") = (uint64_t)path2len;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10), "r"(reg_r8)
- : "memory", "rcx", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_file_unlink(cloudabi_fd_t fd, const char *path,
- size_t pathlen,
- cloudabi_ulflags_t flags) {
- register uint64_t reg_rax asm("rax") = 30;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)path;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)pathlen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)flags;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_lock_unlock(_Atomic(cloudabi_lock_t) * lock,
- cloudabi_scope_t scope) {
- register uint64_t reg_rax asm("rax") = 31;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)lock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)scope;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_advise(void *addr, size_t len,
- cloudabi_advice_t advice) {
- register uint64_t reg_rax asm("rax") = 32;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)advice;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_lock(const void *addr, size_t len) {
- register uint64_t reg_rax asm("rax") = 33;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_map(void *addr, size_t len,
- cloudabi_mprot_t prot,
- cloudabi_mflags_t flags, cloudabi_fd_t fd,
- cloudabi_filesize_t off, void **mem) {
- register uint64_t reg_rax asm("rax") = 34;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)prot;
- register uint64_t reg_r10 asm("r10") = (uint64_t)flags;
- register uint64_t reg_r8 asm("r8") = (uint64_t)fd;
- register uint64_t reg_r9 asm("r9") = (uint64_t)off;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10),
- "r"(reg_r8), "r"(reg_r9)
- : "memory", "rcx", "r11");
- if (okay) {
- *mem = (void *)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_protect(void *addr, size_t len,
- cloudabi_mprot_t prot) {
- register uint64_t reg_rax asm("rax") = 35;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)prot;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_sync(void *addr, size_t len,
- cloudabi_msflags_t flags) {
- register uint64_t reg_rax asm("rax") = 36;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)flags;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_unlock(const void *addr, size_t len) {
- register uint64_t reg_rax asm("rax") = 37;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_mem_unmap(void *addr, size_t len) {
- register uint64_t reg_rax asm("rax") = 38;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)addr;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)len;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_poll(const cloudabi_subscription_t *in,
- cloudabi_event_t *out, size_t nsubscriptions,
- size_t *nevents) {
- register uint64_t reg_rax asm("rax") = 39;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)in;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)out;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)nsubscriptions;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- if (okay) {
- *nevents = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_poll_fd(cloudabi_fd_t fd,
- const cloudabi_subscription_t *in,
- size_t nin, cloudabi_event_t *out,
- size_t nout,
- const cloudabi_subscription_t *timeout,
- size_t *nevents) {
- register uint64_t reg_rax asm("rax") = 40;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)in;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)nin;
- register uint64_t reg_r10 asm("r10") = (uint64_t)out;
- register uint64_t reg_r8 asm("r8") = (uint64_t)nout;
- register uint64_t reg_r9 asm("r9") = (uint64_t)timeout;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx), "r"(reg_r10),
- "r"(reg_r8), "r"(reg_r9)
- : "memory", "rcx", "r11");
- if (okay) {
- *nevents = (size_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_proc_exec(cloudabi_fd_t fd, const void *data,
- size_t datalen,
- const cloudabi_fd_t *fds,
- size_t fdslen) {
- register uint64_t reg_rax asm("rax") = 41;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)fd;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)data;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)datalen;
- register uint64_t reg_r10 asm("r10") = (uint64_t)fds;
- register uint64_t reg_r8 asm("r8") = (uint64_t)fdslen;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10), "r"(reg_r8)
- : "memory", "rcx", "r9", "r11");
- return reg_rax;
-}
-
-_Noreturn void cloudabi_sys_proc_exit(cloudabi_exitcode_t rval) {
- register uint64_t reg_rax asm("rax") = 42;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)rval;
- asm volatile("\tsyscall\n"
- :
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- for (;;)
- ;
-}
-
-cloudabi_errno_t cloudabi_sys_proc_fork(cloudabi_fd_t *fd,
- cloudabi_tid_t *tid) {
- register uint64_t reg_rax asm("rax") = 43;
- register uint64_t reg_rdx asm("rdx");
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax), "=r"(reg_rdx)
- : "r"(reg_rax)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- if (okay) {
- *fd = (cloudabi_fd_t)reg_rax;
- *tid = (cloudabi_tid_t)reg_rdx;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_proc_raise(cloudabi_signal_t sig) {
- register uint64_t reg_rax asm("rax") = 44;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sig;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_random_get(void *buf, size_t nbyte) {
- register uint64_t reg_rax asm("rax") = 45;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)buf;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)nbyte;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_accept(cloudabi_fd_t sock,
- cloudabi_sockstat_t *buf,
- cloudabi_fd_t *conn) {
- register uint64_t reg_rax asm("rax") = 46;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- if (okay) {
- *conn = (cloudabi_fd_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_bind(cloudabi_fd_t sock, cloudabi_fd_t fd,
- const char *path, size_t pathlen) {
- register uint64_t reg_rax asm("rax") = 47;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)fd;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)path;
- register uint64_t reg_r10 asm("r10") = (uint64_t)pathlen;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_connect(cloudabi_fd_t sock, cloudabi_fd_t fd,
- const char *path, size_t pathlen) {
- register uint64_t reg_rax asm("rax") = 48;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)fd;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)path;
- register uint64_t reg_r10 asm("r10") = (uint64_t)pathlen;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx),
- "r"(reg_r10)
- : "memory", "rcx", "r8", "r9", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_listen(cloudabi_fd_t sock,
- cloudabi_backlog_t backlog) {
- register uint64_t reg_rax asm("rax") = 49;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)backlog;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_recv(cloudabi_fd_t sock,
- const cloudabi_recv_in_t *in,
- cloudabi_recv_out_t *out) {
- register uint64_t reg_rax asm("rax") = 50;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)in;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)out;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_send(cloudabi_fd_t sock,
- const cloudabi_send_in_t *in,
- cloudabi_send_out_t *out) {
- register uint64_t reg_rax asm("rax") = 51;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)in;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)out;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_shutdown(cloudabi_fd_t sock,
- cloudabi_sdflags_t how) {
- register uint64_t reg_rax asm("rax") = 52;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)how;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_sock_stat_get(cloudabi_fd_t sock,
- cloudabi_sockstat_t *buf,
- cloudabi_ssflags_t flags) {
- register uint64_t reg_rax asm("rax") = 53;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)sock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)buf;
- register uint64_t reg_rdx asm("rdx") = (uint64_t)flags;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi), "r"(reg_rdx)
- : "memory", "rcx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
-
-cloudabi_errno_t cloudabi_sys_thread_create(cloudabi_threadattr_t *attr,
- cloudabi_tid_t *tid) {
- register uint64_t reg_rax asm("rax") = 54;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)attr;
- register char okay;
- asm volatile(
- "\tsyscall\n"
- "\tsetnc %0\n"
- : "=r"(okay), "=r"(reg_rax)
- : "r"(reg_rax), "r"(reg_rdi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- if (okay) {
- *tid = (cloudabi_tid_t)reg_rax;
- return 0;
- }
- return reg_rax;
-}
-
-_Noreturn void cloudabi_sys_thread_exit(_Atomic(cloudabi_lock_t) * lock,
- cloudabi_scope_t scope) {
- register uint64_t reg_rax asm("rax") = 55;
- register uint64_t reg_rdi asm("rdi") = (uint64_t)lock;
- register uint64_t reg_rsi asm("rsi") = (uint64_t)scope;
- asm volatile("\tsyscall\n"
- :
- : "r"(reg_rax), "r"(reg_rdi), "r"(reg_rsi)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- for (;;)
- ;
-}
-
-cloudabi_errno_t cloudabi_sys_thread_yield(void) {
- register uint64_t reg_rax asm("rax") = 56;
- asm volatile("\tsyscall\n"
- : "=r"(reg_rax)
- : "r"(reg_rax)
- : "memory", "rcx", "rdx", "r8", "r9", "r10", "r11");
- return reg_rax;
-}
diff --git a/sys/modules/cloudabi64/Makefile b/sys/modules/cloudabi64/Makefile
index b6fe38057ba8..a82e836799ab 100644
--- a/sys/modules/cloudabi64/Makefile
+++ b/sys/modules/cloudabi64/Makefile
@@ -14,20 +14,18 @@ OBJS= cloudabi64_vdso_blob.o
CLEANFILES=cloudabi64_vdso.o
.if ${MACHINE_CPUARCH} == "aarch64"
-VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_aarch64.c
+VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_aarch64.S
OUTPUT_TARGET=elf64-littleaarch64
BINARY_ARCHITECTURE=aarch64
.elif ${MACHINE_CPUARCH} == "amd64"
-VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_x86_64.c
+VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_x86_64.S
OUTPUT_TARGET=elf64-x86-64-freebsd
BINARY_ARCHITECTURE=i386
.endif
cloudabi64_vdso.o: ${VDSO_SRCS}
- ${CC} -shared -nostdinc -nostdlib \
+ ${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib \
-Wl,-T${SYSDIR}/compat/cloudabi64/cloudabi64_vdso.lds.s \
- -D_KERNEL -I. -I${SYSDIR} -I${SYSDIR}/contrib/cloudabi \
- -O2 -fomit-frame-pointer \
${VDSO_SRCS} -o ${.TARGET}
cloudabi64_vdso_blob.o: cloudabi64_vdso.o