summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/cloudabi/cloudabi_clock.c4
-rw-r--r--sys/compat/cloudabi/cloudabi_thread.c8
-rw-r--r--sys/compat/cloudabi/cloudabi_util.h5
-rw-r--r--sys/compat/cloudabi/cloudabi_vdso.c88
-rw-r--r--sys/compat/cloudabi/cloudabi_vdso.lds51
-rw-r--r--sys/compat/cloudabi32/Makefile14
-rw-r--r--sys/compat/cloudabi32/cloudabi32_fd.c145
-rw-r--r--sys/compat/cloudabi32/cloudabi32_module.c167
-rw-r--r--sys/compat/cloudabi32/cloudabi32_poll.c408
-rw-r--r--sys/compat/cloudabi32/cloudabi32_proto.h465
-rw-r--r--sys/compat/cloudabi32/cloudabi32_sock.c148
-rw-r--r--sys/compat/cloudabi32/cloudabi32_syscall.h66
-rw-r--r--sys/compat/cloudabi32/cloudabi32_syscalls.c67
-rw-r--r--sys/compat/cloudabi32/cloudabi32_sysent.c75
-rw-r--r--sys/compat/cloudabi32/cloudabi32_systrace_args.c1702
-rw-r--r--sys/compat/cloudabi32/cloudabi32_thread.c77
-rw-r--r--sys/compat/cloudabi32/cloudabi32_util.h51
-rw-r--r--sys/compat/cloudabi32/syscalls.conf15
-rw-r--r--sys/compat/cloudabi64/Makefile4
-rw-r--r--sys/compat/cloudabi64/cloudabi64_fd.c11
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c11
-rw-r--r--sys/compat/cloudabi64/cloudabi64_poll.c19
-rw-r--r--sys/compat/cloudabi64/cloudabi64_proto.h33
-rw-r--r--sys/compat/cloudabi64/cloudabi64_sock.c15
-rw-r--r--sys/compat/cloudabi64/cloudabi64_syscall.h37
-rw-r--r--sys/compat/cloudabi64/cloudabi64_syscalls.c35
-rw-r--r--sys/compat/cloudabi64/cloudabi64_sysent.c35
-rw-r--r--sys/compat/cloudabi64/cloudabi64_systrace_args.c194
-rw-r--r--sys/compat/cloudabi64/cloudabi64_util.h3
-rw-r--r--sys/compat/ia32/ia32_signal.h2
-rw-r--r--sys/compat/linuxkpi/common/include/linux/pci.h34
31 files changed, 3768 insertions, 221 deletions
diff --git a/sys/compat/cloudabi/cloudabi_clock.c b/sys/compat/cloudabi/cloudabi_clock.c
index b26d98e..ce53a11 100644
--- a/sys/compat/cloudabi/cloudabi_clock.c
+++ b/sys/compat/cloudabi/cloudabi_clock.c
@@ -117,7 +117,7 @@ cloudabi_sys_clock_res_get(struct thread *td,
error = cloudabi_convert_timespec(&ts, &cts);
if (error != 0)
return (error);
- td->td_retval[0] = cts;
+ memcpy(td->td_retval, &cts, sizeof(cts));
return (0);
}
@@ -129,6 +129,6 @@ cloudabi_sys_clock_time_get(struct thread *td,
int error;
error = cloudabi_clock_time_get(td, uap->clock_id, &ts);
- td->td_retval[0] = ts;
+ memcpy(td->td_retval, &ts, sizeof(ts));
return (error);
}
diff --git a/sys/compat/cloudabi/cloudabi_thread.c b/sys/compat/cloudabi/cloudabi_thread.c
index dd54e89..e70549b 100644
--- a/sys/compat/cloudabi/cloudabi_thread.c
+++ b/sys/compat/cloudabi/cloudabi_thread.c
@@ -60,14 +60,6 @@ cloudabi_sys_thread_exit(struct thread *td,
}
int
-cloudabi_sys_thread_tcb_set(struct thread *td,
- struct cloudabi_sys_thread_tcb_set_args *uap)
-{
-
- return (cpu_set_user_tls(td, uap->tcb));
-}
-
-int
cloudabi_sys_thread_yield(struct thread *td,
struct cloudabi_sys_thread_yield_args *uap)
{
diff --git a/sys/compat/cloudabi/cloudabi_util.h b/sys/compat/cloudabi/cloudabi_util.h
index c0a02aa..6eb65aa 100644
--- a/sys/compat/cloudabi/cloudabi_util.h
+++ b/sys/compat/cloudabi/cloudabi_util.h
@@ -33,6 +33,7 @@
#include <contrib/cloudabi/cloudabi_types_common.h>
struct file;
+struct sysentvec;
struct thread;
struct timespec;
@@ -76,4 +77,8 @@ int cloudabi_futex_lock_wrlock(struct thread *, cloudabi_lock_t *,
cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t,
cloudabi_timestamp_t);
+/* vDSO setup and teardown. */
+void cloudabi_vdso_init(struct sysentvec *, char *, char *);
+void cloudabi_vdso_destroy(struct sysentvec *);
+
#endif
diff --git a/sys/compat/cloudabi/cloudabi_vdso.c b/sys/compat/cloudabi/cloudabi_vdso.c
new file mode 100644
index 0000000..27c3d36
--- /dev/null
+++ b/sys/compat/cloudabi/cloudabi_vdso.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2016 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/lock.h>
+#include <sys/sysent.h>
+#include <sys/rwlock.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_object.h>
+#include <vm/vm_page.h>
+#include <vm/vm_pager.h>
+
+#include <compat/cloudabi/cloudabi_util.h>
+
+void
+cloudabi_vdso_init(struct sysentvec *sv, char *begin, char *end)
+{
+ vm_page_t m;
+ vm_object_t obj;
+ vm_offset_t addr;
+ size_t i, pages, pages_length, vdso_length;
+
+ /* Determine the number of pages needed to store the vDSO. */
+ vdso_length = end - begin;
+ pages = howmany(vdso_length, PAGE_SIZE);
+ pages_length = pages * PAGE_SIZE;
+
+ /* Allocate a VM object and fill it with the vDSO. */
+ obj = vm_pager_allocate(OBJT_PHYS, 0, pages_length,
+ VM_PROT_DEFAULT, 0, NULL);
+ addr = kva_alloc(PAGE_SIZE);
+ for (i = 0; i < pages; ++i) {
+ VM_OBJECT_WLOCK(obj);
+ m = vm_page_grab(obj, i, VM_ALLOC_NOBUSY | VM_ALLOC_ZERO);
+ m->valid = VM_PAGE_BITS_ALL;
+ VM_OBJECT_WUNLOCK(obj);
+
+ pmap_qenter(addr, &m, 1);
+ memcpy((void *)addr, begin + i * PAGE_SIZE,
+ MIN(vdso_length - i * PAGE_SIZE, PAGE_SIZE));
+ pmap_qremove(addr, 1);
+ }
+ kva_free(addr, PAGE_SIZE);
+
+ /*
+ * Place the vDSO at the top of the address space. The user
+ * stack can start right below it.
+ */
+ sv->sv_shared_page_base = sv->sv_maxuser - pages_length;
+ sv->sv_shared_page_len = pages_length;
+ sv->sv_shared_page_obj = obj;
+ sv->sv_usrstack = sv->sv_shared_page_base;
+}
+
+void
+cloudabi_vdso_destroy(struct sysentvec *sv)
+{
+
+ vm_object_deallocate(sv->sv_shared_page_obj);
+}
diff --git a/sys/compat/cloudabi/cloudabi_vdso.lds b/sys/compat/cloudabi/cloudabi_vdso.lds
new file mode 100644
index 0000000..807c488
--- /dev/null
+++ b/sys/compat/cloudabi/cloudabi_vdso.lds
@@ -0,0 +1,51 @@
+/*
+ * Linker script for the vDSO for CloudABI.
+ * Based on sys/amd64/linux/linux_vdso.lds.s
+ *
+ * $FreeBSD$
+ */
+
+SECTIONS
+{
+ . = . + SIZEOF_HEADERS;
+
+ .hash : { *(.hash) } :text
+ .gnu.hash : { *(.gnu.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+
+ .note : { *(.note.*) } :text :note
+
+ .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
+ .eh_frame : { KEEP (*(.eh_frame)) } :text
+
+ .dynamic : { *(.dynamic) } :text :dynamic
+
+ .rodata : { *(.rodata*) } :text
+ .data : {
+ *(.data*)
+ *(.sdata*)
+ *(.got.plt) *(.got)
+ *(.gnu.linkonce.d.*)
+ *(.bss*)
+ *(.dynbss*)
+ *(.gnu.linkonce.b.*)
+ }
+
+ .altinstructions : { *(.altinstructions) }
+ .altinstr_replacement : { *(.altinstr_replacement) }
+
+ . = ALIGN(0x100);
+ .text : { *(.test .text*) } :text =0x90909090
+}
+
+PHDRS
+{
+ text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
+ dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
+ note PT_NOTE FLAGS(4); /* PF_R */
+ eh_frame_hdr PT_GNU_EH_FRAME;
+}
diff --git a/sys/compat/cloudabi32/Makefile b/sys/compat/cloudabi32/Makefile
new file mode 100644
index 0000000..5d1ff52
--- /dev/null
+++ b/sys/compat/cloudabi32/Makefile
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+all:
+ @echo "make sysent only"
+
+sysent: cloudabi32_sysent.c cloudabi32_syscall.h cloudabi32_proto.h \
+ cloudabi32_syscalls.c cloudabi32_systrace_args.c
+
+cloudabi32_sysent.c cloudabi32_syscall.h cloudabi32_proto.h \
+ cloudabi32_syscalls.c cloudabi32_systrace_args.c: \
+ ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls32.master \
+ syscalls.conf
+ sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls32.master \
+ syscalls.conf
diff --git a/sys/compat/cloudabi32/cloudabi32_fd.c b/sys/compat/cloudabi32/cloudabi32_fd.c
new file mode 100644
index 0000000..1754c48
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_fd.c
@@ -0,0 +1,145 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/limits.h>
+#include <sys/malloc.h>
+#include <sys/syscallsubr.h>
+#include <sys/systm.h>
+#include <sys/uio.h>
+
+#include <contrib/cloudabi/cloudabi32_types.h>
+
+#include <compat/cloudabi32/cloudabi32_proto.h>
+#include <compat/cloudabi32/cloudabi32_util.h>
+
+/* Copies in 32-bit iovec structures from userspace. */
+static int
+cloudabi32_copyinuio(const cloudabi32_iovec_t *iovp, size_t iovcnt,
+ struct uio **uiop)
+{
+ cloudabi32_iovec_t iovobj;
+ struct uio *uio;
+ struct iovec *iov;
+ size_t i;
+ int error;
+
+ /* Allocate uio and iovecs. */
+ if (iovcnt > UIO_MAXIOV)
+ return (EINVAL);
+ uio = malloc(sizeof(struct uio) + iovcnt * sizeof(struct iovec),
+ M_IOV, M_WAITOK);
+ iov = (struct iovec *)(uio + 1);
+
+ /* Initialize uio. */
+ uio->uio_iov = iov;
+ uio->uio_iovcnt = iovcnt;
+ uio->uio_segflg = UIO_USERSPACE;
+ uio->uio_offset = -1;
+ uio->uio_resid = 0;
+
+ /* Copy in iovecs. */
+ for (i = 0; i < iovcnt; i++) {
+ error = copyin(&iovp[i], &iovobj, sizeof(iovobj));
+ if (error != 0) {
+ free(uio, M_IOV);
+ return (error);
+ }
+ iov[i].iov_base = TO_PTR(iovobj.iov_base);
+ iov[i].iov_len = iovobj.iov_len;
+ if (iov[i].iov_len > INT32_MAX - uio->uio_resid) {
+ free(uio, M_IOV);
+ return (EINVAL);
+ }
+ uio->uio_resid += iov[i].iov_len;
+ }
+
+ *uiop = uio;
+ return (0);
+}
+
+int
+cloudabi32_sys_fd_pread(struct thread *td,
+ struct cloudabi32_sys_fd_pread_args *uap)
+{
+ struct uio *uio;
+ int error;
+
+ error = cloudabi32_copyinuio(uap->iov, uap->iovcnt, &uio);
+ if (error != 0)
+ return (error);
+ error = kern_preadv(td, uap->fd, uio, uap->offset);
+ free(uio, M_IOV);
+ return (error);
+}
+
+int
+cloudabi32_sys_fd_pwrite(struct thread *td,
+ struct cloudabi32_sys_fd_pwrite_args *uap)
+{
+ struct uio *uio;
+ int error;
+
+ error = cloudabi32_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio);
+ if (error != 0)
+ return (error);
+ error = kern_pwritev(td, uap->fd, uio, uap->offset);
+ free(uio, M_IOV);
+ return (error);
+}
+
+int
+cloudabi32_sys_fd_read(struct thread *td,
+ struct cloudabi32_sys_fd_read_args *uap)
+{
+ struct uio *uio;
+ int error;
+
+ error = cloudabi32_copyinuio(uap->iov, uap->iovcnt, &uio);
+ if (error != 0)
+ return (error);
+ error = kern_readv(td, uap->fd, uio);
+ free(uio, M_IOV);
+ return (error);
+}
+
+int
+cloudabi32_sys_fd_write(struct thread *td,
+ struct cloudabi32_sys_fd_write_args *uap)
+{
+ struct uio *uio;
+ int error;
+
+ error = cloudabi32_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio);
+ if (error != 0)
+ return (error);
+ error = kern_writev(td, uap->fd, uio);
+ free(uio, M_IOV);
+ return (error);
+}
diff --git a/sys/compat/cloudabi32/cloudabi32_module.c b/sys/compat/cloudabi32/cloudabi32_module.c
new file mode 100644
index 0000000..3e4e4a7
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_module.c
@@ -0,0 +1,167 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/imgact.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/proc.h>
+#include <sys/smp.h>
+#include <sys/sysctl.h>
+#include <sys/sysent.h>
+#include <sys/systm.h>
+
+#include <contrib/cloudabi/cloudabi32_types.h>
+
+#include <compat/cloudabi/cloudabi_util.h>
+
+#include <compat/cloudabi32/cloudabi32_util.h>
+
+extern char _binary_cloudabi32_vdso_o_start[];
+extern char _binary_cloudabi32_vdso_o_end[];
+
+register_t *
+cloudabi32_copyout_strings(struct image_params *imgp)
+{
+ struct image_args *args;
+ uintptr_t begin;
+ size_t len;
+
+ /* Copy out program arguments. */
+ args = imgp->args;
+ len = args->begin_envv - args->begin_argv;
+ begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t));
+ copyout(args->begin_argv, (void *)begin, len);
+ return ((register_t *)begin);
+}
+
+int
+cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
+{
+ char canarybuf[64];
+ Elf32_Auxargs *args;
+ struct thread *td;
+ void *argdata, *canary;
+ size_t argdatalen;
+ int error;
+
+ /*
+ * CloudABI executables do not store the FreeBSD OS release
+ * number in their header. Set the OS release number to the
+ * latest version of FreeBSD, so that system calls behave as if
+ * called natively.
+ */
+ td = curthread;
+ td->td_proc->p_osrel = __FreeBSD_version;
+
+ /* Store canary for stack smashing protection. */
+ argdata = *stack_base;
+ arc4rand(canarybuf, sizeof(canarybuf), 0);
+ *stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
+ canary = *stack_base;
+ error = copyout(canarybuf, canary, sizeof(canarybuf));
+ if (error != 0)
+ return (error);
+
+ /*
+ * Compute length of program arguments. As the argument data is
+ * binary safe, we had to add a trailing null byte in
+ * exec_copyin_data_fds(). Undo this by reducing the length.
+ */
+ args = (Elf32_Auxargs *)imgp->auxargs;
+ argdatalen = imgp->args->begin_envv - imgp->args->begin_argv;
+ if (argdatalen > 0)
+ --argdatalen;
+
+ /* Write out an auxiliary vector. */
+ cloudabi32_auxv_t auxv[] = {
+#define VAL(type, val) { .a_type = (type), .a_val = (val) }
+#define PTR(type, ptr) { .a_type = (type), .a_ptr = (uintptr_t)(ptr) }
+ PTR(CLOUDABI_AT_ARGDATA, argdata),
+ VAL(CLOUDABI_AT_ARGDATALEN, argdatalen),
+ VAL(CLOUDABI_AT_BASE, args->base),
+ PTR(CLOUDABI_AT_CANARY, canary),
+ VAL(CLOUDABI_AT_CANARYLEN, sizeof(canarybuf)),
+ VAL(CLOUDABI_AT_NCPUS, mp_ncpus),
+ VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
+ PTR(CLOUDABI_AT_PHDR, args->phdr),
+ VAL(CLOUDABI_AT_PHNUM, args->phnum),
+ VAL(CLOUDABI_AT_TID, td->td_tid),
+ PTR(CLOUDABI_AT_SYSINFO_EHDR,
+ imgp->proc->p_sysent->sv_shared_page_base),
+#undef VAL
+#undef PTR
+ { .a_type = CLOUDABI_AT_NULL },
+ };
+ *stack_base -= howmany(sizeof(auxv), sizeof(register_t));
+ error = copyout(auxv, *stack_base, sizeof(auxv));
+ if (error != 0)
+ return (error);
+
+ /* Reserve space for storing the TCB. */
+ *stack_base -= howmany(sizeof(cloudabi32_tcb_t), sizeof(register_t));
+ return (0);
+}
+
+static int
+cloudabi32_modevent(module_t mod, int type, void *data)
+{
+
+ switch (type) {
+ case MOD_LOAD:
+ cloudabi_vdso_init(cloudabi32_brand.sysvec,
+ _binary_cloudabi32_vdso_o_start,
+ _binary_cloudabi32_vdso_o_end);
+ if (elf32_insert_brand_entry(&cloudabi32_brand) < 0) {
+ printf("Failed to add CloudABI ELF brand handler\n");
+ return (EINVAL);
+ }
+ return (0);
+ case MOD_UNLOAD:
+ if (elf32_brand_inuse(&cloudabi32_brand))
+ return (EBUSY);
+ if (elf32_remove_brand_entry(&cloudabi32_brand) < 0) {
+ printf("Failed to remove CloudABI ELF brand handler\n");
+ return (EINVAL);
+ }
+ cloudabi_vdso_destroy(cloudabi32_brand.sysvec);
+ return (0);
+ default:
+ return (EOPNOTSUPP);
+ }
+}
+
+static moduledata_t cloudabi32_module = {
+ "cloudabi32",
+ cloudabi32_modevent,
+ NULL
+};
+
+DECLARE_MODULE_TIED(cloudabi32, cloudabi32_module, SI_SUB_EXEC, SI_ORDER_ANY);
+MODULE_DEPEND(cloudabi32, cloudabi, 1, 1, 1);
+FEATURE(cloudabi32, "CloudABI 32bit support");
diff --git a/sys/compat/cloudabi32/cloudabi32_poll.c b/sys/compat/cloudabi32/cloudabi32_poll.c
new file mode 100644
index 0000000..5215580
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_poll.c
@@ -0,0 +1,408 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/syscallsubr.h>
+
+#include <contrib/cloudabi/cloudabi32_types.h>
+
+#include <compat/cloudabi/cloudabi_util.h>
+
+#include <compat/cloudabi32/cloudabi32_proto.h>
+#include <compat/cloudabi32/cloudabi32_util.h>
+
+/* Converts a FreeBSD signal number to a CloudABI signal number. */
+static cloudabi_signal_t
+convert_signal(int sig)
+{
+ static const cloudabi_signal_t signals[] = {
+ [SIGABRT] = CLOUDABI_SIGABRT,
+ [SIGALRM] = CLOUDABI_SIGALRM,
+ [SIGBUS] = CLOUDABI_SIGBUS,
+ [SIGCHLD] = CLOUDABI_SIGCHLD,
+ [SIGCONT] = CLOUDABI_SIGCONT,
+ [SIGFPE] = CLOUDABI_SIGFPE,
+ [SIGHUP] = CLOUDABI_SIGHUP,
+ [SIGILL] = CLOUDABI_SIGILL,
+ [SIGINT] = CLOUDABI_SIGINT,
+ [SIGKILL] = CLOUDABI_SIGKILL,
+ [SIGPIPE] = CLOUDABI_SIGPIPE,
+ [SIGQUIT] = CLOUDABI_SIGQUIT,
+ [SIGSEGV] = CLOUDABI_SIGSEGV,
+ [SIGSTOP] = CLOUDABI_SIGSTOP,
+ [SIGSYS] = CLOUDABI_SIGSYS,
+ [SIGTERM] = CLOUDABI_SIGTERM,
+ [SIGTRAP] = CLOUDABI_SIGTRAP,
+ [SIGTSTP] = CLOUDABI_SIGTSTP,
+ [SIGTTIN] = CLOUDABI_SIGTTIN,
+ [SIGTTOU] = CLOUDABI_SIGTTOU,
+ [SIGURG] = CLOUDABI_SIGURG,
+ [SIGUSR1] = CLOUDABI_SIGUSR1,
+ [SIGUSR2] = CLOUDABI_SIGUSR2,
+ [SIGVTALRM] = CLOUDABI_SIGVTALRM,
+ [SIGXCPU] = CLOUDABI_SIGXCPU,
+ [SIGXFSZ] = CLOUDABI_SIGXFSZ,
+ };
+
+ /* Convert unknown signals to SIGABRT. */
+ if (sig < 0 || sig >= nitems(signals) || signals[sig] == 0)
+ return (SIGABRT);
+ return (signals[sig]);
+}
+
+struct cloudabi32_kevent_args {
+ const cloudabi32_subscription_t *in;
+ cloudabi32_event_t *out;
+ bool once;
+};
+
+/* Converts CloudABI's subscription objects to FreeBSD's struct kevent. */
+static int
+cloudabi32_kevent_copyin(void *arg, struct kevent *kevp, int count)
+{
+ cloudabi32_subscription_t sub;
+ struct cloudabi32_kevent_args *args;
+ cloudabi_timestamp_t ts;
+ int error;
+
+ args = arg;
+ while (count-- > 0) {
+ /* TODO(ed): Copy in multiple entries at once. */
+ error = copyin(args->in++, &sub, sizeof(sub));
+ if (error != 0)
+ return (error);
+
+ memset(kevp, 0, sizeof(*kevp));
+ kevp->udata = TO_PTR(sub.userdata);
+ switch (sub.type) {
+ case CLOUDABI_EVENTTYPE_CLOCK:
+ kevp->filter = EVFILT_TIMER;
+ kevp->ident = sub.clock.identifier;
+ kevp->fflags = NOTE_NSECONDS;
+ if ((sub.clock.flags &
+ CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0 &&
+ sub.clock.timeout > 0) {
+ /* Convert absolute timestamp to a relative. */
+ error = cloudabi_clock_time_get(curthread,
+ sub.clock.clock_id, &ts);
+ if (error != 0)
+ return (error);
+ ts = ts > sub.clock.timeout ? 0 :
+ sub.clock.timeout - ts;
+ } else {
+ /* Relative timestamp. */
+ ts = sub.clock.timeout;
+ }
+ kevp->data = ts > INTPTR_MAX ? INTPTR_MAX : ts;
+ break;
+ case CLOUDABI_EVENTTYPE_FD_READ:
+ kevp->filter = EVFILT_READ;
+ kevp->ident = sub.fd_readwrite.fd;
+ if ((sub.fd_readwrite.flags &
+ CLOUDABI_SUBSCRIPTION_FD_READWRITE_POLL) != 0)
+ kevp->fflags = NOTE_FILE_POLL;
+ break;
+ case CLOUDABI_EVENTTYPE_FD_WRITE:
+ kevp->filter = EVFILT_WRITE;
+ kevp->ident = sub.fd_readwrite.fd;
+ break;
+ case CLOUDABI_EVENTTYPE_PROC_TERMINATE:
+ kevp->filter = EVFILT_PROCDESC;
+ kevp->ident = sub.proc_terminate.fd;
+ kevp->fflags = NOTE_EXIT;
+ break;
+ }
+ if (args->once) {
+ /* Ignore flags. Simply use oneshot mode. */
+ kevp->flags = EV_ADD | EV_ONESHOT;
+ } else {
+ /* Translate flags. */
+ if ((sub.flags & CLOUDABI_SUBSCRIPTION_ADD) != 0)
+ kevp->flags |= EV_ADD;
+ if ((sub.flags & CLOUDABI_SUBSCRIPTION_CLEAR) != 0)
+ kevp->flags |= EV_CLEAR;
+ if ((sub.flags & CLOUDABI_SUBSCRIPTION_DELETE) != 0)
+ kevp->flags |= EV_DELETE;
+ if ((sub.flags & CLOUDABI_SUBSCRIPTION_DISABLE) != 0)
+ kevp->flags |= EV_DISABLE;
+ if ((sub.flags & CLOUDABI_SUBSCRIPTION_ENABLE) != 0)
+ kevp->flags |= EV_ENABLE;
+ if ((sub.flags & CLOUDABI_SUBSCRIPTION_ONESHOT) != 0)
+ kevp->flags |= EV_ONESHOT;
+ }
+ ++kevp;
+ }
+ return (0);
+}
+
+/* Converts FreeBSD's struct kevent to CloudABI's event objects. */
+static int
+cloudabi32_kevent_copyout(void *arg, struct kevent *kevp, int count)
+{
+ cloudabi32_event_t ev;
+ struct cloudabi32_kevent_args *args;
+ int error;
+
+ args = arg;
+ while (count-- > 0) {
+ /* Convert fields that should always be present. */
+ memset(&ev, 0, sizeof(ev));
+ ev.userdata = (uintptr_t)kevp->udata;
+ switch (kevp->filter) {
+ case EVFILT_TIMER:
+ ev.type = CLOUDABI_EVENTTYPE_CLOCK;
+ ev.clock.identifier = kevp->ident;
+ break;
+ case EVFILT_READ:
+ ev.type = CLOUDABI_EVENTTYPE_FD_READ;
+ ev.fd_readwrite.fd = kevp->ident;
+ break;
+ case EVFILT_WRITE:
+ ev.type = CLOUDABI_EVENTTYPE_FD_WRITE;
+ ev.fd_readwrite.fd = kevp->ident;
+ break;
+ case EVFILT_PROCDESC:
+ ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE;
+ ev.proc_terminate.fd = kevp->ident;
+ break;
+ }
+
+ if ((kevp->flags & EV_ERROR) == 0) {
+ /* Success. */
+ switch (kevp->filter) {
+ case EVFILT_READ:
+ case EVFILT_WRITE:
+ ev.fd_readwrite.nbytes = kevp->data;
+ if ((kevp->flags & EV_EOF) != 0) {
+ ev.fd_readwrite.flags |=
+ CLOUDABI_EVENT_FD_READWRITE_HANGUP;
+ }
+ break;
+ case EVFILT_PROCDESC:
+ if (WIFSIGNALED(kevp->data)) {
+ /* Process got signalled. */
+ ev.proc_terminate.signal =
+ convert_signal(WTERMSIG(kevp->data));
+ ev.proc_terminate.exitcode = 0;
+ } else {
+ /* Process exited. */
+ ev.proc_terminate.signal = 0;
+ ev.proc_terminate.exitcode =
+ WEXITSTATUS(kevp->data);
+ }
+ break;
+ }
+ } else {
+ /* Error. */
+ ev.error = cloudabi_convert_errno(kevp->data);
+ }
+ ++kevp;
+
+ /* TODO(ed): Copy out multiple entries at once. */
+ error = copyout(&ev, args->out++, sizeof(ev));
+ if (error != 0)
+ return (error);
+ }
+ return (0);
+}
+
+int
+cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
+{
+ struct cloudabi32_kevent_args args = {
+ .in = uap->in,
+ .out = uap->out,
+ .once = true,
+ };
+ struct kevent_copyops copyops = {
+ .k_copyin = cloudabi32_kevent_copyin,
+ .k_copyout = cloudabi32_kevent_copyout,
+ .arg = &args,
+ };
+
+ /*
+ * Bandaid to support CloudABI futex constructs that are not
+ * implemented through FreeBSD's kqueue().
+ */
+ if (uap->nsubscriptions == 1) {
+ cloudabi32_subscription_t sub;
+ cloudabi32_event_t ev = {};
+ int error;
+
+ error = copyin(uap->in, &sub, sizeof(sub));
+ if (error != 0)
+ return (error);
+ ev.userdata = sub.userdata;
+ ev.type = sub.type;
+ if (sub.type == CLOUDABI_EVENTTYPE_CONDVAR) {
+ /* Wait on a condition variable. */
+ ev.condvar.condvar = sub.condvar.condvar;
+ ev.error = cloudabi_convert_errno(
+ cloudabi_futex_condvar_wait(
+ td, TO_PTR(sub.condvar.condvar),
+ sub.condvar.condvar_scope,
+ TO_PTR(sub.condvar.lock),
+ sub.condvar.lock_scope,
+ CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0));
+ td->td_retval[0] = 1;
+ return (copyout(&ev, uap->out, sizeof(ev)));
+ } else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK) {
+ /* Acquire a read lock. */
+ ev.lock.lock = sub.lock.lock;
+ ev.error = cloudabi_convert_errno(
+ cloudabi_futex_lock_rdlock(
+ td, TO_PTR(sub.lock.lock),
+ sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC,
+ UINT64_MAX, 0));
+ td->td_retval[0] = 1;
+ return (copyout(&ev, uap->out, sizeof(ev)));
+ } else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK) {
+ /* Acquire a write lock. */
+ ev.lock.lock = sub.lock.lock;
+ ev.error = cloudabi_convert_errno(
+ cloudabi_futex_lock_wrlock(
+ td, TO_PTR(sub.lock.lock),
+ sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC,
+ UINT64_MAX, 0));
+ td->td_retval[0] = 1;
+ return (copyout(&ev, uap->out, sizeof(ev)));
+ }
+ } else if (uap->nsubscriptions == 2) {
+ cloudabi32_subscription_t sub[2];
+ cloudabi32_event_t ev[2] = {};
+ int error;
+
+ error = copyin(uap->in, &sub, sizeof(sub));
+ if (error != 0)
+ return (error);
+ ev[0].userdata = sub[0].userdata;
+ ev[0].type = sub[0].type;
+ ev[1].userdata = sub[1].userdata;
+ ev[1].type = sub[1].type;
+ if (sub[0].type == CLOUDABI_EVENTTYPE_CONDVAR &&
+ sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
+ sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
+ /* Wait for a condition variable with timeout. */
+ ev[0].condvar.condvar = sub[0].condvar.condvar;
+ ev[1].clock.identifier = sub[1].clock.identifier;
+ error = cloudabi_futex_condvar_wait(
+ td, TO_PTR(sub[0].condvar.condvar),
+ sub[0].condvar.condvar_scope,
+ TO_PTR(sub[0].condvar.lock),
+ sub[0].condvar.lock_scope, sub[1].clock.clock_id,
+ sub[1].clock.timeout, sub[1].clock.precision);
+ if (error == ETIMEDOUT) {
+ td->td_retval[0] = 1;
+ return (copyout(&ev[1], uap->out,
+ sizeof(ev[1])));
+ }
+
+ ev[0].error = cloudabi_convert_errno(error);
+ td->td_retval[0] = 1;
+ return (copyout(&ev[0], uap->out, sizeof(ev[0])));
+ } else if (sub[0].type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK &&
+ sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
+ sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
+ /* Acquire a read lock with a timeout. */
+ ev[0].lock.lock = sub[0].lock.lock;
+ ev[1].clock.identifier = sub[1].clock.identifier;
+ error = cloudabi_futex_lock_rdlock(
+ td, TO_PTR(sub[0].lock.lock),
+ sub[0].lock.lock_scope, sub[1].clock.clock_id,
+ sub[1].clock.timeout, sub[1].clock.precision);
+ if (error == ETIMEDOUT) {
+ td->td_retval[0] = 1;
+ return (copyout(&ev[1], uap->out,
+ sizeof(ev[1])));
+ }
+
+ ev[0].error = cloudabi_convert_errno(error);
+ td->td_retval[0] = 1;
+ return (copyout(&ev[0], uap->out, sizeof(ev[0])));
+ } else if (sub[0].type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK &&
+ sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
+ sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
+ /* Acquire a write lock with a timeout. */
+ ev[0].lock.lock = sub[0].lock.lock;
+ ev[1].clock.identifier = sub[1].clock.identifier;
+ error = cloudabi_futex_lock_wrlock(
+ td, TO_PTR(sub[0].lock.lock),
+ sub[0].lock.lock_scope, sub[1].clock.clock_id,
+ sub[1].clock.timeout, sub[1].clock.precision);
+ if (error == ETIMEDOUT) {
+ td->td_retval[0] = 1;
+ return (copyout(&ev[1], uap->out,
+ sizeof(ev[1])));
+ }
+
+ ev[0].error = cloudabi_convert_errno(error);
+ td->td_retval[0] = 1;
+ return (copyout(&ev[0], uap->out, sizeof(ev[0])));
+ }
+ }
+
+ return (kern_kevent_anonymous(td, uap->nsubscriptions, &copyops));
+}
+
+int
+cloudabi32_sys_poll_fd(struct thread *td,
+ struct cloudabi32_sys_poll_fd_args *uap)
+{
+ struct cloudabi32_kevent_args args = {
+ .in = uap->in,
+ .out = uap->out,
+ .once = false,
+ };
+ struct kevent_copyops copyops = {
+ .k_copyin = cloudabi32_kevent_copyin,
+ .k_copyout = cloudabi32_kevent_copyout,
+ .arg = &args,
+ };
+ cloudabi32_subscription_t subtimo;
+ struct timespec timeout;
+ int error;
+
+ if (uap->timeout != NULL) {
+ /* Poll with a timeout. */
+ error = copyin(uap->timeout, &subtimo, sizeof(subtimo));
+ if (error != 0)
+ return (error);
+ if (subtimo.type != CLOUDABI_EVENTTYPE_CLOCK ||
+ subtimo.clock.flags != 0)
+ return (EINVAL);
+ timeout.tv_sec = subtimo.clock.timeout / 1000000000;
+ timeout.tv_nsec = subtimo.clock.timeout % 1000000000;
+ return (kern_kevent(td, uap->fd, uap->nin, uap->nout, &copyops,
+ &timeout));
+ } else {
+ /* Poll without a timeout. */
+ return (kern_kevent(td, uap->fd, uap->nin, uap->nout, &copyops,
+ NULL));
+ }
+}
diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h
new file mode 100644
index 0000000..3f028d5
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_proto.h
@@ -0,0 +1,465 @@
+/*
+ * System call prototypes.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * $FreeBSD$
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed
+ */
+
+#ifndef _CLOUDABI32_SYSPROTO_H_
+#define _CLOUDABI32_SYSPROTO_H_
+
+#include <sys/signal.h>
+#include <sys/acl.h>
+#include <sys/cpuset.h>
+#include <sys/_ffcounter.h>
+#include <sys/_semaphore.h>
+#include <sys/ucontext.h>
+#include <sys/wait.h>
+
+#include <bsm/audit_kevents.h>
+
+struct proc;
+
+struct thread;
+
+#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
+ 0 : sizeof(register_t) - sizeof(t))
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define PADL_(t) 0
+#define PADR_(t) PAD_(t)
+#else
+#define PADL_(t) PAD_(t)
+#define PADR_(t) 0
+#endif
+
+struct cloudabi_sys_clock_res_get_args {
+ char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)];
+};
+struct cloudabi_sys_clock_time_get_args {
+ char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)];
+ char precision_l_[PADL_(cloudabi_timestamp_t)]; cloudabi_timestamp_t precision; char precision_r_[PADR_(cloudabi_timestamp_t)];
+};
+struct cloudabi_sys_condvar_signal_args {
+ char condvar_l_[PADL_(cloudabi_condvar_t *)]; cloudabi_condvar_t * condvar; char condvar_r_[PADR_(cloudabi_condvar_t *)];
+ char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)];
+ char nwaiters_l_[PADL_(cloudabi_nthreads_t)]; cloudabi_nthreads_t nwaiters; char nwaiters_r_[PADR_(cloudabi_nthreads_t)];
+};
+struct cloudabi_sys_fd_close_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+};
+struct cloudabi_sys_fd_create1_args {
+ char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
+};
+struct cloudabi_sys_fd_create2_args {
+ char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
+};
+struct cloudabi_sys_fd_datasync_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+};
+struct cloudabi_sys_fd_dup_args {
+ char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)];
+};
+struct cloudabi32_sys_fd_pread_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)];
+ char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)];
+ char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)];
+};
+struct cloudabi32_sys_fd_pwrite_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)];
+ char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)];
+ char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)];
+};
+struct cloudabi32_sys_fd_read_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)];
+ char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_fd_replace_args {
+ char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)];
+ char to_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t to; char to_r_[PADR_(cloudabi_fd_t)];
+};
+struct cloudabi_sys_fd_seek_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char offset_l_[PADL_(cloudabi_filedelta_t)]; cloudabi_filedelta_t offset; char offset_r_[PADR_(cloudabi_filedelta_t)];
+ char whence_l_[PADL_(cloudabi_whence_t)]; cloudabi_whence_t whence; char whence_r_[PADR_(cloudabi_whence_t)];
+};
+struct cloudabi_sys_fd_stat_get_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(cloudabi_fdstat_t *)]; cloudabi_fdstat_t * buf; char buf_r_[PADR_(cloudabi_fdstat_t *)];
+};
+struct cloudabi_sys_fd_stat_put_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(const cloudabi_fdstat_t *)]; const cloudabi_fdstat_t * buf; char buf_r_[PADR_(const cloudabi_fdstat_t *)];
+ char flags_l_[PADL_(cloudabi_fdsflags_t)]; cloudabi_fdsflags_t flags; char flags_r_[PADR_(cloudabi_fdsflags_t)];
+};
+struct cloudabi_sys_fd_sync_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+};
+struct cloudabi32_sys_fd_write_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)];
+ char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_file_advise_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)];
+ char len_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t len; char len_r_[PADR_(cloudabi_filesize_t)];
+ char advice_l_[PADL_(cloudabi_advice_t)]; cloudabi_advice_t advice; char advice_r_[PADR_(cloudabi_advice_t)];
+};
+struct cloudabi_sys_file_allocate_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)];
+ char len_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t len; char len_r_[PADR_(cloudabi_filesize_t)];
+};
+struct cloudabi_sys_file_create_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+ char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
+};
+struct cloudabi_sys_file_link_args {
+ char fd1_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd1; char fd1_r_[PADR_(cloudabi_lookup_t)];
+ char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)];
+ char path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)];
+ char fd2_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd2; char fd2_r_[PADR_(cloudabi_fd_t)];
+ char path2_l_[PADL_(const char *)]; const char * path2; char path2_r_[PADR_(const char *)];
+ char path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_file_open_args {
+ char dirfd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t dirfd; char dirfd_r_[PADR_(cloudabi_lookup_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+ char oflags_l_[PADL_(cloudabi_oflags_t)]; cloudabi_oflags_t oflags; char oflags_r_[PADR_(cloudabi_oflags_t)];
+ char fds_l_[PADL_(const cloudabi_fdstat_t *)]; const cloudabi_fdstat_t * fds; char fds_r_[PADR_(const cloudabi_fdstat_t *)];
+};
+struct cloudabi_sys_file_readdir_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)];
+ char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)];
+ char cookie_l_[PADL_(cloudabi_dircookie_t)]; cloudabi_dircookie_t cookie; char cookie_r_[PADR_(cloudabi_dircookie_t)];
+};
+struct cloudabi_sys_file_readlink_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+ char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)];
+ char bufsize_l_[PADL_(size_t)]; size_t bufsize; char bufsize_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_file_rename_args {
+ char oldfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t oldfd; char oldfd_r_[PADR_(cloudabi_fd_t)];
+ char old_l_[PADL_(const char *)]; const char * old; char old_r_[PADR_(const char *)];
+ char oldlen_l_[PADL_(size_t)]; size_t oldlen; char oldlen_r_[PADR_(size_t)];
+ char newfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t newfd; char newfd_r_[PADR_(cloudabi_fd_t)];
+ char new_l_[PADL_(const char *)]; const char * new; char new_r_[PADR_(const char *)];
+ char newlen_l_[PADL_(size_t)]; size_t newlen; char newlen_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_file_stat_fget_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(cloudabi_filestat_t *)]; cloudabi_filestat_t * buf; char buf_r_[PADR_(cloudabi_filestat_t *)];
+};
+struct cloudabi_sys_file_stat_fput_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(const cloudabi_filestat_t *)]; const cloudabi_filestat_t * buf; char buf_r_[PADR_(const cloudabi_filestat_t *)];
+ char flags_l_[PADL_(cloudabi_fsflags_t)]; cloudabi_fsflags_t flags; char flags_r_[PADR_(cloudabi_fsflags_t)];
+};
+struct cloudabi_sys_file_stat_get_args {
+ char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+ char buf_l_[PADL_(cloudabi_filestat_t *)]; cloudabi_filestat_t * buf; char buf_r_[PADR_(cloudabi_filestat_t *)];
+};
+struct cloudabi_sys_file_stat_put_args {
+ char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+ char buf_l_[PADL_(const cloudabi_filestat_t *)]; const cloudabi_filestat_t * buf; char buf_r_[PADR_(const cloudabi_filestat_t *)];
+ char flags_l_[PADL_(cloudabi_fsflags_t)]; cloudabi_fsflags_t flags; char flags_r_[PADR_(cloudabi_fsflags_t)];
+};
+struct cloudabi_sys_file_symlink_args {
+ char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)];
+ char path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)];
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char path2_l_[PADL_(const char *)]; const char * path2; char path2_r_[PADR_(const char *)];
+ char path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_file_unlink_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+ char flags_l_[PADL_(cloudabi_ulflags_t)]; cloudabi_ulflags_t flags; char flags_r_[PADR_(cloudabi_ulflags_t)];
+};
+struct cloudabi_sys_lock_unlock_args {
+ char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)];
+ char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)];
+};
+struct cloudabi_sys_mem_advise_args {
+ char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+ char advice_l_[PADL_(cloudabi_advice_t)]; cloudabi_advice_t advice; char advice_r_[PADR_(cloudabi_advice_t)];
+};
+struct cloudabi_sys_mem_lock_args {
+ char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_mem_map_args {
+ char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+ char prot_l_[PADL_(cloudabi_mprot_t)]; cloudabi_mprot_t prot; char prot_r_[PADR_(cloudabi_mprot_t)];
+ char flags_l_[PADL_(cloudabi_mflags_t)]; cloudabi_mflags_t flags; char flags_r_[PADR_(cloudabi_mflags_t)];
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char off_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t off; char off_r_[PADR_(cloudabi_filesize_t)];
+};
+struct cloudabi_sys_mem_protect_args {
+ char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+ char prot_l_[PADL_(cloudabi_mprot_t)]; cloudabi_mprot_t prot; char prot_r_[PADR_(cloudabi_mprot_t)];
+};
+struct cloudabi_sys_mem_sync_args {
+ char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+ char flags_l_[PADL_(cloudabi_msflags_t)]; cloudabi_msflags_t flags; char flags_r_[PADR_(cloudabi_msflags_t)];
+};
+struct cloudabi_sys_mem_unlock_args {
+ char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_mem_unmap_args {
+ char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)];
+ char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)];
+};
+struct cloudabi32_sys_poll_args {
+ char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)];
+ char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)];
+ char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)];
+};
+struct cloudabi32_sys_poll_fd_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)];
+ char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)];
+ char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)];
+ char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)];
+ char timeout_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi32_subscription_t *)];
+};
+struct cloudabi_sys_proc_exec_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)];
+ char datalen_l_[PADL_(size_t)]; size_t datalen; char datalen_r_[PADR_(size_t)];
+ char fds_l_[PADL_(const cloudabi_fd_t *)]; const cloudabi_fd_t * fds; char fds_r_[PADR_(const cloudabi_fd_t *)];
+ char fdslen_l_[PADL_(size_t)]; size_t fdslen; char fdslen_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_proc_exit_args {
+ char rval_l_[PADL_(cloudabi_exitcode_t)]; cloudabi_exitcode_t rval; char rval_r_[PADR_(cloudabi_exitcode_t)];
+};
+struct cloudabi_sys_proc_fork_args {
+ register_t dummy;
+};
+struct cloudabi_sys_proc_raise_args {
+ char sig_l_[PADL_(cloudabi_signal_t)]; cloudabi_signal_t sig; char sig_r_[PADR_(cloudabi_signal_t)];
+};
+struct cloudabi_sys_random_get_args {
+ char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)];
+ char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_sock_accept_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(cloudabi_sockstat_t *)]; cloudabi_sockstat_t * buf; char buf_r_[PADR_(cloudabi_sockstat_t *)];
+};
+struct cloudabi_sys_sock_bind_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_sock_connect_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
+ char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)];
+};
+struct cloudabi_sys_sock_listen_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char backlog_l_[PADL_(cloudabi_backlog_t)]; cloudabi_backlog_t backlog; char backlog_r_[PADR_(cloudabi_backlog_t)];
+};
+struct cloudabi32_sys_sock_recv_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char in_l_[PADL_(const cloudabi32_recv_in_t *)]; const cloudabi32_recv_in_t * in; char in_r_[PADR_(const cloudabi32_recv_in_t *)];
+ char out_l_[PADL_(cloudabi32_recv_out_t *)]; cloudabi32_recv_out_t * out; char out_r_[PADR_(cloudabi32_recv_out_t *)];
+};
+struct cloudabi32_sys_sock_send_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char in_l_[PADL_(const cloudabi32_send_in_t *)]; const cloudabi32_send_in_t * in; char in_r_[PADR_(const cloudabi32_send_in_t *)];
+ char out_l_[PADL_(cloudabi32_send_out_t *)]; cloudabi32_send_out_t * out; char out_r_[PADR_(cloudabi32_send_out_t *)];
+};
+struct cloudabi_sys_sock_shutdown_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char how_l_[PADL_(cloudabi_sdflags_t)]; cloudabi_sdflags_t how; char how_r_[PADR_(cloudabi_sdflags_t)];
+};
+struct cloudabi_sys_sock_stat_get_args {
+ char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)];
+ char buf_l_[PADL_(cloudabi_sockstat_t *)]; cloudabi_sockstat_t * buf; char buf_r_[PADR_(cloudabi_sockstat_t *)];
+ char flags_l_[PADL_(cloudabi_ssflags_t)]; cloudabi_ssflags_t flags; char flags_r_[PADR_(cloudabi_ssflags_t)];
+};
+struct cloudabi32_sys_thread_create_args {
+ char attr_l_[PADL_(cloudabi32_threadattr_t *)]; cloudabi32_threadattr_t * attr; char attr_r_[PADR_(cloudabi32_threadattr_t *)];
+};
+struct cloudabi_sys_thread_exit_args {
+ char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)];
+ char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)];
+};
+struct cloudabi_sys_thread_yield_args {
+ register_t dummy;
+};
+int cloudabi_sys_clock_res_get(struct thread *, struct cloudabi_sys_clock_res_get_args *);
+int cloudabi_sys_clock_time_get(struct thread *, struct cloudabi_sys_clock_time_get_args *);
+int cloudabi_sys_condvar_signal(struct thread *, struct cloudabi_sys_condvar_signal_args *);
+int cloudabi_sys_fd_close(struct thread *, struct cloudabi_sys_fd_close_args *);
+int cloudabi_sys_fd_create1(struct thread *, struct cloudabi_sys_fd_create1_args *);
+int cloudabi_sys_fd_create2(struct thread *, struct cloudabi_sys_fd_create2_args *);
+int cloudabi_sys_fd_datasync(struct thread *, struct cloudabi_sys_fd_datasync_args *);
+int cloudabi_sys_fd_dup(struct thread *, struct cloudabi_sys_fd_dup_args *);
+int cloudabi32_sys_fd_pread(struct thread *, struct cloudabi32_sys_fd_pread_args *);
+int cloudabi32_sys_fd_pwrite(struct thread *, struct cloudabi32_sys_fd_pwrite_args *);
+int cloudabi32_sys_fd_read(struct thread *, struct cloudabi32_sys_fd_read_args *);
+int cloudabi_sys_fd_replace(struct thread *, struct cloudabi_sys_fd_replace_args *);
+int cloudabi_sys_fd_seek(struct thread *, struct cloudabi_sys_fd_seek_args *);
+int cloudabi_sys_fd_stat_get(struct thread *, struct cloudabi_sys_fd_stat_get_args *);
+int cloudabi_sys_fd_stat_put(struct thread *, struct cloudabi_sys_fd_stat_put_args *);
+int cloudabi_sys_fd_sync(struct thread *, struct cloudabi_sys_fd_sync_args *);
+int cloudabi32_sys_fd_write(struct thread *, struct cloudabi32_sys_fd_write_args *);
+int cloudabi_sys_file_advise(struct thread *, struct cloudabi_sys_file_advise_args *);
+int cloudabi_sys_file_allocate(struct thread *, struct cloudabi_sys_file_allocate_args *);
+int cloudabi_sys_file_create(struct thread *, struct cloudabi_sys_file_create_args *);
+int cloudabi_sys_file_link(struct thread *, struct cloudabi_sys_file_link_args *);
+int cloudabi_sys_file_open(struct thread *, struct cloudabi_sys_file_open_args *);
+int cloudabi_sys_file_readdir(struct thread *, struct cloudabi_sys_file_readdir_args *);
+int cloudabi_sys_file_readlink(struct thread *, struct cloudabi_sys_file_readlink_args *);
+int cloudabi_sys_file_rename(struct thread *, struct cloudabi_sys_file_rename_args *);
+int cloudabi_sys_file_stat_fget(struct thread *, struct cloudabi_sys_file_stat_fget_args *);
+int cloudabi_sys_file_stat_fput(struct thread *, struct cloudabi_sys_file_stat_fput_args *);
+int cloudabi_sys_file_stat_get(struct thread *, struct cloudabi_sys_file_stat_get_args *);
+int cloudabi_sys_file_stat_put(struct thread *, struct cloudabi_sys_file_stat_put_args *);
+int cloudabi_sys_file_symlink(struct thread *, struct cloudabi_sys_file_symlink_args *);
+int cloudabi_sys_file_unlink(struct thread *, struct cloudabi_sys_file_unlink_args *);
+int cloudabi_sys_lock_unlock(struct thread *, struct cloudabi_sys_lock_unlock_args *);
+int cloudabi_sys_mem_advise(struct thread *, struct cloudabi_sys_mem_advise_args *);
+int cloudabi_sys_mem_lock(struct thread *, struct cloudabi_sys_mem_lock_args *);
+int cloudabi_sys_mem_map(struct thread *, struct cloudabi_sys_mem_map_args *);
+int cloudabi_sys_mem_protect(struct thread *, struct cloudabi_sys_mem_protect_args *);
+int cloudabi_sys_mem_sync(struct thread *, struct cloudabi_sys_mem_sync_args *);
+int cloudabi_sys_mem_unlock(struct thread *, struct cloudabi_sys_mem_unlock_args *);
+int cloudabi_sys_mem_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *);
+int cloudabi32_sys_poll(struct thread *, struct cloudabi32_sys_poll_args *);
+int cloudabi32_sys_poll_fd(struct thread *, struct cloudabi32_sys_poll_fd_args *);
+int cloudabi_sys_proc_exec(struct thread *, struct cloudabi_sys_proc_exec_args *);
+int cloudabi_sys_proc_exit(struct thread *, struct cloudabi_sys_proc_exit_args *);
+int cloudabi_sys_proc_fork(struct thread *, struct cloudabi_sys_proc_fork_args *);
+int cloudabi_sys_proc_raise(struct thread *, struct cloudabi_sys_proc_raise_args *);
+int cloudabi_sys_random_get(struct thread *, struct cloudabi_sys_random_get_args *);
+int cloudabi_sys_sock_accept(struct thread *, struct cloudabi_sys_sock_accept_args *);
+int cloudabi_sys_sock_bind(struct thread *, struct cloudabi_sys_sock_bind_args *);
+int cloudabi_sys_sock_connect(struct thread *, struct cloudabi_sys_sock_connect_args *);
+int cloudabi_sys_sock_listen(struct thread *, struct cloudabi_sys_sock_listen_args *);
+int cloudabi32_sys_sock_recv(struct thread *, struct cloudabi32_sys_sock_recv_args *);
+int cloudabi32_sys_sock_send(struct thread *, struct cloudabi32_sys_sock_send_args *);
+int cloudabi_sys_sock_shutdown(struct thread *, struct cloudabi_sys_sock_shutdown_args *);
+int cloudabi_sys_sock_stat_get(struct thread *, struct cloudabi_sys_sock_stat_get_args *);
+int cloudabi32_sys_thread_create(struct thread *, struct cloudabi32_sys_thread_create_args *);
+int cloudabi_sys_thread_exit(struct thread *, struct cloudabi_sys_thread_exit_args *);
+int cloudabi_sys_thread_yield(struct thread *, struct cloudabi_sys_thread_yield_args *);
+
+#ifdef COMPAT_43
+
+
+#endif /* COMPAT_43 */
+
+
+#ifdef COMPAT_FREEBSD4
+
+
+#endif /* COMPAT_FREEBSD4 */
+
+
+#ifdef COMPAT_FREEBSD6
+
+
+#endif /* COMPAT_FREEBSD6 */
+
+
+#ifdef COMPAT_FREEBSD7
+
+
+#endif /* COMPAT_FREEBSD7 */
+
+
+#ifdef COMPAT_FREEBSD10
+
+
+#endif /* COMPAT_FREEBSD10 */
+
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_clock_res_get AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_clock_time_get AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_condvar_signal AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_close AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_create1 AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_create2 AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_datasync AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_dup AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_pread AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_pwrite AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_read AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_replace AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_seek AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_stat_get AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_stat_put AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_fd_sync AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_fd_write AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_advise AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_allocate AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_create AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_link AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_open AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_readdir AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_readlink AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_rename AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_fget AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_fput AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_get AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_stat_put AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_symlink AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_file_unlink AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_lock_unlock AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_advise AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_lock AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_map AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_protect AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_sync AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_unlock AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_mem_unmap AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll_fd AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_exec AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_exit AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_fork AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_proc_raise AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_random_get AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_accept AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_bind AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_connect AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_listen AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_sock_recv AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_sock_send AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_shutdown AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_sock_stat_get AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi32_sys_thread_create AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_thread_exit AUE_NULL
+#define CLOUDABI32_SYS_AUE_cloudabi_sys_thread_yield AUE_NULL
+
+#undef PAD_
+#undef PADL_
+#undef PADR_
+
+#endif /* !_CLOUDABI32_SYSPROTO_H_ */
diff --git a/sys/compat/cloudabi32/cloudabi32_sock.c b/sys/compat/cloudabi32/cloudabi32_sock.c
new file mode 100644
index 0000000..24ed32c
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_sock.c
@@ -0,0 +1,148 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/socket.h>
+#include <sys/syscallsubr.h>
+#include <sys/systm.h>
+#include <sys/uio.h>
+
+#include <contrib/cloudabi/cloudabi32_types.h>
+
+#include <compat/cloudabi/cloudabi_util.h>
+
+#include <compat/cloudabi32/cloudabi32_proto.h>
+#include <compat/cloudabi32/cloudabi32_util.h>
+
+static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket");
+
+int
+cloudabi32_sys_sock_recv(struct thread *td,
+ struct cloudabi32_sys_sock_recv_args *uap)
+{
+ struct sockaddr_storage ss;
+ cloudabi32_recv_in_t ri;
+ cloudabi32_recv_out_t ro = {};
+ cloudabi32_iovec_t iovobj;
+ struct msghdr msghdr = {};
+ const cloudabi32_iovec_t *user_iov;
+ size_t i;
+ int error;
+
+ error = copyin(uap->in, &ri, sizeof(ri));
+ if (error != 0)
+ return (error);
+
+ /* Convert results in cloudabi_recv_in_t to struct msghdr. */
+ if (ri.ri_datalen > UIO_MAXIOV)
+ return (EINVAL);
+ msghdr.msg_iovlen = ri.ri_datalen;
+ msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec),
+ M_SOCKET, M_WAITOK);
+ user_iov = TO_PTR(ri.ri_data);
+ for (i = 0; i < msghdr.msg_iovlen; i++) {
+ error = copyin(&user_iov[i], &iovobj, sizeof(iovobj));
+ if (error != 0) {
+ free(msghdr.msg_iov, M_SOCKET);
+ return (error);
+ }
+ msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base);
+ msghdr.msg_iov[i].iov_len = iovobj.iov_len;
+ }
+ msghdr.msg_name = &ss;
+ msghdr.msg_namelen = sizeof(ss);
+ if (ri.ri_flags & CLOUDABI_MSG_PEEK)
+ msghdr.msg_flags |= MSG_PEEK;
+ if (ri.ri_flags & CLOUDABI_MSG_WAITALL)
+ msghdr.msg_flags |= MSG_WAITALL;
+
+ /* TODO(ed): Add file descriptor passing. */
+ error = kern_recvit(td, uap->sock, &msghdr, UIO_SYSSPACE, NULL);
+ free(msghdr.msg_iov, M_SOCKET);
+ if (error != 0)
+ return (error);
+
+ /* Convert results in msghdr to cloudabi_recv_out_t. */
+ ro.ro_datalen = td->td_retval[0];
+ cloudabi_convert_sockaddr((struct sockaddr *)&ss,
+ MIN(msghdr.msg_namelen, sizeof(ss)), &ro.ro_peername);
+ td->td_retval[0] = 0;
+ return (copyout(&ro, uap->out, sizeof(ro)));
+}
+
+int
+cloudabi32_sys_sock_send(struct thread *td,
+ struct cloudabi32_sys_sock_send_args *uap)
+{
+ cloudabi32_send_in_t si;
+ cloudabi32_send_out_t so = {};
+ cloudabi32_ciovec_t iovobj;
+ struct msghdr msghdr = {};
+ const cloudabi32_ciovec_t *user_iov;
+ size_t i;
+ int error, flags;
+
+ error = copyin(uap->in, &si, sizeof(si));
+ if (error != 0)
+ return (error);
+
+ /* Convert results in cloudabi_send_in_t to struct msghdr. */
+ if (si.si_datalen > UIO_MAXIOV)
+ return (EINVAL);
+ msghdr.msg_iovlen = si.si_datalen;
+ msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec),
+ M_SOCKET, M_WAITOK);
+ user_iov = TO_PTR(si.si_data);
+ for (i = 0; i < msghdr.msg_iovlen; i++) {
+ error = copyin(&user_iov[i], &iovobj, sizeof(iovobj));
+ if (error != 0) {
+ free(msghdr.msg_iov, M_SOCKET);
+ return (error);
+ }
+ msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base);
+ msghdr.msg_iov[i].iov_len = iovobj.iov_len;
+ }
+
+ flags = MSG_NOSIGNAL;
+ if (si.si_flags & CLOUDABI_MSG_EOR)
+ flags |= MSG_EOR;
+
+ /* TODO(ed): Add file descriptor passing. */
+ error = kern_sendit(td, uap->sock, &msghdr, flags, NULL, UIO_USERSPACE);
+ free(msghdr.msg_iov, M_SOCKET);
+ if (error != 0)
+ return (error);
+
+ /* Convert results in msghdr to cloudabi_send_out_t. */
+ so.so_datalen = td->td_retval[0];
+ td->td_retval[0] = 0;
+ return (copyout(&so, uap->out, sizeof(so)));
+}
diff --git a/sys/compat/cloudabi32/cloudabi32_syscall.h b/sys/compat/cloudabi32/cloudabi32_syscall.h
new file mode 100644
index 0000000..4cba6fd
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_syscall.h
@@ -0,0 +1,66 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * $FreeBSD$
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed
+ */
+
+#define CLOUDABI32_SYS_cloudabi_sys_clock_res_get 0
+#define CLOUDABI32_SYS_cloudabi_sys_clock_time_get 1
+#define CLOUDABI32_SYS_cloudabi_sys_condvar_signal 2
+#define CLOUDABI32_SYS_cloudabi_sys_fd_close 3
+#define CLOUDABI32_SYS_cloudabi_sys_fd_create1 4
+#define CLOUDABI32_SYS_cloudabi_sys_fd_create2 5
+#define CLOUDABI32_SYS_cloudabi_sys_fd_datasync 6
+#define CLOUDABI32_SYS_cloudabi_sys_fd_dup 7
+#define CLOUDABI32_SYS_cloudabi32_sys_fd_pread 8
+#define CLOUDABI32_SYS_cloudabi32_sys_fd_pwrite 9
+#define CLOUDABI32_SYS_cloudabi32_sys_fd_read 10
+#define CLOUDABI32_SYS_cloudabi_sys_fd_replace 11
+#define CLOUDABI32_SYS_cloudabi_sys_fd_seek 12
+#define CLOUDABI32_SYS_cloudabi_sys_fd_stat_get 13
+#define CLOUDABI32_SYS_cloudabi_sys_fd_stat_put 14
+#define CLOUDABI32_SYS_cloudabi_sys_fd_sync 15
+#define CLOUDABI32_SYS_cloudabi32_sys_fd_write 16
+#define CLOUDABI32_SYS_cloudabi_sys_file_advise 17
+#define CLOUDABI32_SYS_cloudabi_sys_file_allocate 18
+#define CLOUDABI32_SYS_cloudabi_sys_file_create 19
+#define CLOUDABI32_SYS_cloudabi_sys_file_link 20
+#define CLOUDABI32_SYS_cloudabi_sys_file_open 21
+#define CLOUDABI32_SYS_cloudabi_sys_file_readdir 22
+#define CLOUDABI32_SYS_cloudabi_sys_file_readlink 23
+#define CLOUDABI32_SYS_cloudabi_sys_file_rename 24
+#define CLOUDABI32_SYS_cloudabi_sys_file_stat_fget 25
+#define CLOUDABI32_SYS_cloudabi_sys_file_stat_fput 26
+#define CLOUDABI32_SYS_cloudabi_sys_file_stat_get 27
+#define CLOUDABI32_SYS_cloudabi_sys_file_stat_put 28
+#define CLOUDABI32_SYS_cloudabi_sys_file_symlink 29
+#define CLOUDABI32_SYS_cloudabi_sys_file_unlink 30
+#define CLOUDABI32_SYS_cloudabi_sys_lock_unlock 31
+#define CLOUDABI32_SYS_cloudabi_sys_mem_advise 32
+#define CLOUDABI32_SYS_cloudabi_sys_mem_lock 33
+#define CLOUDABI32_SYS_cloudabi_sys_mem_map 34
+#define CLOUDABI32_SYS_cloudabi_sys_mem_protect 35
+#define CLOUDABI32_SYS_cloudabi_sys_mem_sync 36
+#define CLOUDABI32_SYS_cloudabi_sys_mem_unlock 37
+#define CLOUDABI32_SYS_cloudabi_sys_mem_unmap 38
+#define CLOUDABI32_SYS_cloudabi32_sys_poll 39
+#define CLOUDABI32_SYS_cloudabi32_sys_poll_fd 40
+#define CLOUDABI32_SYS_cloudabi_sys_proc_exec 41
+#define CLOUDABI32_SYS_cloudabi_sys_proc_exit 42
+#define CLOUDABI32_SYS_cloudabi_sys_proc_fork 43
+#define CLOUDABI32_SYS_cloudabi_sys_proc_raise 44
+#define CLOUDABI32_SYS_cloudabi_sys_random_get 45
+#define CLOUDABI32_SYS_cloudabi_sys_sock_accept 46
+#define CLOUDABI32_SYS_cloudabi_sys_sock_bind 47
+#define CLOUDABI32_SYS_cloudabi_sys_sock_connect 48
+#define CLOUDABI32_SYS_cloudabi_sys_sock_listen 49
+#define CLOUDABI32_SYS_cloudabi32_sys_sock_recv 50
+#define CLOUDABI32_SYS_cloudabi32_sys_sock_send 51
+#define CLOUDABI32_SYS_cloudabi_sys_sock_shutdown 52
+#define CLOUDABI32_SYS_cloudabi_sys_sock_stat_get 53
+#define CLOUDABI32_SYS_cloudabi32_sys_thread_create 54
+#define CLOUDABI32_SYS_cloudabi_sys_thread_exit 55
+#define CLOUDABI32_SYS_cloudabi_sys_thread_yield 56
+#define CLOUDABI32_SYS_MAXSYSCALL 57
diff --git a/sys/compat/cloudabi32/cloudabi32_syscalls.c b/sys/compat/cloudabi32/cloudabi32_syscalls.c
new file mode 100644
index 0000000..56a46fb
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_syscalls.c
@@ -0,0 +1,67 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * $FreeBSD$
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed
+ */
+
+const char *cloudabi32_syscallnames[] = {
+ "cloudabi_sys_clock_res_get", /* 0 = cloudabi_sys_clock_res_get */
+ "cloudabi_sys_clock_time_get", /* 1 = cloudabi_sys_clock_time_get */
+ "cloudabi_sys_condvar_signal", /* 2 = cloudabi_sys_condvar_signal */
+ "cloudabi_sys_fd_close", /* 3 = cloudabi_sys_fd_close */
+ "cloudabi_sys_fd_create1", /* 4 = cloudabi_sys_fd_create1 */
+ "cloudabi_sys_fd_create2", /* 5 = cloudabi_sys_fd_create2 */
+ "cloudabi_sys_fd_datasync", /* 6 = cloudabi_sys_fd_datasync */
+ "cloudabi_sys_fd_dup", /* 7 = cloudabi_sys_fd_dup */
+ "cloudabi32_sys_fd_pread", /* 8 = cloudabi32_sys_fd_pread */
+ "cloudabi32_sys_fd_pwrite", /* 9 = cloudabi32_sys_fd_pwrite */
+ "cloudabi32_sys_fd_read", /* 10 = cloudabi32_sys_fd_read */
+ "cloudabi_sys_fd_replace", /* 11 = cloudabi_sys_fd_replace */
+ "cloudabi_sys_fd_seek", /* 12 = cloudabi_sys_fd_seek */
+ "cloudabi_sys_fd_stat_get", /* 13 = cloudabi_sys_fd_stat_get */
+ "cloudabi_sys_fd_stat_put", /* 14 = cloudabi_sys_fd_stat_put */
+ "cloudabi_sys_fd_sync", /* 15 = cloudabi_sys_fd_sync */
+ "cloudabi32_sys_fd_write", /* 16 = cloudabi32_sys_fd_write */
+ "cloudabi_sys_file_advise", /* 17 = cloudabi_sys_file_advise */
+ "cloudabi_sys_file_allocate", /* 18 = cloudabi_sys_file_allocate */
+ "cloudabi_sys_file_create", /* 19 = cloudabi_sys_file_create */
+ "cloudabi_sys_file_link", /* 20 = cloudabi_sys_file_link */
+ "cloudabi_sys_file_open", /* 21 = cloudabi_sys_file_open */
+ "cloudabi_sys_file_readdir", /* 22 = cloudabi_sys_file_readdir */
+ "cloudabi_sys_file_readlink", /* 23 = cloudabi_sys_file_readlink */
+ "cloudabi_sys_file_rename", /* 24 = cloudabi_sys_file_rename */
+ "cloudabi_sys_file_stat_fget", /* 25 = cloudabi_sys_file_stat_fget */
+ "cloudabi_sys_file_stat_fput", /* 26 = cloudabi_sys_file_stat_fput */
+ "cloudabi_sys_file_stat_get", /* 27 = cloudabi_sys_file_stat_get */
+ "cloudabi_sys_file_stat_put", /* 28 = cloudabi_sys_file_stat_put */
+ "cloudabi_sys_file_symlink", /* 29 = cloudabi_sys_file_symlink */
+ "cloudabi_sys_file_unlink", /* 30 = cloudabi_sys_file_unlink */
+ "cloudabi_sys_lock_unlock", /* 31 = cloudabi_sys_lock_unlock */
+ "cloudabi_sys_mem_advise", /* 32 = cloudabi_sys_mem_advise */
+ "cloudabi_sys_mem_lock", /* 33 = cloudabi_sys_mem_lock */
+ "cloudabi_sys_mem_map", /* 34 = cloudabi_sys_mem_map */
+ "cloudabi_sys_mem_protect", /* 35 = cloudabi_sys_mem_protect */
+ "cloudabi_sys_mem_sync", /* 36 = cloudabi_sys_mem_sync */
+ "cloudabi_sys_mem_unlock", /* 37 = cloudabi_sys_mem_unlock */
+ "cloudabi_sys_mem_unmap", /* 38 = cloudabi_sys_mem_unmap */
+ "cloudabi32_sys_poll", /* 39 = cloudabi32_sys_poll */
+ "cloudabi32_sys_poll_fd", /* 40 = cloudabi32_sys_poll_fd */
+ "cloudabi_sys_proc_exec", /* 41 = cloudabi_sys_proc_exec */
+ "cloudabi_sys_proc_exit", /* 42 = cloudabi_sys_proc_exit */
+ "cloudabi_sys_proc_fork", /* 43 = cloudabi_sys_proc_fork */
+ "cloudabi_sys_proc_raise", /* 44 = cloudabi_sys_proc_raise */
+ "cloudabi_sys_random_get", /* 45 = cloudabi_sys_random_get */
+ "cloudabi_sys_sock_accept", /* 46 = cloudabi_sys_sock_accept */
+ "cloudabi_sys_sock_bind", /* 47 = cloudabi_sys_sock_bind */
+ "cloudabi_sys_sock_connect", /* 48 = cloudabi_sys_sock_connect */
+ "cloudabi_sys_sock_listen", /* 49 = cloudabi_sys_sock_listen */
+ "cloudabi32_sys_sock_recv", /* 50 = cloudabi32_sys_sock_recv */
+ "cloudabi32_sys_sock_send", /* 51 = cloudabi32_sys_sock_send */
+ "cloudabi_sys_sock_shutdown", /* 52 = cloudabi_sys_sock_shutdown */
+ "cloudabi_sys_sock_stat_get", /* 53 = cloudabi_sys_sock_stat_get */
+ "cloudabi32_sys_thread_create", /* 54 = cloudabi32_sys_thread_create */
+ "cloudabi_sys_thread_exit", /* 55 = cloudabi_sys_thread_exit */
+ "cloudabi_sys_thread_yield", /* 56 = cloudabi_sys_thread_yield */
+};
diff --git a/sys/compat/cloudabi32/cloudabi32_sysent.c b/sys/compat/cloudabi32/cloudabi32_sysent.c
new file mode 100644
index 0000000..187e384
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_sysent.c
@@ -0,0 +1,75 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * $FreeBSD$
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed
+ */
+
+#include <sys/sysent.h>
+#include <sys/sysproto.h>
+#include <contrib/cloudabi/cloudabi32_types.h>
+#include <compat/cloudabi32/cloudabi32_proto.h>
+
+#define AS(name) (sizeof(struct name) / sizeof(register_t))
+
+/* The casts are bogus but will do for now. */
+struct sysent cloudabi32_sysent[] = {
+ { AS(cloudabi_sys_clock_res_get_args), (sy_call_t *)cloudabi_sys_clock_res_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 0 = cloudabi_sys_clock_res_get */
+ { AS(cloudabi_sys_clock_time_get_args), (sy_call_t *)cloudabi_sys_clock_time_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 1 = cloudabi_sys_clock_time_get */
+ { AS(cloudabi_sys_condvar_signal_args), (sy_call_t *)cloudabi_sys_condvar_signal, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 2 = cloudabi_sys_condvar_signal */
+ { AS(cloudabi_sys_fd_close_args), (sy_call_t *)cloudabi_sys_fd_close, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 3 = cloudabi_sys_fd_close */
+ { AS(cloudabi_sys_fd_create1_args), (sy_call_t *)cloudabi_sys_fd_create1, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 4 = cloudabi_sys_fd_create1 */
+ { AS(cloudabi_sys_fd_create2_args), (sy_call_t *)cloudabi_sys_fd_create2, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 5 = cloudabi_sys_fd_create2 */
+ { AS(cloudabi_sys_fd_datasync_args), (sy_call_t *)cloudabi_sys_fd_datasync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 6 = cloudabi_sys_fd_datasync */
+ { AS(cloudabi_sys_fd_dup_args), (sy_call_t *)cloudabi_sys_fd_dup, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 7 = cloudabi_sys_fd_dup */
+ { AS(cloudabi32_sys_fd_pread_args), (sy_call_t *)cloudabi32_sys_fd_pread, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 8 = cloudabi32_sys_fd_pread */
+ { AS(cloudabi32_sys_fd_pwrite_args), (sy_call_t *)cloudabi32_sys_fd_pwrite, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 9 = cloudabi32_sys_fd_pwrite */
+ { AS(cloudabi32_sys_fd_read_args), (sy_call_t *)cloudabi32_sys_fd_read, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 10 = cloudabi32_sys_fd_read */
+ { AS(cloudabi_sys_fd_replace_args), (sy_call_t *)cloudabi_sys_fd_replace, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 11 = cloudabi_sys_fd_replace */
+ { AS(cloudabi_sys_fd_seek_args), (sy_call_t *)cloudabi_sys_fd_seek, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 12 = cloudabi_sys_fd_seek */
+ { AS(cloudabi_sys_fd_stat_get_args), (sy_call_t *)cloudabi_sys_fd_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 13 = cloudabi_sys_fd_stat_get */
+ { AS(cloudabi_sys_fd_stat_put_args), (sy_call_t *)cloudabi_sys_fd_stat_put, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 14 = cloudabi_sys_fd_stat_put */
+ { AS(cloudabi_sys_fd_sync_args), (sy_call_t *)cloudabi_sys_fd_sync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 15 = cloudabi_sys_fd_sync */
+ { AS(cloudabi32_sys_fd_write_args), (sy_call_t *)cloudabi32_sys_fd_write, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 16 = cloudabi32_sys_fd_write */
+ { AS(cloudabi_sys_file_advise_args), (sy_call_t *)cloudabi_sys_file_advise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 17 = cloudabi_sys_file_advise */
+ { AS(cloudabi_sys_file_allocate_args), (sy_call_t *)cloudabi_sys_file_allocate, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 18 = cloudabi_sys_file_allocate */
+ { AS(cloudabi_sys_file_create_args), (sy_call_t *)cloudabi_sys_file_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 19 = cloudabi_sys_file_create */
+ { AS(cloudabi_sys_file_link_args), (sy_call_t *)cloudabi_sys_file_link, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 20 = cloudabi_sys_file_link */
+ { AS(cloudabi_sys_file_open_args), (sy_call_t *)cloudabi_sys_file_open, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 21 = cloudabi_sys_file_open */
+ { AS(cloudabi_sys_file_readdir_args), (sy_call_t *)cloudabi_sys_file_readdir, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 22 = cloudabi_sys_file_readdir */
+ { AS(cloudabi_sys_file_readlink_args), (sy_call_t *)cloudabi_sys_file_readlink, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 23 = cloudabi_sys_file_readlink */
+ { AS(cloudabi_sys_file_rename_args), (sy_call_t *)cloudabi_sys_file_rename, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 24 = cloudabi_sys_file_rename */
+ { AS(cloudabi_sys_file_stat_fget_args), (sy_call_t *)cloudabi_sys_file_stat_fget, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 25 = cloudabi_sys_file_stat_fget */
+ { AS(cloudabi_sys_file_stat_fput_args), (sy_call_t *)cloudabi_sys_file_stat_fput, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 26 = cloudabi_sys_file_stat_fput */
+ { AS(cloudabi_sys_file_stat_get_args), (sy_call_t *)cloudabi_sys_file_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 27 = cloudabi_sys_file_stat_get */
+ { AS(cloudabi_sys_file_stat_put_args), (sy_call_t *)cloudabi_sys_file_stat_put, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 28 = cloudabi_sys_file_stat_put */
+ { AS(cloudabi_sys_file_symlink_args), (sy_call_t *)cloudabi_sys_file_symlink, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 29 = cloudabi_sys_file_symlink */
+ { AS(cloudabi_sys_file_unlink_args), (sy_call_t *)cloudabi_sys_file_unlink, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 30 = cloudabi_sys_file_unlink */
+ { AS(cloudabi_sys_lock_unlock_args), (sy_call_t *)cloudabi_sys_lock_unlock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 31 = cloudabi_sys_lock_unlock */
+ { AS(cloudabi_sys_mem_advise_args), (sy_call_t *)cloudabi_sys_mem_advise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 32 = cloudabi_sys_mem_advise */
+ { AS(cloudabi_sys_mem_lock_args), (sy_call_t *)cloudabi_sys_mem_lock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 33 = cloudabi_sys_mem_lock */
+ { AS(cloudabi_sys_mem_map_args), (sy_call_t *)cloudabi_sys_mem_map, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 34 = cloudabi_sys_mem_map */
+ { AS(cloudabi_sys_mem_protect_args), (sy_call_t *)cloudabi_sys_mem_protect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 35 = cloudabi_sys_mem_protect */
+ { AS(cloudabi_sys_mem_sync_args), (sy_call_t *)cloudabi_sys_mem_sync, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 36 = cloudabi_sys_mem_sync */
+ { AS(cloudabi_sys_mem_unlock_args), (sy_call_t *)cloudabi_sys_mem_unlock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 37 = cloudabi_sys_mem_unlock */
+ { AS(cloudabi_sys_mem_unmap_args), (sy_call_t *)cloudabi_sys_mem_unmap, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 38 = cloudabi_sys_mem_unmap */
+ { AS(cloudabi32_sys_poll_args), (sy_call_t *)cloudabi32_sys_poll, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 39 = cloudabi32_sys_poll */
+ { AS(cloudabi32_sys_poll_fd_args), (sy_call_t *)cloudabi32_sys_poll_fd, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 40 = cloudabi32_sys_poll_fd */
+ { AS(cloudabi_sys_proc_exec_args), (sy_call_t *)cloudabi_sys_proc_exec, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_exec */
+ { AS(cloudabi_sys_proc_exit_args), (sy_call_t *)cloudabi_sys_proc_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 42 = cloudabi_sys_proc_exit */
+ { 0, (sy_call_t *)cloudabi_sys_proc_fork, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 43 = cloudabi_sys_proc_fork */
+ { AS(cloudabi_sys_proc_raise_args), (sy_call_t *)cloudabi_sys_proc_raise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 44 = cloudabi_sys_proc_raise */
+ { AS(cloudabi_sys_random_get_args), (sy_call_t *)cloudabi_sys_random_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 45 = cloudabi_sys_random_get */
+ { AS(cloudabi_sys_sock_accept_args), (sy_call_t *)cloudabi_sys_sock_accept, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 46 = cloudabi_sys_sock_accept */
+ { AS(cloudabi_sys_sock_bind_args), (sy_call_t *)cloudabi_sys_sock_bind, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 47 = cloudabi_sys_sock_bind */
+ { AS(cloudabi_sys_sock_connect_args), (sy_call_t *)cloudabi_sys_sock_connect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 48 = cloudabi_sys_sock_connect */
+ { AS(cloudabi_sys_sock_listen_args), (sy_call_t *)cloudabi_sys_sock_listen, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 49 = cloudabi_sys_sock_listen */
+ { AS(cloudabi32_sys_sock_recv_args), (sy_call_t *)cloudabi32_sys_sock_recv, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 50 = cloudabi32_sys_sock_recv */
+ { AS(cloudabi32_sys_sock_send_args), (sy_call_t *)cloudabi32_sys_sock_send, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 51 = cloudabi32_sys_sock_send */
+ { AS(cloudabi_sys_sock_shutdown_args), (sy_call_t *)cloudabi_sys_sock_shutdown, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 52 = cloudabi_sys_sock_shutdown */
+ { AS(cloudabi_sys_sock_stat_get_args), (sy_call_t *)cloudabi_sys_sock_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 53 = cloudabi_sys_sock_stat_get */
+ { AS(cloudabi32_sys_thread_create_args), (sy_call_t *)cloudabi32_sys_thread_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 54 = cloudabi32_sys_thread_create */
+ { AS(cloudabi_sys_thread_exit_args), (sy_call_t *)cloudabi_sys_thread_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 55 = cloudabi_sys_thread_exit */
+ { 0, (sy_call_t *)cloudabi_sys_thread_yield, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 56 = cloudabi_sys_thread_yield */
+};
diff --git a/sys/compat/cloudabi32/cloudabi32_systrace_args.c b/sys/compat/cloudabi32/cloudabi32_systrace_args.c
new file mode 100644
index 0000000..0ba5ec5
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_systrace_args.c
@@ -0,0 +1,1702 @@
+/*
+ * System call argument to DTrace register array converstion.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * $FreeBSD$
+ * This file is part of the DTrace syscall provider.
+ */
+
+static void
+systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
+{
+ int64_t *iarg = (int64_t *) uarg;
+ switch (sysnum) {
+ /* cloudabi_sys_clock_res_get */
+ case 0: {
+ struct cloudabi_sys_clock_res_get_args *p = params;
+ iarg[0] = p->clock_id; /* cloudabi_clockid_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_clock_time_get */
+ case 1: {
+ struct cloudabi_sys_clock_time_get_args *p = params;
+ iarg[0] = p->clock_id; /* cloudabi_clockid_t */
+ iarg[1] = p->precision; /* cloudabi_timestamp_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_condvar_signal */
+ case 2: {
+ struct cloudabi_sys_condvar_signal_args *p = params;
+ uarg[0] = (intptr_t) p->condvar; /* cloudabi_condvar_t * */
+ iarg[1] = p->scope; /* cloudabi_scope_t */
+ iarg[2] = p->nwaiters; /* cloudabi_nthreads_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_fd_close */
+ case 3: {
+ struct cloudabi_sys_fd_close_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_fd_create1 */
+ case 4: {
+ struct cloudabi_sys_fd_create1_args *p = params;
+ iarg[0] = p->type; /* cloudabi_filetype_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_fd_create2 */
+ case 5: {
+ struct cloudabi_sys_fd_create2_args *p = params;
+ iarg[0] = p->type; /* cloudabi_filetype_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_fd_datasync */
+ case 6: {
+ struct cloudabi_sys_fd_datasync_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_fd_dup */
+ case 7: {
+ struct cloudabi_sys_fd_dup_args *p = params;
+ iarg[0] = p->from; /* cloudabi_fd_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi32_sys_fd_pread */
+ case 8: {
+ struct cloudabi32_sys_fd_pread_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->iov; /* const cloudabi32_iovec_t * */
+ uarg[2] = p->iovcnt; /* size_t */
+ iarg[3] = p->offset; /* cloudabi_filesize_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi32_sys_fd_pwrite */
+ case 9: {
+ struct cloudabi32_sys_fd_pwrite_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->iov; /* const cloudabi32_ciovec_t * */
+ uarg[2] = p->iovcnt; /* size_t */
+ iarg[3] = p->offset; /* cloudabi_filesize_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi32_sys_fd_read */
+ case 10: {
+ struct cloudabi32_sys_fd_read_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->iov; /* const cloudabi32_iovec_t * */
+ uarg[2] = p->iovcnt; /* size_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_fd_replace */
+ case 11: {
+ struct cloudabi_sys_fd_replace_args *p = params;
+ iarg[0] = p->from; /* cloudabi_fd_t */
+ iarg[1] = p->to; /* cloudabi_fd_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_fd_seek */
+ case 12: {
+ struct cloudabi_sys_fd_seek_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ iarg[1] = p->offset; /* cloudabi_filedelta_t */
+ iarg[2] = p->whence; /* cloudabi_whence_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_fd_stat_get */
+ case 13: {
+ struct cloudabi_sys_fd_stat_get_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* cloudabi_fdstat_t * */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_fd_stat_put */
+ case 14: {
+ struct cloudabi_sys_fd_stat_put_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* const cloudabi_fdstat_t * */
+ iarg[2] = p->flags; /* cloudabi_fdsflags_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_fd_sync */
+ case 15: {
+ struct cloudabi_sys_fd_sync_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi32_sys_fd_write */
+ case 16: {
+ struct cloudabi32_sys_fd_write_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->iov; /* const cloudabi32_ciovec_t * */
+ uarg[2] = p->iovcnt; /* size_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_file_advise */
+ case 17: {
+ struct cloudabi_sys_file_advise_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ iarg[1] = p->offset; /* cloudabi_filesize_t */
+ iarg[2] = p->len; /* cloudabi_filesize_t */
+ iarg[3] = p->advice; /* cloudabi_advice_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_file_allocate */
+ case 18: {
+ struct cloudabi_sys_file_allocate_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ iarg[1] = p->offset; /* cloudabi_filesize_t */
+ iarg[2] = p->len; /* cloudabi_filesize_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_file_create */
+ case 19: {
+ struct cloudabi_sys_file_create_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->path; /* const char * */
+ uarg[2] = p->pathlen; /* size_t */
+ iarg[3] = p->type; /* cloudabi_filetype_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_file_link */
+ case 20: {
+ struct cloudabi_sys_file_link_args *p = params;
+ iarg[0] = p->fd1; /* cloudabi_lookup_t */
+ uarg[1] = (intptr_t) p->path1; /* const char * */
+ uarg[2] = p->path1len; /* size_t */
+ iarg[3] = p->fd2; /* cloudabi_fd_t */
+ uarg[4] = (intptr_t) p->path2; /* const char * */
+ uarg[5] = p->path2len; /* size_t */
+ *n_args = 6;
+ break;
+ }
+ /* cloudabi_sys_file_open */
+ case 21: {
+ struct cloudabi_sys_file_open_args *p = params;
+ iarg[0] = p->dirfd; /* cloudabi_lookup_t */
+ uarg[1] = (intptr_t) p->path; /* const char * */
+ uarg[2] = p->pathlen; /* size_t */
+ iarg[3] = p->oflags; /* cloudabi_oflags_t */
+ uarg[4] = (intptr_t) p->fds; /* const cloudabi_fdstat_t * */
+ *n_args = 5;
+ break;
+ }
+ /* cloudabi_sys_file_readdir */
+ case 22: {
+ struct cloudabi_sys_file_readdir_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* void * */
+ uarg[2] = p->nbyte; /* size_t */
+ iarg[3] = p->cookie; /* cloudabi_dircookie_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_file_readlink */
+ case 23: {
+ struct cloudabi_sys_file_readlink_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->path; /* const char * */
+ uarg[2] = p->pathlen; /* size_t */
+ uarg[3] = (intptr_t) p->buf; /* char * */
+ uarg[4] = p->bufsize; /* size_t */
+ *n_args = 5;
+ break;
+ }
+ /* cloudabi_sys_file_rename */
+ case 24: {
+ struct cloudabi_sys_file_rename_args *p = params;
+ iarg[0] = p->oldfd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->old; /* const char * */
+ uarg[2] = p->oldlen; /* size_t */
+ iarg[3] = p->newfd; /* cloudabi_fd_t */
+ uarg[4] = (intptr_t) p->new; /* const char * */
+ uarg[5] = p->newlen; /* size_t */
+ *n_args = 6;
+ break;
+ }
+ /* cloudabi_sys_file_stat_fget */
+ case 25: {
+ struct cloudabi_sys_file_stat_fget_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* cloudabi_filestat_t * */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_file_stat_fput */
+ case 26: {
+ struct cloudabi_sys_file_stat_fput_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* const cloudabi_filestat_t * */
+ iarg[2] = p->flags; /* cloudabi_fsflags_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_file_stat_get */
+ case 27: {
+ struct cloudabi_sys_file_stat_get_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_lookup_t */
+ uarg[1] = (intptr_t) p->path; /* const char * */
+ uarg[2] = p->pathlen; /* size_t */
+ uarg[3] = (intptr_t) p->buf; /* cloudabi_filestat_t * */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_file_stat_put */
+ case 28: {
+ struct cloudabi_sys_file_stat_put_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_lookup_t */
+ uarg[1] = (intptr_t) p->path; /* const char * */
+ uarg[2] = p->pathlen; /* size_t */
+ uarg[3] = (intptr_t) p->buf; /* const cloudabi_filestat_t * */
+ iarg[4] = p->flags; /* cloudabi_fsflags_t */
+ *n_args = 5;
+ break;
+ }
+ /* cloudabi_sys_file_symlink */
+ case 29: {
+ struct cloudabi_sys_file_symlink_args *p = params;
+ uarg[0] = (intptr_t) p->path1; /* const char * */
+ uarg[1] = p->path1len; /* size_t */
+ iarg[2] = p->fd; /* cloudabi_fd_t */
+ uarg[3] = (intptr_t) p->path2; /* const char * */
+ uarg[4] = p->path2len; /* size_t */
+ *n_args = 5;
+ break;
+ }
+ /* cloudabi_sys_file_unlink */
+ case 30: {
+ struct cloudabi_sys_file_unlink_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->path; /* const char * */
+ uarg[2] = p->pathlen; /* size_t */
+ iarg[3] = p->flags; /* cloudabi_ulflags_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_lock_unlock */
+ case 31: {
+ struct cloudabi_sys_lock_unlock_args *p = params;
+ uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */
+ iarg[1] = p->scope; /* cloudabi_scope_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_mem_advise */
+ case 32: {
+ struct cloudabi_sys_mem_advise_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* void * */
+ uarg[1] = p->len; /* size_t */
+ iarg[2] = p->advice; /* cloudabi_advice_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_mem_lock */
+ case 33: {
+ struct cloudabi_sys_mem_lock_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* const void * */
+ uarg[1] = p->len; /* size_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_mem_map */
+ case 34: {
+ struct cloudabi_sys_mem_map_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* void * */
+ uarg[1] = p->len; /* size_t */
+ iarg[2] = p->prot; /* cloudabi_mprot_t */
+ iarg[3] = p->flags; /* cloudabi_mflags_t */
+ iarg[4] = p->fd; /* cloudabi_fd_t */
+ iarg[5] = p->off; /* cloudabi_filesize_t */
+ *n_args = 6;
+ break;
+ }
+ /* cloudabi_sys_mem_protect */
+ case 35: {
+ struct cloudabi_sys_mem_protect_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* void * */
+ uarg[1] = p->len; /* size_t */
+ iarg[2] = p->prot; /* cloudabi_mprot_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_mem_sync */
+ case 36: {
+ struct cloudabi_sys_mem_sync_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* void * */
+ uarg[1] = p->len; /* size_t */
+ iarg[2] = p->flags; /* cloudabi_msflags_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_mem_unlock */
+ case 37: {
+ struct cloudabi_sys_mem_unlock_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* const void * */
+ uarg[1] = p->len; /* size_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_mem_unmap */
+ case 38: {
+ struct cloudabi_sys_mem_unmap_args *p = params;
+ uarg[0] = (intptr_t) p->addr; /* void * */
+ uarg[1] = p->len; /* size_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi32_sys_poll */
+ case 39: {
+ struct cloudabi32_sys_poll_args *p = params;
+ uarg[0] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */
+ uarg[1] = (intptr_t) p->out; /* cloudabi32_event_t * */
+ uarg[2] = p->nsubscriptions; /* size_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi32_sys_poll_fd */
+ case 40: {
+ struct cloudabi32_sys_poll_fd_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */
+ uarg[2] = p->nin; /* size_t */
+ uarg[3] = (intptr_t) p->out; /* cloudabi32_event_t * */
+ uarg[4] = p->nout; /* size_t */
+ uarg[5] = (intptr_t) p->timeout; /* const cloudabi32_subscription_t * */
+ *n_args = 6;
+ break;
+ }
+ /* cloudabi_sys_proc_exec */
+ case 41: {
+ struct cloudabi_sys_proc_exec_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->data; /* const void * */
+ uarg[2] = p->datalen; /* size_t */
+ uarg[3] = (intptr_t) p->fds; /* const cloudabi_fd_t * */
+ uarg[4] = p->fdslen; /* size_t */
+ *n_args = 5;
+ break;
+ }
+ /* cloudabi_sys_proc_exit */
+ case 42: {
+ struct cloudabi_sys_proc_exit_args *p = params;
+ iarg[0] = p->rval; /* cloudabi_exitcode_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_proc_fork */
+ case 43: {
+ *n_args = 0;
+ break;
+ }
+ /* cloudabi_sys_proc_raise */
+ case 44: {
+ struct cloudabi_sys_proc_raise_args *p = params;
+ iarg[0] = p->sig; /* cloudabi_signal_t */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_random_get */
+ case 45: {
+ struct cloudabi_sys_random_get_args *p = params;
+ uarg[0] = (intptr_t) p->buf; /* void * */
+ uarg[1] = p->nbyte; /* size_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_sock_accept */
+ case 46: {
+ struct cloudabi_sys_sock_accept_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_sock_bind */
+ case 47: {
+ struct cloudabi_sys_sock_bind_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ iarg[1] = p->fd; /* cloudabi_fd_t */
+ uarg[2] = (intptr_t) p->path; /* const char * */
+ uarg[3] = p->pathlen; /* size_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_sock_connect */
+ case 48: {
+ struct cloudabi_sys_sock_connect_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ iarg[1] = p->fd; /* cloudabi_fd_t */
+ uarg[2] = (intptr_t) p->path; /* const char * */
+ uarg[3] = p->pathlen; /* size_t */
+ *n_args = 4;
+ break;
+ }
+ /* cloudabi_sys_sock_listen */
+ case 49: {
+ struct cloudabi_sys_sock_listen_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ iarg[1] = p->backlog; /* cloudabi_backlog_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi32_sys_sock_recv */
+ case 50: {
+ struct cloudabi32_sys_sock_recv_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->in; /* const cloudabi32_recv_in_t * */
+ uarg[2] = (intptr_t) p->out; /* cloudabi32_recv_out_t * */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi32_sys_sock_send */
+ case 51: {
+ struct cloudabi32_sys_sock_send_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->in; /* const cloudabi32_send_in_t * */
+ uarg[2] = (intptr_t) p->out; /* cloudabi32_send_out_t * */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi_sys_sock_shutdown */
+ case 52: {
+ struct cloudabi_sys_sock_shutdown_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ iarg[1] = p->how; /* cloudabi_sdflags_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_sock_stat_get */
+ case 53: {
+ struct cloudabi_sys_sock_stat_get_args *p = params;
+ iarg[0] = p->sock; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */
+ iarg[2] = p->flags; /* cloudabi_ssflags_t */
+ *n_args = 3;
+ break;
+ }
+ /* cloudabi32_sys_thread_create */
+ case 54: {
+ struct cloudabi32_sys_thread_create_args *p = params;
+ uarg[0] = (intptr_t) p->attr; /* cloudabi32_threadattr_t * */
+ *n_args = 1;
+ break;
+ }
+ /* cloudabi_sys_thread_exit */
+ case 55: {
+ struct cloudabi_sys_thread_exit_args *p = params;
+ uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */
+ iarg[1] = p->scope; /* cloudabi_scope_t */
+ *n_args = 2;
+ break;
+ }
+ /* cloudabi_sys_thread_yield */
+ case 56: {
+ *n_args = 0;
+ break;
+ }
+ default:
+ *n_args = 0;
+ break;
+ };
+}
+static void
+systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
+{
+ const char *p = NULL;
+ switch (sysnum) {
+ /* cloudabi_sys_clock_res_get */
+ case 0:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_clockid_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_clock_time_get */
+ case 1:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_clockid_t";
+ break;
+ case 1:
+ p = "cloudabi_timestamp_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_condvar_signal */
+ case 2:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_condvar_t *";
+ break;
+ case 1:
+ p = "cloudabi_scope_t";
+ break;
+ case 2:
+ p = "cloudabi_nthreads_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_close */
+ case 3:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_create1 */
+ case 4:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_filetype_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_create2 */
+ case 5:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_filetype_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_datasync */
+ case 6:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_dup */
+ case 7:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_fd_pread */
+ case 8:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_iovec_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_filesize_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_fd_pwrite */
+ case 9:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_ciovec_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_filesize_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_fd_read */
+ case 10:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_iovec_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_replace */
+ case 11:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_fd_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_seek */
+ case 12:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_filedelta_t";
+ break;
+ case 2:
+ p = "cloudabi_whence_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_stat_get */
+ case 13:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_fdstat_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_stat_put */
+ case 14:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi_fdstat_t *";
+ break;
+ case 2:
+ p = "cloudabi_fdsflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_fd_sync */
+ case 15:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_fd_write */
+ case 16:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_ciovec_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_advise */
+ case 17:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_filesize_t";
+ break;
+ case 2:
+ p = "cloudabi_filesize_t";
+ break;
+ case 3:
+ p = "cloudabi_advice_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_allocate */
+ case 18:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_filesize_t";
+ break;
+ case 2:
+ p = "cloudabi_filesize_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_create */
+ case 19:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_filetype_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_link */
+ case 20:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_lookup_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_fd_t";
+ break;
+ case 4:
+ p = "const char *";
+ break;
+ case 5:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_open */
+ case 21:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_lookup_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_oflags_t";
+ break;
+ case 4:
+ p = "const cloudabi_fdstat_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_readdir */
+ case 22:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "void *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_dircookie_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_readlink */
+ case 23:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "char *";
+ break;
+ case 4:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_rename */
+ case 24:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_fd_t";
+ break;
+ case 4:
+ p = "const char *";
+ break;
+ case 5:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_stat_fget */
+ case 25:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_filestat_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_stat_fput */
+ case 26:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi_filestat_t *";
+ break;
+ case 2:
+ p = "cloudabi_fsflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_stat_get */
+ case 27:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_lookup_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_filestat_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_stat_put */
+ case 28:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_lookup_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "const cloudabi_filestat_t *";
+ break;
+ case 4:
+ p = "cloudabi_fsflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_symlink */
+ case 29:
+ switch(ndx) {
+ case 0:
+ p = "const char *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ case 2:
+ p = "cloudabi_fd_t";
+ break;
+ case 3:
+ p = "const char *";
+ break;
+ case 4:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_file_unlink */
+ case 30:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const char *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi_ulflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_lock_unlock */
+ case 31:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_lock_t *";
+ break;
+ case 1:
+ p = "cloudabi_scope_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_advise */
+ case 32:
+ switch(ndx) {
+ case 0:
+ p = "void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ case 2:
+ p = "cloudabi_advice_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_lock */
+ case 33:
+ switch(ndx) {
+ case 0:
+ p = "const void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_map */
+ case 34:
+ switch(ndx) {
+ case 0:
+ p = "void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ case 2:
+ p = "cloudabi_mprot_t";
+ break;
+ case 3:
+ p = "cloudabi_mflags_t";
+ break;
+ case 4:
+ p = "cloudabi_fd_t";
+ break;
+ case 5:
+ p = "cloudabi_filesize_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_protect */
+ case 35:
+ switch(ndx) {
+ case 0:
+ p = "void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ case 2:
+ p = "cloudabi_mprot_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_sync */
+ case 36:
+ switch(ndx) {
+ case 0:
+ p = "void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ case 2:
+ p = "cloudabi_msflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_unlock */
+ case 37:
+ switch(ndx) {
+ case 0:
+ p = "const void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_mem_unmap */
+ case 38:
+ switch(ndx) {
+ case 0:
+ p = "void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_poll */
+ case 39:
+ switch(ndx) {
+ case 0:
+ p = "const cloudabi32_subscription_t *";
+ break;
+ case 1:
+ p = "cloudabi32_event_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_poll_fd */
+ case 40:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_subscription_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi32_event_t *";
+ break;
+ case 4:
+ p = "size_t";
+ break;
+ case 5:
+ p = "const cloudabi32_subscription_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_proc_exec */
+ case 41:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const void *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "const cloudabi_fd_t *";
+ break;
+ case 4:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_proc_exit */
+ case 42:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_exitcode_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_proc_fork */
+ case 43:
+ break;
+ /* cloudabi_sys_proc_raise */
+ case 44:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_signal_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_random_get */
+ case 45:
+ switch(ndx) {
+ case 0:
+ p = "void *";
+ break;
+ case 1:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_sock_accept */
+ case 46:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_sockstat_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_sock_bind */
+ case 47:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_fd_t";
+ break;
+ case 2:
+ p = "const char *";
+ break;
+ case 3:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_sock_connect */
+ case 48:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_fd_t";
+ break;
+ case 2:
+ p = "const char *";
+ break;
+ case 3:
+ p = "size_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_sock_listen */
+ case 49:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_backlog_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_sock_recv */
+ case 50:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_recv_in_t *";
+ break;
+ case 2:
+ p = "cloudabi32_recv_out_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_sock_send */
+ case 51:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "const cloudabi32_send_in_t *";
+ break;
+ case 2:
+ p = "cloudabi32_send_out_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_sock_shutdown */
+ case 52:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_sdflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_sock_stat_get */
+ case 53:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
+ p = "cloudabi_sockstat_t *";
+ break;
+ case 2:
+ p = "cloudabi_ssflags_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi32_sys_thread_create */
+ case 54:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi32_threadattr_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_thread_exit */
+ case 55:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_lock_t *";
+ break;
+ case 1:
+ p = "cloudabi_scope_t";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_thread_yield */
+ case 56:
+ break;
+ default:
+ break;
+ };
+ if (p != NULL)
+ strlcpy(desc, p, descsz);
+}
+static void
+systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
+{
+ const char *p = NULL;
+ switch (sysnum) {
+ /* cloudabi_sys_clock_res_get */
+ case 0:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_timestamp_t";
+ break;
+ /* cloudabi_sys_clock_time_get */
+ case 1:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_timestamp_t";
+ break;
+ /* cloudabi_sys_condvar_signal */
+ case 2:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_close */
+ case 3:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_create1 */
+ case 4:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_fd_t";
+ break;
+ /* cloudabi_sys_fd_create2 */
+ case 5:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_datasync */
+ case 6:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_dup */
+ case 7:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_fd_t";
+ break;
+ /* cloudabi32_sys_fd_pread */
+ case 8:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi32_sys_fd_pwrite */
+ case 9:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi32_sys_fd_read */
+ case 10:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi_sys_fd_replace */
+ case 11:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_seek */
+ case 12:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_filesize_t";
+ break;
+ /* cloudabi_sys_fd_stat_get */
+ case 13:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_stat_put */
+ case 14:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_fd_sync */
+ case 15:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi32_sys_fd_write */
+ case 16:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi_sys_file_advise */
+ case 17:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_allocate */
+ case 18:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_create */
+ case 19:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_link */
+ case 20:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_open */
+ case 21:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_fd_t";
+ break;
+ /* cloudabi_sys_file_readdir */
+ case 22:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi_sys_file_readlink */
+ case 23:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi_sys_file_rename */
+ case 24:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_stat_fget */
+ case 25:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_stat_fput */
+ case 26:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_stat_get */
+ case 27:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_stat_put */
+ case 28:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_symlink */
+ case 29:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_file_unlink */
+ case 30:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_lock_unlock */
+ case 31:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_advise */
+ case 32:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_lock */
+ case 33:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_map */
+ case 34:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_protect */
+ case 35:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_sync */
+ case 36:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_unlock */
+ case 37:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_mem_unmap */
+ case 38:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi32_sys_poll */
+ case 39:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi32_sys_poll_fd */
+ case 40:
+ if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi_sys_proc_exec */
+ case 41:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_proc_exit */
+ case 42:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_proc_fork */
+ case 43:
+ /* cloudabi_sys_proc_raise */
+ case 44:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_random_get */
+ case 45:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_sock_accept */
+ case 46:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_fd_t";
+ break;
+ /* cloudabi_sys_sock_bind */
+ case 47:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_sock_connect */
+ case 48:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_sock_listen */
+ case 49:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi32_sys_sock_recv */
+ case 50:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi32_sys_sock_send */
+ case 51:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_sock_shutdown */
+ case 52:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_sock_stat_get */
+ case 53:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi32_sys_thread_create */
+ case 54:
+ if (ndx == 0 || ndx == 1)
+ p = "cloudabi_tid_t";
+ break;
+ /* cloudabi_sys_thread_exit */
+ case 55:
+ if (ndx == 0 || ndx == 1)
+ p = "void";
+ break;
+ /* cloudabi_sys_thread_yield */
+ case 56:
+ default:
+ break;
+ };
+ if (p != NULL)
+ strlcpy(desc, p, descsz);
+}
diff --git a/sys/compat/cloudabi32/cloudabi32_thread.c b/sys/compat/cloudabi32/cloudabi32_thread.c
new file mode 100644
index 0000000..50538d9
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_thread.c
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+
+#include <contrib/cloudabi/cloudabi32_types.h>
+
+#include <compat/cloudabi32/cloudabi32_proto.h>
+#include <compat/cloudabi32/cloudabi32_util.h>
+
+struct thread_create_args {
+ cloudabi32_threadattr_t attr;
+ uint32_t tcb;
+ lwpid_t tid;
+};
+
+static int
+initialize_thread(struct thread *td, void *thunk)
+{
+ struct thread_create_args *args = thunk;
+
+ /* Save the thread ID, so it can be returned. */
+ args->tid = td->td_tid;
+
+ /* Set up initial register contents. */
+ return (cloudabi32_thread_setregs(td, &args->attr, args->tcb));
+}
+
+int
+cloudabi32_sys_thread_create(struct thread *td,
+ struct cloudabi32_sys_thread_create_args *uap)
+{
+ struct thread_create_args args;
+ int error;
+
+ error = copyin(uap->attr, &args.attr, sizeof(args.attr));
+ if (error != 0)
+ return (error);
+
+ /* Remove some space on the top of the stack for the TCB. */
+ args.tcb = rounddown(args.attr.stack + args.attr.stack_size -
+ sizeof(cloudabi32_tcb_t), _Alignof(cloudabi32_tcb_t));
+ args.attr.stack_size = args.tcb - args.attr.stack;
+
+ error = thread_create(td, NULL, initialize_thread, &args);
+ if (error != 0)
+ return (error);
+ td->td_retval[0] = args.tid;
+ return (0);
+}
diff --git a/sys/compat/cloudabi32/cloudabi32_util.h b/sys/compat/cloudabi32/cloudabi32_util.h
new file mode 100644
index 0000000..c08c91e
--- /dev/null
+++ b/sys/compat/cloudabi32/cloudabi32_util.h
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2015 Nuxi, https://nuxi.nl/
+ *
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _CLOUDABI32_UTIL_H_
+#define _CLOUDABI32_UTIL_H_
+
+#include <sys/types.h>
+#define __ELF_WORD_SIZE 32
+#include <sys/imgact_elf.h>
+
+#include <contrib/cloudabi/cloudabi32_types.h>
+
+struct image_params;
+struct thread;
+
+extern Elf32_Brandinfo cloudabi32_brand;
+
+#define TO_PTR(x) ((void *)(uintptr_t)(x))
+
+/* Stack initialization during process execution. */
+register_t *cloudabi32_copyout_strings(struct image_params *);
+int cloudabi32_fixup(register_t **, struct image_params *);
+
+int cloudabi32_thread_setregs(struct thread *,
+ const cloudabi32_threadattr_t *, uint32_t);
+
+#endif
diff --git a/sys/compat/cloudabi32/syscalls.conf b/sys/compat/cloudabi32/syscalls.conf
new file mode 100644
index 0000000..8e6522a
--- /dev/null
+++ b/sys/compat/cloudabi32/syscalls.conf
@@ -0,0 +1,15 @@
+# $FreeBSD$
+sysnames="cloudabi32_syscalls.c"
+sysproto="cloudabi32_proto.h"
+sysproto_h=_CLOUDABI32_SYSPROTO_H_
+syshdr="cloudabi32_syscall.h"
+syssw="cloudabi32_sysent.c"
+sysmk="/dev/null"
+syscallprefix="CLOUDABI32_SYS_"
+switchname="cloudabi32_sysent"
+namesname="cloudabi32_syscallnames"
+systrace="cloudabi32_systrace_args.c"
+
+# Allow all system calls in capabilities mode. Extract the names of the
+# system calls from syscalls.master.
+capenabled=`sed -n -e 's/.*\<\(cloudabi[0-9]*_sys_[a-z0-9_]*\)\>.*/\1/p' $1 | tr '\n' ','`
diff --git a/sys/compat/cloudabi64/Makefile b/sys/compat/cloudabi64/Makefile
index 83d27a3..60ae571 100644
--- a/sys/compat/cloudabi64/Makefile
+++ b/sys/compat/cloudabi64/Makefile
@@ -8,7 +8,7 @@ sysent: cloudabi64_sysent.c cloudabi64_syscall.h cloudabi64_proto.h \
cloudabi64_sysent.c cloudabi64_syscall.h cloudabi64_proto.h \
cloudabi64_syscalls.c cloudabi64_systrace_args.c: \
- ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls.master \
+ ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls64.master \
syscalls.conf
- sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls.master \
+ sh ../../kern/makesyscalls.sh ../../contrib/cloudabi/syscalls64.master \
syscalls.conf
diff --git a/sys/compat/cloudabi64/cloudabi64_fd.c b/sys/compat/cloudabi64/cloudabi64_fd.c
index 7d0c69a..fcfcc42 100644
--- a/sys/compat/cloudabi64/cloudabi64_fd.c
+++ b/sys/compat/cloudabi64/cloudabi64_fd.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <contrib/cloudabi/cloudabi64_types.h>
#include <compat/cloudabi64/cloudabi64_proto.h>
+#include <compat/cloudabi64/cloudabi64_util.h>
/* Copies in 64-bit iovec structures from userspace. */
static int
@@ -70,9 +71,9 @@ cloudabi64_copyinuio(const cloudabi64_iovec_t *iovp, size_t iovcnt,
free(uio, M_IOV);
return (error);
}
- iov[i].iov_base = (void *)iovobj.iov_base;
+ iov[i].iov_base = TO_PTR(iovobj.iov_base);
iov[i].iov_len = iovobj.iov_len;
- if (iov[i].iov_len > SSIZE_MAX - uio->uio_resid) {
+ if (iov[i].iov_len > INT64_MAX - uio->uio_resid) {
free(uio, M_IOV);
return (EINVAL);
}
@@ -105,8 +106,7 @@ cloudabi64_sys_fd_pwrite(struct thread *td,
struct uio *uio;
int error;
- error = cloudabi64_copyinuio((const cloudabi64_iovec_t *)uap->iov,
- uap->iovcnt, &uio);
+ error = cloudabi64_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio);
if (error != 0)
return (error);
error = kern_pwritev(td, uap->fd, uio, uap->offset);
@@ -136,8 +136,7 @@ cloudabi64_sys_fd_write(struct thread *td,
struct uio *uio;
int error;
- error = cloudabi64_copyinuio((const cloudabi64_iovec_t *)uap->iov,
- uap->iovcnt, &uio);
+ error = cloudabi64_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio);
if (error != 0)
return (error);
error = kern_writev(td, uap->fd, uio);
diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c
index 246a887..da1ea11 100644
--- a/sys/compat/cloudabi64/cloudabi64_module.c
+++ b/sys/compat/cloudabi64/cloudabi64_module.c
@@ -38,8 +38,13 @@ __FBSDID("$FreeBSD$");
#include <contrib/cloudabi/cloudabi64_types.h>
+#include <compat/cloudabi/cloudabi_util.h>
+
#include <compat/cloudabi64/cloudabi64_util.h>
+extern char _binary_cloudabi64_vdso_o_start[];
+extern char _binary_cloudabi64_vdso_o_end[];
+
register_t *
cloudabi64_copyout_strings(struct image_params *imgp)
{
@@ -107,6 +112,8 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
VAL(CLOUDABI_AT_TID, td->td_tid),
+ PTR(CLOUDABI_AT_SYSINFO_EHDR,
+ imgp->proc->p_sysent->sv_shared_page_base),
#undef VAL
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
@@ -127,6 +134,9 @@ cloudabi64_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
+ cloudabi_vdso_init(cloudabi64_brand.sysvec,
+ _binary_cloudabi64_vdso_o_start,
+ _binary_cloudabi64_vdso_o_end);
if (elf64_insert_brand_entry(&cloudabi64_brand) < 0) {
printf("Failed to add CloudABI ELF brand handler\n");
return (EINVAL);
@@ -139,6 +149,7 @@ cloudabi64_modevent(module_t mod, int type, void *data)
printf("Failed to remove CloudABI ELF brand handler\n");
return (EINVAL);
}
+ cloudabi_vdso_destroy(cloudabi64_brand.sysvec);
return (0);
default:
return (EOPNOTSUPP);
diff --git a/sys/compat/cloudabi64/cloudabi64_poll.c b/sys/compat/cloudabi64/cloudabi64_poll.c
index e44d69f..63d8120 100644
--- a/sys/compat/cloudabi64/cloudabi64_poll.c
+++ b/sys/compat/cloudabi64/cloudabi64_poll.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <compat/cloudabi/cloudabi_util.h>
#include <compat/cloudabi64/cloudabi64_proto.h>
+#include <compat/cloudabi64/cloudabi64_util.h>
/* Converts a FreeBSD signal number to a CloudABI signal number. */
static cloudabi_signal_t
@@ -98,7 +99,7 @@ cloudabi64_kevent_copyin(void *arg, struct kevent *kevp, int count)
return (error);
memset(kevp, 0, sizeof(*kevp));
- kevp->udata = (void *)sub.userdata;
+ kevp->udata = TO_PTR(sub.userdata);
switch (sub.type) {
case CLOUDABI_EVENTTYPE_CLOCK:
kevp->filter = EVFILT_TIMER;
@@ -264,9 +265,9 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev.condvar.condvar = sub.condvar.condvar;
ev.error = cloudabi_convert_errno(
cloudabi_futex_condvar_wait(
- td, (cloudabi_condvar_t *)sub.condvar.condvar,
+ td, TO_PTR(sub.condvar.condvar),
sub.condvar.condvar_scope,
- (cloudabi_lock_t *)sub.condvar.lock,
+ TO_PTR(sub.condvar.lock),
sub.condvar.lock_scope,
CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0));
td->td_retval[0] = 1;
@@ -276,7 +277,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_rdlock(
- td, (cloudabi_lock_t *)sub.lock.lock,
+ td, TO_PTR(sub.lock.lock),
sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC,
UINT64_MAX, 0));
td->td_retval[0] = 1;
@@ -286,7 +287,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_wrlock(
- td, (cloudabi_lock_t *)sub.lock.lock,
+ td, TO_PTR(sub.lock.lock),
sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC,
UINT64_MAX, 0));
td->td_retval[0] = 1;
@@ -311,9 +312,9 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev[0].condvar.condvar = sub[0].condvar.condvar;
ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_condvar_wait(
- td, (cloudabi_condvar_t *)sub[0].condvar.condvar,
+ td, TO_PTR(sub[0].condvar.condvar),
sub[0].condvar.condvar_scope,
- (cloudabi_lock_t *)sub[0].condvar.lock,
+ TO_PTR(sub[0].condvar.lock),
sub[0].condvar.lock_scope, sub[1].clock.clock_id,
sub[1].clock.timeout, sub[1].clock.precision);
if (error == ETIMEDOUT) {
@@ -332,7 +333,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev[0].lock.lock = sub[0].lock.lock;
ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_rdlock(
- td, (cloudabi_lock_t *)sub[0].lock.lock,
+ td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
sub[1].clock.timeout, sub[1].clock.precision);
if (error == ETIMEDOUT) {
@@ -351,7 +352,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev[0].lock.lock = sub[0].lock.lock;
ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_wrlock(
- td, (cloudabi_lock_t *)sub[0].lock.lock,
+ td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
sub[1].clock.timeout, sub[1].clock.precision);
if (error == ETIMEDOUT) {
diff --git a/sys/compat/cloudabi64/cloudabi64_proto.h b/sys/compat/cloudabi64/cloudabi64_proto.h
index 79a0f60..aed44ad 100644
--- a/sys/compat/cloudabi64/cloudabi64_proto.h
+++ b/sys/compat/cloudabi64/cloudabi64_proto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed
*/
#ifndef _CLOUDABI64_SYSPROTO_H_
@@ -236,6 +236,14 @@ struct cloudabi64_sys_poll_args {
char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)];
char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)];
};
+struct cloudabi64_sys_poll_fd_args {
+ char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
+ char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)];
+ char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)];
+ char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)];
+ char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)];
+ char timeout_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi64_subscription_t *)];
+};
struct cloudabi_sys_proc_exec_args {
char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)];
@@ -302,20 +310,9 @@ struct cloudabi_sys_thread_exit_args {
char lock_l_[PADL_(cloudabi_lock_t *)]; cloudabi_lock_t * lock; char lock_r_[PADR_(cloudabi_lock_t *)];
char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)];
};
-struct cloudabi_sys_thread_tcb_set_args {
- char tcb_l_[PADL_(void *)]; void * tcb; char tcb_r_[PADR_(void *)];
-};
struct cloudabi_sys_thread_yield_args {
register_t dummy;
};
-struct cloudabi64_sys_poll_fd_args {
- char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
- char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)];
- char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)];
- char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)];
- char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)];
- char timeout_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi64_subscription_t *)];
-};
int cloudabi_sys_clock_res_get(struct thread *, struct cloudabi_sys_clock_res_get_args *);
int cloudabi_sys_clock_time_get(struct thread *, struct cloudabi_sys_clock_time_get_args *);
int cloudabi_sys_condvar_signal(struct thread *, struct cloudabi_sys_condvar_signal_args *);
@@ -356,6 +353,7 @@ int cloudabi_sys_mem_sync(struct thread *, struct cloudabi_sys_mem_sync_args *);
int cloudabi_sys_mem_unlock(struct thread *, struct cloudabi_sys_mem_unlock_args *);
int cloudabi_sys_mem_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *);
int cloudabi64_sys_poll(struct thread *, struct cloudabi64_sys_poll_args *);
+int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *);
int cloudabi_sys_proc_exec(struct thread *, struct cloudabi_sys_proc_exec_args *);
int cloudabi_sys_proc_exit(struct thread *, struct cloudabi_sys_proc_exit_args *);
int cloudabi_sys_proc_fork(struct thread *, struct cloudabi_sys_proc_fork_args *);
@@ -371,9 +369,7 @@ int cloudabi_sys_sock_shutdown(struct thread *, struct cloudabi_sys_sock_shutdow
int cloudabi_sys_sock_stat_get(struct thread *, struct cloudabi_sys_sock_stat_get_args *);
int cloudabi64_sys_thread_create(struct thread *, struct cloudabi64_sys_thread_create_args *);
int cloudabi_sys_thread_exit(struct thread *, struct cloudabi_sys_thread_exit_args *);
-int cloudabi_sys_thread_tcb_set(struct thread *, struct cloudabi_sys_thread_tcb_set_args *);
int cloudabi_sys_thread_yield(struct thread *, struct cloudabi_sys_thread_yield_args *);
-int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *);
#ifdef COMPAT_43
@@ -398,6 +394,12 @@ int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *
#endif /* COMPAT_FREEBSD7 */
+
+#ifdef COMPAT_FREEBSD10
+
+
+#endif /* COMPAT_FREEBSD10 */
+
#define CLOUDABI64_SYS_AUE_cloudabi_sys_clock_res_get AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_clock_time_get AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_condvar_signal AUE_NULL
@@ -438,6 +440,7 @@ int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *
#define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_unlock AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_unmap AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi64_sys_poll AUE_NULL
+#define CLOUDABI64_SYS_AUE_cloudabi64_sys_poll_fd AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_exec AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_exit AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_fork AUE_NULL
@@ -453,9 +456,7 @@ int cloudabi64_sys_poll_fd(struct thread *, struct cloudabi64_sys_poll_fd_args *
#define CLOUDABI64_SYS_AUE_cloudabi_sys_sock_stat_get AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi64_sys_thread_create AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_thread_exit AUE_NULL
-#define CLOUDABI64_SYS_AUE_cloudabi_sys_thread_tcb_set AUE_NULL
#define CLOUDABI64_SYS_AUE_cloudabi_sys_thread_yield AUE_NULL
-#define CLOUDABI64_SYS_AUE_cloudabi64_sys_poll_fd AUE_NULL
#undef PAD_
#undef PADL_
diff --git a/sys/compat/cloudabi64/cloudabi64_sock.c b/sys/compat/cloudabi64/cloudabi64_sock.c
index e6b9c94..3915ddf 100644
--- a/sys/compat/cloudabi64/cloudabi64_sock.c
+++ b/sys/compat/cloudabi64/cloudabi64_sock.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <compat/cloudabi/cloudabi_util.h>
#include <compat/cloudabi64/cloudabi64_proto.h>
+#include <compat/cloudabi64/cloudabi64_util.h>
static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket");
@@ -52,6 +53,7 @@ cloudabi64_sys_sock_recv(struct thread *td,
cloudabi64_recv_out_t ro = {};
cloudabi64_iovec_t iovobj;
struct msghdr msghdr = {};
+ const cloudabi64_iovec_t *user_iov;
size_t i;
int error;
@@ -65,14 +67,14 @@ cloudabi64_sys_sock_recv(struct thread *td,
msghdr.msg_iovlen = ri.ri_datalen;
msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec),
M_SOCKET, M_WAITOK);
+ user_iov = TO_PTR(ri.ri_data);
for (i = 0; i < msghdr.msg_iovlen; i++) {
- error = copyin(&((cloudabi64_iovec_t *)ri.ri_data)[i], &iovobj,
- sizeof(iovobj));
+ error = copyin(&user_iov[i], &iovobj, sizeof(iovobj));
if (error != 0) {
free(msghdr.msg_iov, M_SOCKET);
return (error);
}
- msghdr.msg_iov[i].iov_base = (void *)iovobj.iov_base;
+ msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base);
msghdr.msg_iov[i].iov_len = iovobj.iov_len;
}
msghdr.msg_name = &ss;
@@ -104,6 +106,7 @@ cloudabi64_sys_sock_send(struct thread *td,
cloudabi64_send_out_t so = {};
cloudabi64_ciovec_t iovobj;
struct msghdr msghdr = {};
+ const cloudabi64_ciovec_t *user_iov;
size_t i;
int error, flags;
@@ -117,14 +120,14 @@ cloudabi64_sys_sock_send(struct thread *td,
msghdr.msg_iovlen = si.si_datalen;
msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec),
M_SOCKET, M_WAITOK);
+ user_iov = TO_PTR(si.si_data);
for (i = 0; i < msghdr.msg_iovlen; i++) {
- error = copyin(&((cloudabi64_ciovec_t *)si.si_data)[i], &iovobj,
- sizeof(iovobj));
+ error = copyin(&user_iov[i], &iovobj, sizeof(iovobj));
if (error != 0) {
free(msghdr.msg_iov, M_SOCKET);
return (error);
}
- msghdr.msg_iov[i].iov_base = (void *)iovobj.iov_base;
+ msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base);
msghdr.msg_iov[i].iov_len = iovobj.iov_len;
}
diff --git a/sys/compat/cloudabi64/cloudabi64_syscall.h b/sys/compat/cloudabi64/cloudabi64_syscall.h
index b5694bf..7d99d5e 100644
--- a/sys/compat/cloudabi64/cloudabi64_syscall.h
+++ b/sys/compat/cloudabi64/cloudabi64_syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed
*/
#define CLOUDABI64_SYS_cloudabi_sys_clock_res_get 0
@@ -46,22 +46,21 @@
#define CLOUDABI64_SYS_cloudabi_sys_mem_unlock 37
#define CLOUDABI64_SYS_cloudabi_sys_mem_unmap 38
#define CLOUDABI64_SYS_cloudabi64_sys_poll 39
-#define CLOUDABI64_SYS_cloudabi_sys_proc_exec 40
-#define CLOUDABI64_SYS_cloudabi_sys_proc_exit 41
-#define CLOUDABI64_SYS_cloudabi_sys_proc_fork 42
-#define CLOUDABI64_SYS_cloudabi_sys_proc_raise 43
-#define CLOUDABI64_SYS_cloudabi_sys_random_get 44
-#define CLOUDABI64_SYS_cloudabi_sys_sock_accept 45
-#define CLOUDABI64_SYS_cloudabi_sys_sock_bind 46
-#define CLOUDABI64_SYS_cloudabi_sys_sock_connect 47
-#define CLOUDABI64_SYS_cloudabi_sys_sock_listen 48
-#define CLOUDABI64_SYS_cloudabi64_sys_sock_recv 49
-#define CLOUDABI64_SYS_cloudabi64_sys_sock_send 50
-#define CLOUDABI64_SYS_cloudabi_sys_sock_shutdown 51
-#define CLOUDABI64_SYS_cloudabi_sys_sock_stat_get 52
-#define CLOUDABI64_SYS_cloudabi64_sys_thread_create 53
-#define CLOUDABI64_SYS_cloudabi_sys_thread_exit 54
-#define CLOUDABI64_SYS_cloudabi_sys_thread_tcb_set 55
+#define CLOUDABI64_SYS_cloudabi64_sys_poll_fd 40
+#define CLOUDABI64_SYS_cloudabi_sys_proc_exec 41
+#define CLOUDABI64_SYS_cloudabi_sys_proc_exit 42
+#define CLOUDABI64_SYS_cloudabi_sys_proc_fork 43
+#define CLOUDABI64_SYS_cloudabi_sys_proc_raise 44
+#define CLOUDABI64_SYS_cloudabi_sys_random_get 45
+#define CLOUDABI64_SYS_cloudabi_sys_sock_accept 46
+#define CLOUDABI64_SYS_cloudabi_sys_sock_bind 47
+#define CLOUDABI64_SYS_cloudabi_sys_sock_connect 48
+#define CLOUDABI64_SYS_cloudabi_sys_sock_listen 49
+#define CLOUDABI64_SYS_cloudabi64_sys_sock_recv 50
+#define CLOUDABI64_SYS_cloudabi64_sys_sock_send 51
+#define CLOUDABI64_SYS_cloudabi_sys_sock_shutdown 52
+#define CLOUDABI64_SYS_cloudabi_sys_sock_stat_get 53
+#define CLOUDABI64_SYS_cloudabi64_sys_thread_create 54
+#define CLOUDABI64_SYS_cloudabi_sys_thread_exit 55
#define CLOUDABI64_SYS_cloudabi_sys_thread_yield 56
-#define CLOUDABI64_SYS_cloudabi64_sys_poll_fd 57
-#define CLOUDABI64_SYS_MAXSYSCALL 58
+#define CLOUDABI64_SYS_MAXSYSCALL 57
diff --git a/sys/compat/cloudabi64/cloudabi64_syscalls.c b/sys/compat/cloudabi64/cloudabi64_syscalls.c
index 03407ff..d430056 100644
--- a/sys/compat/cloudabi64/cloudabi64_syscalls.c
+++ b/sys/compat/cloudabi64/cloudabi64_syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed
*/
const char *cloudabi64_syscallnames[] = {
@@ -47,22 +47,21 @@ const char *cloudabi64_syscallnames[] = {
"cloudabi_sys_mem_unlock", /* 37 = cloudabi_sys_mem_unlock */
"cloudabi_sys_mem_unmap", /* 38 = cloudabi_sys_mem_unmap */
"cloudabi64_sys_poll", /* 39 = cloudabi64_sys_poll */
- "cloudabi_sys_proc_exec", /* 40 = cloudabi_sys_proc_exec */
- "cloudabi_sys_proc_exit", /* 41 = cloudabi_sys_proc_exit */
- "cloudabi_sys_proc_fork", /* 42 = cloudabi_sys_proc_fork */
- "cloudabi_sys_proc_raise", /* 43 = cloudabi_sys_proc_raise */
- "cloudabi_sys_random_get", /* 44 = cloudabi_sys_random_get */
- "cloudabi_sys_sock_accept", /* 45 = cloudabi_sys_sock_accept */
- "cloudabi_sys_sock_bind", /* 46 = cloudabi_sys_sock_bind */
- "cloudabi_sys_sock_connect", /* 47 = cloudabi_sys_sock_connect */
- "cloudabi_sys_sock_listen", /* 48 = cloudabi_sys_sock_listen */
- "cloudabi64_sys_sock_recv", /* 49 = cloudabi64_sys_sock_recv */
- "cloudabi64_sys_sock_send", /* 50 = cloudabi64_sys_sock_send */
- "cloudabi_sys_sock_shutdown", /* 51 = cloudabi_sys_sock_shutdown */
- "cloudabi_sys_sock_stat_get", /* 52 = cloudabi_sys_sock_stat_get */
- "cloudabi64_sys_thread_create", /* 53 = cloudabi64_sys_thread_create */
- "cloudabi_sys_thread_exit", /* 54 = cloudabi_sys_thread_exit */
- "cloudabi_sys_thread_tcb_set", /* 55 = cloudabi_sys_thread_tcb_set */
+ "cloudabi64_sys_poll_fd", /* 40 = cloudabi64_sys_poll_fd */
+ "cloudabi_sys_proc_exec", /* 41 = cloudabi_sys_proc_exec */
+ "cloudabi_sys_proc_exit", /* 42 = cloudabi_sys_proc_exit */
+ "cloudabi_sys_proc_fork", /* 43 = cloudabi_sys_proc_fork */
+ "cloudabi_sys_proc_raise", /* 44 = cloudabi_sys_proc_raise */
+ "cloudabi_sys_random_get", /* 45 = cloudabi_sys_random_get */
+ "cloudabi_sys_sock_accept", /* 46 = cloudabi_sys_sock_accept */
+ "cloudabi_sys_sock_bind", /* 47 = cloudabi_sys_sock_bind */
+ "cloudabi_sys_sock_connect", /* 48 = cloudabi_sys_sock_connect */
+ "cloudabi_sys_sock_listen", /* 49 = cloudabi_sys_sock_listen */
+ "cloudabi64_sys_sock_recv", /* 50 = cloudabi64_sys_sock_recv */
+ "cloudabi64_sys_sock_send", /* 51 = cloudabi64_sys_sock_send */
+ "cloudabi_sys_sock_shutdown", /* 52 = cloudabi_sys_sock_shutdown */
+ "cloudabi_sys_sock_stat_get", /* 53 = cloudabi_sys_sock_stat_get */
+ "cloudabi64_sys_thread_create", /* 54 = cloudabi64_sys_thread_create */
+ "cloudabi_sys_thread_exit", /* 55 = cloudabi_sys_thread_exit */
"cloudabi_sys_thread_yield", /* 56 = cloudabi_sys_thread_yield */
- "cloudabi64_sys_poll_fd", /* 57 = cloudabi64_sys_poll_fd */
};
diff --git a/sys/compat/cloudabi64/cloudabi64_sysent.c b/sys/compat/cloudabi64/cloudabi64_sysent.c
index 50f4a65..3b11850 100644
--- a/sys/compat/cloudabi64/cloudabi64_sysent.c
+++ b/sys/compat/cloudabi64/cloudabi64_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: head/sys/contrib/cloudabi/syscalls.master 297468 2016-03-31 18:50:06Z ed
+ * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed
*/
#include <sys/sysent.h>
@@ -55,22 +55,21 @@ struct sysent cloudabi64_sysent[] = {
{ AS(cloudabi_sys_mem_unlock_args), (sy_call_t *)cloudabi_sys_mem_unlock, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 37 = cloudabi_sys_mem_unlock */
{ AS(cloudabi_sys_mem_unmap_args), (sy_call_t *)cloudabi_sys_mem_unmap, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 38 = cloudabi_sys_mem_unmap */
{ AS(cloudabi64_sys_poll_args), (sy_call_t *)cloudabi64_sys_poll, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 39 = cloudabi64_sys_poll */
- { AS(cloudabi_sys_proc_exec_args), (sy_call_t *)cloudabi_sys_proc_exec, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 40 = cloudabi_sys_proc_exec */
- { AS(cloudabi_sys_proc_exit_args), (sy_call_t *)cloudabi_sys_proc_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_exit */
- { 0, (sy_call_t *)cloudabi_sys_proc_fork, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 42 = cloudabi_sys_proc_fork */
- { AS(cloudabi_sys_proc_raise_args), (sy_call_t *)cloudabi_sys_proc_raise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 43 = cloudabi_sys_proc_raise */
- { AS(cloudabi_sys_random_get_args), (sy_call_t *)cloudabi_sys_random_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 44 = cloudabi_sys_random_get */
- { AS(cloudabi_sys_sock_accept_args), (sy_call_t *)cloudabi_sys_sock_accept, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 45 = cloudabi_sys_sock_accept */
- { AS(cloudabi_sys_sock_bind_args), (sy_call_t *)cloudabi_sys_sock_bind, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 46 = cloudabi_sys_sock_bind */
- { AS(cloudabi_sys_sock_connect_args), (sy_call_t *)cloudabi_sys_sock_connect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 47 = cloudabi_sys_sock_connect */
- { AS(cloudabi_sys_sock_listen_args), (sy_call_t *)cloudabi_sys_sock_listen, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 48 = cloudabi_sys_sock_listen */
- { AS(cloudabi64_sys_sock_recv_args), (sy_call_t *)cloudabi64_sys_sock_recv, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 49 = cloudabi64_sys_sock_recv */
- { AS(cloudabi64_sys_sock_send_args), (sy_call_t *)cloudabi64_sys_sock_send, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 50 = cloudabi64_sys_sock_send */
- { AS(cloudabi_sys_sock_shutdown_args), (sy_call_t *)cloudabi_sys_sock_shutdown, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 51 = cloudabi_sys_sock_shutdown */
- { AS(cloudabi_sys_sock_stat_get_args), (sy_call_t *)cloudabi_sys_sock_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 52 = cloudabi_sys_sock_stat_get */
- { AS(cloudabi64_sys_thread_create_args), (sy_call_t *)cloudabi64_sys_thread_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 53 = cloudabi64_sys_thread_create */
- { AS(cloudabi_sys_thread_exit_args), (sy_call_t *)cloudabi_sys_thread_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 54 = cloudabi_sys_thread_exit */
- { AS(cloudabi_sys_thread_tcb_set_args), (sy_call_t *)cloudabi_sys_thread_tcb_set, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 55 = cloudabi_sys_thread_tcb_set */
+ { AS(cloudabi64_sys_poll_fd_args), (sy_call_t *)cloudabi64_sys_poll_fd, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 40 = cloudabi64_sys_poll_fd */
+ { AS(cloudabi_sys_proc_exec_args), (sy_call_t *)cloudabi_sys_proc_exec, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_exec */
+ { AS(cloudabi_sys_proc_exit_args), (sy_call_t *)cloudabi_sys_proc_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 42 = cloudabi_sys_proc_exit */
+ { 0, (sy_call_t *)cloudabi_sys_proc_fork, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 43 = cloudabi_sys_proc_fork */
+ { AS(cloudabi_sys_proc_raise_args), (sy_call_t *)cloudabi_sys_proc_raise, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 44 = cloudabi_sys_proc_raise */
+ { AS(cloudabi_sys_random_get_args), (sy_call_t *)cloudabi_sys_random_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 45 = cloudabi_sys_random_get */
+ { AS(cloudabi_sys_sock_accept_args), (sy_call_t *)cloudabi_sys_sock_accept, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 46 = cloudabi_sys_sock_accept */
+ { AS(cloudabi_sys_sock_bind_args), (sy_call_t *)cloudabi_sys_sock_bind, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 47 = cloudabi_sys_sock_bind */
+ { AS(cloudabi_sys_sock_connect_args), (sy_call_t *)cloudabi_sys_sock_connect, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 48 = cloudabi_sys_sock_connect */
+ { AS(cloudabi_sys_sock_listen_args), (sy_call_t *)cloudabi_sys_sock_listen, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 49 = cloudabi_sys_sock_listen */
+ { AS(cloudabi64_sys_sock_recv_args), (sy_call_t *)cloudabi64_sys_sock_recv, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 50 = cloudabi64_sys_sock_recv */
+ { AS(cloudabi64_sys_sock_send_args), (sy_call_t *)cloudabi64_sys_sock_send, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 51 = cloudabi64_sys_sock_send */
+ { AS(cloudabi_sys_sock_shutdown_args), (sy_call_t *)cloudabi_sys_sock_shutdown, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 52 = cloudabi_sys_sock_shutdown */
+ { AS(cloudabi_sys_sock_stat_get_args), (sy_call_t *)cloudabi_sys_sock_stat_get, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 53 = cloudabi_sys_sock_stat_get */
+ { AS(cloudabi64_sys_thread_create_args), (sy_call_t *)cloudabi64_sys_thread_create, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 54 = cloudabi64_sys_thread_create */
+ { AS(cloudabi_sys_thread_exit_args), (sy_call_t *)cloudabi_sys_thread_exit, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 55 = cloudabi_sys_thread_exit */
{ 0, (sy_call_t *)cloudabi_sys_thread_yield, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 56 = cloudabi_sys_thread_yield */
- { AS(cloudabi64_sys_poll_fd_args), (sy_call_t *)cloudabi64_sys_poll_fd, AUE_NULL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 57 = cloudabi64_sys_poll_fd */
};
diff --git a/sys/compat/cloudabi64/cloudabi64_systrace_args.c b/sys/compat/cloudabi64/cloudabi64_systrace_args.c
index 9429e8e..3e97b25 100644
--- a/sys/compat/cloudabi64/cloudabi64_systrace_args.c
+++ b/sys/compat/cloudabi64/cloudabi64_systrace_args.c
@@ -373,8 +373,20 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
*n_args = 3;
break;
}
- /* cloudabi_sys_proc_exec */
+ /* cloudabi64_sys_poll_fd */
case 40: {
+ struct cloudabi64_sys_poll_fd_args *p = params;
+ iarg[0] = p->fd; /* cloudabi_fd_t */
+ uarg[1] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */
+ uarg[2] = p->nin; /* size_t */
+ uarg[3] = (intptr_t) p->out; /* cloudabi64_event_t * */
+ uarg[4] = p->nout; /* size_t */
+ uarg[5] = (intptr_t) p->timeout; /* const cloudabi64_subscription_t * */
+ *n_args = 6;
+ break;
+ }
+ /* cloudabi_sys_proc_exec */
+ case 41: {
struct cloudabi_sys_proc_exec_args *p = params;
iarg[0] = p->fd; /* cloudabi_fd_t */
uarg[1] = (intptr_t) p->data; /* const void * */
@@ -385,26 +397,26 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_proc_exit */
- case 41: {
+ case 42: {
struct cloudabi_sys_proc_exit_args *p = params;
iarg[0] = p->rval; /* cloudabi_exitcode_t */
*n_args = 1;
break;
}
/* cloudabi_sys_proc_fork */
- case 42: {
+ case 43: {
*n_args = 0;
break;
}
/* cloudabi_sys_proc_raise */
- case 43: {
+ case 44: {
struct cloudabi_sys_proc_raise_args *p = params;
iarg[0] = p->sig; /* cloudabi_signal_t */
*n_args = 1;
break;
}
/* cloudabi_sys_random_get */
- case 44: {
+ case 45: {
struct cloudabi_sys_random_get_args *p = params;
uarg[0] = (intptr_t) p->buf; /* void * */
uarg[1] = p->nbyte; /* size_t */
@@ -412,7 +424,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_sock_accept */
- case 45: {
+ case 46: {
struct cloudabi_sys_sock_accept_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */
@@ -420,7 +432,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_sock_bind */
- case 46: {
+ case 47: {
struct cloudabi_sys_sock_bind_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
iarg[1] = p->fd; /* cloudabi_fd_t */
@@ -430,7 +442,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_sock_connect */
- case 47: {
+ case 48: {
struct cloudabi_sys_sock_connect_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
iarg[1] = p->fd; /* cloudabi_fd_t */
@@ -440,7 +452,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_sock_listen */
- case 48: {
+ case 49: {
struct cloudabi_sys_sock_listen_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
iarg[1] = p->backlog; /* cloudabi_backlog_t */
@@ -448,7 +460,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi64_sys_sock_recv */
- case 49: {
+ case 50: {
struct cloudabi64_sys_sock_recv_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
uarg[1] = (intptr_t) p->in; /* const cloudabi64_recv_in_t * */
@@ -457,7 +469,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi64_sys_sock_send */
- case 50: {
+ case 51: {
struct cloudabi64_sys_sock_send_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
uarg[1] = (intptr_t) p->in; /* const cloudabi64_send_in_t * */
@@ -466,7 +478,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_sock_shutdown */
- case 51: {
+ case 52: {
struct cloudabi_sys_sock_shutdown_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
iarg[1] = p->how; /* cloudabi_sdflags_t */
@@ -474,7 +486,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi_sys_sock_stat_get */
- case 52: {
+ case 53: {
struct cloudabi_sys_sock_stat_get_args *p = params;
iarg[0] = p->sock; /* cloudabi_fd_t */
uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */
@@ -483,44 +495,25 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
break;
}
/* cloudabi64_sys_thread_create */
- case 53: {
+ case 54: {
struct cloudabi64_sys_thread_create_args *p = params;
uarg[0] = (intptr_t) p->attr; /* cloudabi64_threadattr_t * */
*n_args = 1;
break;
}
/* cloudabi_sys_thread_exit */
- case 54: {
+ case 55: {
struct cloudabi_sys_thread_exit_args *p = params;
uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */
iarg[1] = p->scope; /* cloudabi_scope_t */
*n_args = 2;
break;
}
- /* cloudabi_sys_thread_tcb_set */
- case 55: {
- struct cloudabi_sys_thread_tcb_set_args *p = params;
- uarg[0] = (intptr_t) p->tcb; /* void * */
- *n_args = 1;
- break;
- }
/* cloudabi_sys_thread_yield */
case 56: {
*n_args = 0;
break;
}
- /* cloudabi64_sys_poll_fd */
- case 57: {
- struct cloudabi64_sys_poll_fd_args *p = params;
- iarg[0] = p->fd; /* cloudabi_fd_t */
- uarg[1] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */
- uarg[2] = p->nin; /* size_t */
- uarg[3] = (intptr_t) p->out; /* cloudabi64_event_t * */
- uarg[4] = p->nout; /* size_t */
- uarg[5] = (intptr_t) p->timeout; /* const cloudabi64_subscription_t * */
- *n_args = 6;
- break;
- }
default:
*n_args = 0;
break;
@@ -1177,13 +1170,38 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
};
break;
- /* cloudabi_sys_proc_exec */
+ /* cloudabi64_sys_poll_fd */
case 40:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
break;
case 1:
+ p = "const cloudabi64_subscription_t *";
+ break;
+ case 2:
+ p = "size_t";
+ break;
+ case 3:
+ p = "cloudabi64_event_t *";
+ break;
+ case 4:
+ p = "size_t";
+ break;
+ case 5:
+ p = "const cloudabi64_subscription_t *";
+ break;
+ default:
+ break;
+ };
+ break;
+ /* cloudabi_sys_proc_exec */
+ case 41:
+ switch(ndx) {
+ case 0:
+ p = "cloudabi_fd_t";
+ break;
+ case 1:
p = "const void *";
break;
case 2:
@@ -1200,7 +1218,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_proc_exit */
- case 41:
+ case 42:
switch(ndx) {
case 0:
p = "cloudabi_exitcode_t";
@@ -1210,10 +1228,10 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_proc_fork */
- case 42:
+ case 43:
break;
/* cloudabi_sys_proc_raise */
- case 43:
+ case 44:
switch(ndx) {
case 0:
p = "cloudabi_signal_t";
@@ -1223,7 +1241,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_random_get */
- case 44:
+ case 45:
switch(ndx) {
case 0:
p = "void *";
@@ -1236,7 +1254,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_sock_accept */
- case 45:
+ case 46:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1249,7 +1267,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_sock_bind */
- case 46:
+ case 47:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1268,7 +1286,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_sock_connect */
- case 47:
+ case 48:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1287,7 +1305,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_sock_listen */
- case 48:
+ case 49:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1300,7 +1318,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi64_sys_sock_recv */
- case 49:
+ case 50:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1316,7 +1334,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi64_sys_sock_send */
- case 50:
+ case 51:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1332,7 +1350,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_sock_shutdown */
- case 51:
+ case 52:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1345,7 +1363,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_sock_stat_get */
- case 52:
+ case 53:
switch(ndx) {
case 0:
p = "cloudabi_fd_t";
@@ -1361,7 +1379,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi64_sys_thread_create */
- case 53:
+ case 54:
switch(ndx) {
case 0:
p = "cloudabi64_threadattr_t *";
@@ -1371,7 +1389,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
};
break;
/* cloudabi_sys_thread_exit */
- case 54:
+ case 55:
switch(ndx) {
case 0:
p = "cloudabi_lock_t *";
@@ -1383,44 +1401,9 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
break;
};
break;
- /* cloudabi_sys_thread_tcb_set */
- case 55:
- switch(ndx) {
- case 0:
- p = "void *";
- break;
- default:
- break;
- };
- break;
/* cloudabi_sys_thread_yield */
case 56:
break;
- /* cloudabi64_sys_poll_fd */
- case 57:
- switch(ndx) {
- case 0:
- p = "cloudabi_fd_t";
- break;
- case 1:
- p = "const cloudabi64_subscription_t *";
- break;
- case 2:
- p = "size_t";
- break;
- case 3:
- p = "cloudabi64_event_t *";
- break;
- case 4:
- p = "size_t";
- break;
- case 5:
- p = "const cloudabi64_subscription_t *";
- break;
- default:
- break;
- };
- break;
default:
break;
};
@@ -1632,90 +1615,85 @@ systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
if (ndx == 0 || ndx == 1)
p = "size_t";
break;
- /* cloudabi_sys_proc_exec */
+ /* cloudabi64_sys_poll_fd */
case 40:
if (ndx == 0 || ndx == 1)
+ p = "size_t";
+ break;
+ /* cloudabi_sys_proc_exec */
+ case 41:
+ if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_proc_exit */
- case 41:
+ case 42:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_proc_fork */
- case 42:
- /* cloudabi_sys_proc_raise */
case 43:
+ /* cloudabi_sys_proc_raise */
+ case 44:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_random_get */
- case 44:
+ case 45:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_sock_accept */
- case 45:
+ case 46:
if (ndx == 0 || ndx == 1)
p = "cloudabi_fd_t";
break;
/* cloudabi_sys_sock_bind */
- case 46:
+ case 47:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_sock_connect */
- case 47:
+ case 48:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_sock_listen */
- case 48:
+ case 49:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi64_sys_sock_recv */
- case 49:
+ case 50:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi64_sys_sock_send */
- case 50:
+ case 51:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_sock_shutdown */
- case 51:
+ case 52:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_sock_stat_get */
- case 52:
+ case 53:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi64_sys_thread_create */
- case 53:
+ case 54:
if (ndx == 0 || ndx == 1)
p = "cloudabi_tid_t";
break;
/* cloudabi_sys_thread_exit */
- case 54:
- if (ndx == 0 || ndx == 1)
- p = "void";
- break;
- /* cloudabi_sys_thread_tcb_set */
case 55:
if (ndx == 0 || ndx == 1)
p = "void";
break;
/* cloudabi_sys_thread_yield */
case 56:
- /* cloudabi64_sys_poll_fd */
- case 57:
- if (ndx == 0 || ndx == 1)
- p = "size_t";
- break;
default:
break;
};
diff --git a/sys/compat/cloudabi64/cloudabi64_util.h b/sys/compat/cloudabi64/cloudabi64_util.h
index 29a90d7..5d50639 100644
--- a/sys/compat/cloudabi64/cloudabi64_util.h
+++ b/sys/compat/cloudabi64/cloudabi64_util.h
@@ -29,6 +29,7 @@
#define _CLOUDABI64_UTIL_H_
#include <sys/types.h>
+#define __ELF_WORD_SIZE 64
#include <sys/imgact_elf.h>
#include <contrib/cloudabi/cloudabi64_types.h>
@@ -38,6 +39,8 @@ struct thread;
extern Elf64_Brandinfo cloudabi64_brand;
+#define TO_PTR(x) ((void *)(uintptr_t)(x))
+
/* Stack initialization during process execution. */
register_t *cloudabi64_copyout_strings(struct image_params *);
int cloudabi64_fixup(register_t **, struct image_params *);
diff --git a/sys/compat/ia32/ia32_signal.h b/sys/compat/ia32/ia32_signal.h
index 78cb82a..ce51596 100644
--- a/sys/compat/ia32/ia32_signal.h
+++ b/sys/compat/ia32/ia32_signal.h
@@ -32,6 +32,8 @@
#ifndef _COMPAT_IA32_IA32_SIGNAL_H
#define _COMPAT_IA32_IA32_SIGNAL_H
+#include <compat/freebsd32/freebsd32_signal.h>
+
#define _MC_IA32_HASSEGS 0x1
#define _MC_IA32_HASBASES 0x2
#define _MC_IA32_HASFPXSTATE 0x4
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 54a9b2f..e7bf51f 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -2,7 +2,7 @@
* Copyright (c) 2010 Isilon Systems, Inc.
* Copyright (c) 2010 iX Systems, Inc.
* Copyright (c) 2010 Panasas, Inc.
- * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd.
+ * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -121,9 +121,9 @@ struct pci_device_id {
#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x04 /* Supported Link Speed 5.0GT/s */
#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x08 /* Supported Link Speed 8.0GT/s */
-#define IORESOURCE_MEM SYS_RES_MEMORY
-#define IORESOURCE_IO SYS_RES_IOPORT
-#define IORESOURCE_IRQ SYS_RES_IRQ
+#define IORESOURCE_MEM (1 << SYS_RES_MEMORY)
+#define IORESOURCE_IO (1 << SYS_RES_IOPORT)
+#define IORESOURCE_IRQ (1 << SYS_RES_IRQ)
enum pci_bus_speed {
PCI_SPEED_UNKNOWN = -1,
@@ -230,17 +230,33 @@ pci_resource_len(struct pci_dev *pdev, int bar)
return rle->count;
}
+static inline int
+pci_resource_type(struct pci_dev *pdev, int bar)
+{
+ struct pci_map *pm;
+
+ pm = pci_find_bar(pdev->dev.bsddev, PCIR_BAR(bar));
+ if (!pm)
+ return (-1);
+
+ if (PCI_BAR_IO(pm->pm_value))
+ return (SYS_RES_IOPORT);
+ else
+ return (SYS_RES_MEMORY);
+}
+
/*
* All drivers just seem to want to inspect the type not flags.
*/
static inline int
pci_resource_flags(struct pci_dev *pdev, int bar)
{
- struct resource_list_entry *rle;
+ int type;
- if ((rle = _pci_get_bar(pdev, bar)) == NULL)
+ type = pci_resource_type(pdev, bar);
+ if (type < 0)
return (0);
- return rle->type;
+ return (1 << type);
}
static inline const char *
@@ -300,8 +316,8 @@ pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
int rid;
int type;
- type = pci_resource_flags(pdev, bar);
- if (type == 0)
+ type = pci_resource_type(pdev, bar);
+ if (type < 0)
return (-ENODEV);
rid = PCIR_BAR(bar);
if (bus_alloc_resource_any(pdev->dev.bsddev, type, &rid,
OpenPOWER on IntegriCloud