diff --git a/Makefile.inc1 b/Makefile.inc1 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1519,8 +1519,6 @@ _sysent_PATH= ${TMPPATH}:/usr/libexec _sysent_dirs= sys/kern _sysent_dirs+= sys/compat/freebsd32 -_sysent_dirs+= sys/compat/cloudabi32 \ - sys/compat/cloudabi64 _sysent_dirs+= sys/amd64/linux \ sys/amd64/linux32 \ sys/arm/linux \ diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -40,6 +40,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20210921: remove couldabi +OLD_FILES+=usr/share/man/man4/cloudabi.4.gz + # 20210906: stop installing {llvm,clang,lldb}-tblgen OLD_FILES+=usr/bin/llvm-tblgen OLD_FILES+=usr/bin/clang-tblgen diff --git a/lib/libsysdecode/errno.c b/lib/libsysdecode/errno.c --- a/lib/libsysdecode/errno.c +++ b/lib/libsysdecode/errno.c @@ -40,87 +40,6 @@ #include #endif -#include - -static const int cloudabi_errno_table[] = { - [CLOUDABI_E2BIG] = E2BIG, - [CLOUDABI_EACCES] = EACCES, - [CLOUDABI_EADDRINUSE] = EADDRINUSE, - [CLOUDABI_EADDRNOTAVAIL] = EADDRNOTAVAIL, - [CLOUDABI_EAFNOSUPPORT] = EAFNOSUPPORT, - [CLOUDABI_EAGAIN] = EAGAIN, - [CLOUDABI_EALREADY] = EALREADY, - [CLOUDABI_EBADF] = EBADF, - [CLOUDABI_EBADMSG] = EBADMSG, - [CLOUDABI_EBUSY] = EBUSY, - [CLOUDABI_ECANCELED] = ECANCELED, - [CLOUDABI_ECHILD] = ECHILD, - [CLOUDABI_ECONNABORTED] = ECONNABORTED, - [CLOUDABI_ECONNREFUSED] = ECONNREFUSED, - [CLOUDABI_ECONNRESET] = ECONNRESET, - [CLOUDABI_EDEADLK] = EDEADLK, - [CLOUDABI_EDESTADDRREQ] = EDESTADDRREQ, - [CLOUDABI_EDOM] = EDOM, - [CLOUDABI_EDQUOT] = EDQUOT, - [CLOUDABI_EEXIST] = EEXIST, - [CLOUDABI_EFAULT] = EFAULT, - [CLOUDABI_EFBIG] = EFBIG, - [CLOUDABI_EHOSTUNREACH] = EHOSTUNREACH, - [CLOUDABI_EIDRM] = EIDRM, - [CLOUDABI_EILSEQ] = EILSEQ, - [CLOUDABI_EINPROGRESS] = EINPROGRESS, - [CLOUDABI_EINTR] = EINTR, - [CLOUDABI_EINVAL] = EINVAL, - [CLOUDABI_EIO] = EIO, - [CLOUDABI_EISCONN] = EISCONN, - [CLOUDABI_EISDIR] = EISDIR, - [CLOUDABI_ELOOP] = ELOOP, - [CLOUDABI_EMFILE] = EMFILE, - [CLOUDABI_EMLINK] = EMLINK, - [CLOUDABI_EMSGSIZE] = EMSGSIZE, - [CLOUDABI_EMULTIHOP] = EMULTIHOP, - [CLOUDABI_ENAMETOOLONG] = ENAMETOOLONG, - [CLOUDABI_ENETDOWN] = ENETDOWN, - [CLOUDABI_ENETRESET] = ENETRESET, - [CLOUDABI_ENETUNREACH] = ENETUNREACH, - [CLOUDABI_ENFILE] = ENFILE, - [CLOUDABI_ENOBUFS] = ENOBUFS, - [CLOUDABI_ENODEV] = ENODEV, - [CLOUDABI_ENOENT] = ENOENT, - [CLOUDABI_ENOEXEC] = ENOEXEC, - [CLOUDABI_ENOLCK] = ENOLCK, - [CLOUDABI_ENOLINK] = ENOLINK, - [CLOUDABI_ENOMEM] = ENOMEM, - [CLOUDABI_ENOMSG] = ENOMSG, - [CLOUDABI_ENOPROTOOPT] = ENOPROTOOPT, - [CLOUDABI_ENOSPC] = ENOSPC, - [CLOUDABI_ENOSYS] = ENOSYS, - [CLOUDABI_ENOTCONN] = ENOTCONN, - [CLOUDABI_ENOTDIR] = ENOTDIR, - [CLOUDABI_ENOTEMPTY] = ENOTEMPTY, - [CLOUDABI_ENOTRECOVERABLE] = ENOTRECOVERABLE, - [CLOUDABI_ENOTSOCK] = ENOTSOCK, - [CLOUDABI_ENOTSUP] = ENOTSUP, - [CLOUDABI_ENOTTY] = ENOTTY, - [CLOUDABI_ENXIO] = ENXIO, - [CLOUDABI_EOVERFLOW] = EOVERFLOW, - [CLOUDABI_EOWNERDEAD] = EOWNERDEAD, - [CLOUDABI_EPERM] = EPERM, - [CLOUDABI_EPIPE] = EPIPE, - [CLOUDABI_EPROTO] = EPROTO, - [CLOUDABI_EPROTONOSUPPORT] = EPROTONOSUPPORT, - [CLOUDABI_EPROTOTYPE] = EPROTOTYPE, - [CLOUDABI_ERANGE] = ERANGE, - [CLOUDABI_EROFS] = EROFS, - [CLOUDABI_ESPIPE] = ESPIPE, - [CLOUDABI_ESRCH] = ESRCH, - [CLOUDABI_ESTALE] = ESTALE, - [CLOUDABI_ETIMEDOUT] = ETIMEDOUT, - [CLOUDABI_ETXTBSY] = ETXTBSY, - [CLOUDABI_EXDEV] = EXDEV, - [CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE, -}; - int sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error) { @@ -145,12 +64,6 @@ break; } #endif - case SYSDECODE_ABI_CLOUDABI32: - case SYSDECODE_ABI_CLOUDABI64: - if (error >= 0 && - (unsigned int)error < nitems(cloudabi_errno_table)) - return (cloudabi_errno_table[error]); - break; default: break; } @@ -172,16 +85,6 @@ return (linux_errtbl[error]); break; #endif - case SYSDECODE_ABI_CLOUDABI32: - case SYSDECODE_ABI_CLOUDABI64: { - unsigned int i; - - for (i = 0; i < nitems(cloudabi_errno_table); i++) { - if (error == cloudabi_errno_table[i]) - return (i); - } - break; - } default: break; } diff --git a/lib/libsysdecode/syscallnames.c b/lib/libsysdecode/syscallnames.c --- a/lib/libsysdecode/syscallnames.c +++ b/lib/libsysdecode/syscallnames.c @@ -64,11 +64,6 @@ #include #endif -static -#include -static -#include - const char * sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code) { @@ -96,14 +91,6 @@ return (linux32_syscallnames[code]); break; #endif - case SYSDECODE_ABI_CLOUDABI32: - if (code < nitems(cloudabi32_syscallnames)) - return (cloudabi32_syscallnames[code]); - break; - case SYSDECODE_ABI_CLOUDABI64: - if (code < nitems(cloudabi64_syscallnames)) - return (cloudabi64_syscallnames[code]); - break; default: break; } diff --git a/lib/libsysdecode/sysdecode.h b/lib/libsysdecode/sysdecode.h --- a/lib/libsysdecode/sysdecode.h +++ b/lib/libsysdecode/sysdecode.h @@ -34,8 +34,6 @@ SYSDECODE_ABI_FREEBSD32, SYSDECODE_ABI_LINUX, SYSDECODE_ABI_LINUX32, - SYSDECODE_ABI_CLOUDABI64, - SYSDECODE_ABI_CLOUDABI32 }; int sysdecode_abi_to_freebsd_errno(enum sysdecode_abi _abi, int _error); diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -110,7 +110,6 @@ chromebook_platform.4 \ ${_chvgpio.4} \ ciss.4 \ - cloudabi.4 \ ${_coretemp.4} \ cp2112.4 \ ${_cpuctl.4} \ @@ -631,8 +630,6 @@ MLINKS+=cas.4 if_cas.4 MLINKS+=cdce.4 if_cdce.4 MLINKS+=cfi.4 cfid.4 -MLINKS+=cloudabi.4 cloudabi32.4 \ - cloudabi.4 cloudabi64.4 MLINKS+=crypto.4 cryptodev.4 MLINKS+=cue.4 if_cue.4 MLINKS+=cxgb.4 if_cxgb.4 diff --git a/share/man/man4/cloudabi.4 b/share/man/man4/cloudabi.4 deleted file mode 100644 --- a/share/man/man4/cloudabi.4 +++ /dev/null @@ -1,123 +0,0 @@ -.\" Copyright (c) 2015-2017 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$ -.Dd November 30, 2017 -.Dt CLOUDABI 4 -.Os -.Sh NAME -.Nm cloudabi , -.Nm cloudabi32 , -.Nm cloudabi64 -.Nd CloudABI support -.Sh SYNOPSIS -Support for 32-bit CloudABI executables can be compiled into the kernel -by adding this line to the kernel configuration file: -.Bd -ragged -offset indent -.Cd "options COMPAT_CLOUDABI32" -.Ed -.Pp -Similarly, -support for 64-bit CloudABI executables can be enabled by adding this -line: -.Bd -ragged -offset indent -.Cd "options COMPAT_CLOUDABI64" -.Ed -.Pp -CloudABI support can also be loaded at boot time from -.Xr loader.conf 5 : -.Bd -literal -offset indent -cloudabi_load="YES" -cloudabi32_load="YES" -cloudabi64_load="YES" -.Ed -.Sh DESCRIPTION -CloudABI is a POSIX-like pure capability-based runtime environment, -similar to -.Xr capsicum 4 . -It can be used to develop applications that are cross-platform, -easier to test, -and hardened against security exploits. -.Pp -Support for CloudABI on -.Fx -consists of three separate kernel modules. -The -.Nm cloudabi -kernel module implements all of the system calls that do not depend on -data structures that differ between hardware architectures. -.Pp -The -.Nm cloudabi32 -and -.Nm cloudabi64 -kernel modules provide implementations of all of the machine-dependent -system calls, -assuming that pointers stored in data structures are either 32 bits or -64 bits in size. -These modules also provide the image activators that load and start ELF -executables. -.Pp -Though the -.Nm cloudabi -module can be loaded on any architecture supported by -.Fx , -the -.Nm cloudabi32 -module is only available on amd64, arm64, armv6, armv7 and i386. -The same holds for the -.Nm cloudabi64 -module, -which is only available for amd64 and arm64. -.Pp -A full cross compilation toolchain for CloudABI is available in the -.Pa devel/cloudabi-toolchain -port. -.Pp -The -.Pa sysutils/cloudabi-utils -port provides the -.Xr cloudabi-run 1 -utility. -.Xr cloudabi-run 1 -can be used to safely execute CloudABI processes with access to a -restricted set of resources. -.Sh SEE ALSO -.Xr cloudabi-run 1 , -.Xr capsicum 4 , -.Xr linux 4 , -.Xr elf 5 -.Pp -CloudABI for FreeBSD: -.Pa https://nuxi.nl/cloudabi/freebsd/ . -.Pp -cloudlibc on GitHub: -.Pa https://github.com/NuxiNL/cloudlibc . -.Pp -The CloudABI Ports Collection on GitHub: -.Pa https://github.com/NuxiNL/cloudabi-ports . -.Sh HISTORY -CloudABI support first appeared in -.Fx 11.0 . -.Sh AUTHORS -.An Nuxi : Pa https://nuxi.nl/ . diff --git a/sys/amd64/cloudabi32/cloudabi32_sysvec.c b/sys/amd64/cloudabi32/cloudabi32_sysvec.c deleted file mode 100644 --- a/sys/amd64/cloudabi32/cloudabi32_sysvec.c +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * Copyright (c) 2015-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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -extern const char *cloudabi32_syscallnames[]; -extern struct sysent cloudabi32_sysent[]; - -extern unsigned long ia32_maxssiz; - -static int -cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp) -{ - int error; - uint32_t args[2]; - - /* Place auxiliary vector and TCB on the stack. */ - error = cloudabi32_fixup(stack_base, imgp); - if (error != 0) - return (error); - - /* - * On i386, the TCB is referred to by %gs:0. Reuse the empty - * space normally used by the return address (args[0]) to store - * a single element array, containing a pointer to the TCB. %gs - * base will point to this. - * - * Also let the first argument of the entry point (args[1]) - * refer to the auxiliary vector, which is stored right after - * the TCB. - */ - args[0] = *stack_base; - args[1] = *stack_base + - roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); - *stack_base -= roundup2(sizeof(args), sizeof(register_t)); - return (copyout(args, (void *)*stack_base, sizeof(args))); -} - -static void -cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, - uintptr_t stack) -{ - - ia32_setregs(td, imgp, stack); - (void)cpu_set_user_tls(td, TO_PTR(stack)); -} - -static int -cloudabi32_fetch_syscall_args(struct thread *td) -{ - struct trapframe *frame; - struct syscall_args *sa; - int error; - - frame = td->td_frame; - sa = &td->td_sa; - - /* Obtain system call number. */ - sa->code = frame->tf_rax; - sa->original_code = sa->code; - if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) - return (ENOSYS); - sa->callp = &cloudabi32_sysent[sa->code]; - - /* - * Fetch system call arguments. - * - * The vDSO has already made sure that the arguments are - * eight-byte aligned. Pointers and size_t parameters are - * zero-extended. This makes it possible to copy in the - * arguments directly. As long as the call doesn't use 32-bit - * data structures, we can just invoke the same system call - * implementation used by 64-bit processes. - */ - error = copyin((void *)frame->tf_rcx, sa->args, - sa->callp->sy_narg * sizeof(sa->args[0])); - if (error != 0) - return (error); - - /* Default system call return values. */ - td->td_retval[0] = 0; - td->td_retval[1] = 0; - return (0); -} - -static void -cloudabi32_set_syscall_retval(struct thread *td, int error) -{ - struct trapframe *frame = td->td_frame; - - switch (error) { - case 0: - /* - * System call succeeded. - * - * Simply copy out the 64-bit return values into the - * same buffer provided for system call arguments. The - * vDSO will copy them to the right spot, truncating - * pointers and size_t values to 32 bits. - */ - frame->tf_rax = copyout(td->td_retval, (void *)frame->tf_rcx, - sizeof(td->td_retval)) == 0 ? 0 : CLOUDABI_EFAULT; - break; - case ERESTART: - /* Restart system call. */ - frame->tf_rip -= frame->tf_err; - frame->tf_r10 = frame->tf_rcx; - set_pcb_flags(td->td_pcb, PCB_FULL_IRET); - break; - case EJUSTRETURN: - break; - default: - /* System call returned an error. */ - frame->tf_rax = cloudabi_convert_errno(error); - break; - } -} - -static void -cloudabi32_schedtail(struct thread *td) -{ - struct trapframe *frame = td->td_frame; - register_t retval[2]; - - /* Return values for processes returning from fork. */ - if ((td->td_pflags & TDP_FORKING) != 0) { - retval[0] = CLOUDABI_PROCESS_CHILD; - retval[1] = td->td_tid; - copyout(retval, (void *)frame->tf_rcx, sizeof(retval)); - } -} - -int -cloudabi32_thread_setregs(struct thread *td, - const cloudabi32_threadattr_t *attr, uint32_t tcb) -{ - stack_t stack; - uint32_t args[3]; - void *frameptr; - int error; - - /* Perform standard register initialization. */ - stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_len - sizeof(args); - cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); - - /* - * Copy the arguments for the thread entry point onto the stack - * (args[1] and args[2]). Similar to process startup, use the - * otherwise unused return address (args[0]) for TLS. - */ - args[0] = tcb; - args[1] = td->td_tid; - args[2] = attr->argument; - frameptr = (void *)td->td_frame->tf_rsp; - error = copyout(args, frameptr, sizeof(args)); - if (error != 0) - return (error); - - return (cpu_set_user_tls(td, frameptr)); -} - -static struct sysentvec cloudabi32_elf_sysvec = { - .sv_size = CLOUDABI32_SYS_MAXSYSCALL, - .sv_table = cloudabi32_sysent, - .sv_fixup = cloudabi32_fixup_tcb, - .sv_name = "CloudABI ELF32", - .sv_coredump = elf32_coredump, - .sv_elf_core_osabi = ELFOSABI_FREEBSD, - .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, - .sv_elf_core_prepare_notes = elf32_prepare_notes, - .sv_minuser = FREEBSD32_MINUSER, - .sv_maxuser = FREEBSD32_MAXUSER, - .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, - .sv_copyout_strings = cloudabi32_copyout_strings, - .sv_setregs = cloudabi32_proc_setregs, - .sv_fixlimit = ia32_fixlimit, - .sv_maxssiz = &ia32_maxssiz, - .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_IA32 | SV_ILP32, - .sv_set_syscall_retval = cloudabi32_set_syscall_retval, - .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, - .sv_syscallnames = cloudabi32_syscallnames, - .sv_schedtail = cloudabi32_schedtail, - .sv_set_fork_retval = x86_set_fork_retval, -}; - -INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); - -Elf32_Brandinfo cloudabi32_brand = { - .brand = ELFOSABI_CLOUDABI, - .machine = EM_386, - .sysvec = &cloudabi32_elf_sysvec, - .flags = BI_BRAND_ONLY_STATIC, -}; diff --git a/sys/amd64/cloudabi64/cloudabi64_sysvec.c b/sys/amd64/cloudabi64/cloudabi64_sysvec.c deleted file mode 100644 --- a/sys/amd64/cloudabi64/cloudabi64_sysvec.c +++ /dev/null @@ -1,226 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -extern const char *cloudabi64_syscallnames[]; -extern struct sysent cloudabi64_sysent[]; - -static int -cloudabi64_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp) -{ - int error; - register_t tcbptr; - - /* Place auxiliary vector and TCB on the stack. */ - error = cloudabi64_fixup(stack_base, imgp); - if (error != 0) - return (error); - - /* - * On x86-64, the TCB is referred to by %fs:0. Take some space - * from the top of the stack to store a single element array, - * containing a pointer to the TCB. %fs base will point to this. - */ - tcbptr = (register_t)*stack_base; - *stack_base -= sizeof(tcbptr); - return (copyout(&tcbptr, (void *)*stack_base, sizeof(tcbptr))); -} - -static void -cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp, - uintptr_t stack) -{ - struct trapframe *regs; - - exec_setregs(td, imgp, stack); - - /* - * The stack now contains a pointer to the TCB, the TCB itself, - * and the auxiliary vector. Let %rdx point to the auxiliary - * vector, and set %fs base to the address of the TCB. - */ - regs = td->td_frame; - regs->tf_rdi = stack + sizeof(register_t) + - roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t)); - (void)cpu_set_user_tls(td, TO_PTR(stack)); -} - -static int -cloudabi64_fetch_syscall_args(struct thread *td) -{ - struct trapframe *frame; - struct syscall_args *sa; - - frame = td->td_frame; - sa = &td->td_sa; - - /* Obtain system call number. */ - sa->code = frame->tf_rax; - sa->original_code = sa->code; - if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL) - return (ENOSYS); - sa->callp = &cloudabi64_sysent[sa->code]; - - /* Fetch system call arguments. */ - sa->args[0] = frame->tf_rdi; - sa->args[1] = frame->tf_rsi; - sa->args[2] = frame->tf_rdx; - sa->args[3] = frame->tf_rcx; /* Actually %r10. */ - sa->args[4] = frame->tf_r8; - sa->args[5] = frame->tf_r9; - - /* Default system call return values. */ - td->td_retval[0] = 0; - td->td_retval[1] = frame->tf_rdx; - return (0); -} - -static void -cloudabi64_set_syscall_retval(struct thread *td, int error) -{ - struct trapframe *frame = td->td_frame; - - switch (error) { - case 0: - /* System call succeeded. */ - frame->tf_rax = td->td_retval[0]; - frame->tf_rdx = td->td_retval[1]; - frame->tf_rflags &= ~PSL_C; - break; - case ERESTART: - /* Restart system call. */ - frame->tf_rip -= frame->tf_err; - frame->tf_r10 = frame->tf_rcx; - set_pcb_flags(td->td_pcb, PCB_FULL_IRET); - break; - case EJUSTRETURN: - break; - default: - /* System call returned an error. */ - frame->tf_rax = cloudabi_convert_errno(error); - frame->tf_rflags |= PSL_C; - break; - } -} - -static void -cloudabi64_schedtail(struct thread *td) -{ - struct trapframe *frame = td->td_frame; - - /* Initial register values for processes returning from fork. */ - frame->tf_rax = CLOUDABI_PROCESS_CHILD; - frame->tf_rdx = td->td_tid; -} - -int -cloudabi64_thread_setregs(struct thread *td, - const cloudabi64_threadattr_t *attr, uint64_t tcb) -{ - struct trapframe *frame; - stack_t stack; - uint64_t tcbptr; - int error; - - /* - * On x86-64, the TCB is referred to by %fs:0. Take some space - * from the top of the stack to store a single element array, - * containing a pointer to the TCB. %fs base will point to this. - */ - tcbptr = rounddown(attr->stack + attr->stack_len - sizeof(tcbptr), - _Alignof(tcbptr)); - error = copyout(&tcb, (void *)tcbptr, sizeof(tcb)); - if (error != 0) - return (error); - - /* Perform standard register initialization. */ - stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = tcbptr - attr->stack; - cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); - - /* - * Pass in the thread ID of the new thread and the argument - * pointer provided by the parent thread in as arguments to the - * entry point. - */ - frame = td->td_frame; - frame->tf_rdi = td->td_tid; - frame->tf_rsi = attr->argument; - - return (cpu_set_user_tls(td, TO_PTR(tcbptr))); -} - -static struct sysentvec cloudabi64_elf_sysvec = { - .sv_size = CLOUDABI64_SYS_MAXSYSCALL, - .sv_table = cloudabi64_sysent, - .sv_fixup = cloudabi64_fixup_tcb, - .sv_name = "CloudABI ELF64", - .sv_coredump = elf64_coredump, - .sv_elf_core_osabi = ELFOSABI_FREEBSD, - .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, - .sv_elf_core_prepare_notes = elf64_prepare_notes, - .sv_minuser = VM_MIN_ADDRESS, - /* Keep top page reserved to work around AMD Ryzen stability issues. */ - .sv_maxuser = VM_MAXUSER_ADDRESS - PAGE_SIZE, - .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, - .sv_copyout_strings = cloudabi64_copyout_strings, - .sv_setregs = cloudabi64_proc_setregs, - .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_LP64, - .sv_set_syscall_retval = cloudabi64_set_syscall_retval, - .sv_fetch_syscall_args = cloudabi64_fetch_syscall_args, - .sv_syscallnames = cloudabi64_syscallnames, - .sv_schedtail = cloudabi64_schedtail, - .sv_set_fork_retval = x86_set_fork_retval, -}; - -INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec); - -Elf64_Brandinfo cloudabi64_brand = { - .brand = ELFOSABI_CLOUDABI, - .machine = EM_X86_64, - .sysvec = &cloudabi64_elf_sysvec, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_ONLY_STATIC, -}; diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -626,12 +626,6 @@ # Enable (32-bit) a.out binary support options COMPAT_AOUT -# Enable 32-bit runtime support for CloudABI binaries. -options COMPAT_CLOUDABI32 - -# Enable 64-bit runtime support for CloudABI binaries. -options COMPAT_CLOUDABI64 - ##################################################################### # ZFS support diff --git a/sys/arm/cloudabi32/cloudabi32_sysvec.c b/sys/arm/cloudabi32/cloudabi32_sysvec.c deleted file mode 100644 --- a/sys/arm/cloudabi32/cloudabi32_sysvec.c +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * Copyright (c) 2015-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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -extern const char *cloudabi32_syscallnames[]; -extern struct sysent cloudabi32_sysent[]; - -static void -cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, - uintptr_t stack) -{ - struct trapframe *regs; - - exec_setregs(td, imgp, stack); - - /* - * The stack now contains a pointer to the TCB and the auxiliary - * vector. Let r0 point to the auxiliary vector, and set - * tpidrurw to the TCB. - */ - regs = td->td_frame; - regs->tf_r0 = - stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); - (void)cpu_set_user_tls(td, TO_PTR(stack)); -} - -static int -cloudabi32_fetch_syscall_args(struct thread *td) -{ - struct trapframe *frame; - struct syscall_args *sa; - int error; - - frame = td->td_frame; - sa = &td->td_sa; - - /* Obtain system call number. */ - sa->code = frame->tf_r12; - sa->original_code = sa->code; - if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) - return (ENOSYS); - sa->callp = &cloudabi32_sysent[sa->code]; - - /* Fetch system call arguments from registers and the stack. */ - sa->args[0] = frame->tf_r0; - sa->args[1] = frame->tf_r1; - sa->args[2] = frame->tf_r2; - sa->args[3] = frame->tf_r3; - if (sa->callp->sy_narg > 4) { - error = copyin((void *)td->td_frame->tf_usr_sp, &sa->args[4], - (sa->callp->sy_narg - 4) * sizeof(register_t)); - if (error != 0) - return (error); - } - - /* Default system call return values. */ - td->td_retval[0] = 0; - td->td_retval[1] = frame->tf_r1; - return (0); -} - -static void -cloudabi32_set_syscall_retval(struct thread *td, int error) -{ - struct trapframe *frame = td->td_frame; - - switch (error) { - case 0: - /* System call succeeded. */ - frame->tf_r0 = td->td_retval[0]; - frame->tf_r1 = td->td_retval[1]; - frame->tf_spsr &= ~PSR_C; - break; - case ERESTART: - /* Restart system call. */ - frame->tf_pc -= 4; - break; - case EJUSTRETURN: - break; - default: - /* System call returned an error. */ - frame->tf_r0 = cloudabi_convert_errno(error); - frame->tf_spsr |= PSR_C; - break; - } -} - -static void -cloudabi32_schedtail(struct thread *td) -{ - struct trapframe *frame = td->td_frame; - - /* - * Initial register values for processes returning from fork. - * Make sure that we only set these values when forking, not - * when creating a new thread. - */ - if ((td->td_pflags & TDP_FORKING) != 0) { - frame->tf_r0 = CLOUDABI_PROCESS_CHILD; - frame->tf_r1 = td->td_tid; - } -} - -int -cloudabi32_thread_setregs(struct thread *td, - const cloudabi32_threadattr_t *attr, uint32_t tcb) -{ - struct trapframe *frame; - stack_t stack; - - /* Perform standard register initialization. */ - stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_len; - cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); - - /* - * Pass in the thread ID of the new thread and the argument - * pointer provided by the parent thread in as arguments to the - * entry point. - */ - frame = td->td_frame; - frame->tf_r0 = td->td_tid; - frame->tf_r1 = attr->argument; - - /* Set up TLS. */ - return (cpu_set_user_tls(td, TO_PTR(tcb))); -} - -static struct sysentvec cloudabi32_elf_sysvec = { - .sv_size = CLOUDABI32_SYS_MAXSYSCALL, - .sv_table = cloudabi32_sysent, - .sv_fixup = cloudabi32_fixup, - .sv_name = "CloudABI ELF32", - .sv_coredump = elf32_coredump, - .sv_elf_core_osabi = ELFOSABI_FREEBSD, - .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, - .sv_elf_core_prepare_notes = elf32_prepare_notes, - .sv_minuser = VM_MIN_ADDRESS, - .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, - .sv_copyout_strings = cloudabi32_copyout_strings, - .sv_setregs = cloudabi32_proc_setregs, - .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_ILP32, - .sv_set_syscall_retval = cloudabi32_set_syscall_retval, - .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, - .sv_syscallnames = cloudabi32_syscallnames, - .sv_schedtail = cloudabi32_schedtail, -}; - -INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); - -Elf32_Brandinfo cloudabi32_brand = { - .brand = ELFOSABI_CLOUDABI, - .machine = EM_ARM, - .sysvec = &cloudabi32_elf_sysvec, - .flags = BI_BRAND_ONLY_STATIC, -}; diff --git a/sys/arm64/cloudabi32/cloudabi32_sysvec.c b/sys/arm64/cloudabi32/cloudabi32_sysvec.c deleted file mode 100644 --- a/sys/arm64/cloudabi32/cloudabi32_sysvec.c +++ /dev/null @@ -1,207 +0,0 @@ -/*- - * Copyright (c) 2015-2017 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -extern const char *cloudabi32_syscallnames[]; -extern struct sysent cloudabi32_sysent[]; - -static void -cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, - uintptr_t stack) -{ - struct trapframe *regs; - - regs = td->td_frame; - memset(regs, 0, sizeof(*regs)); - regs->tf_x[0] = - stack + roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); - regs->tf_x[13] = STACKALIGN(stack); - regs->tf_elr = imgp->entry_addr; - regs->tf_spsr |= PSR_AARCH32; - (void)cpu_set_user_tls(td, TO_PTR(stack)); -} - -static int -cloudabi32_fetch_syscall_args(struct thread *td) -{ - struct trapframe *frame; - struct syscall_args *sa; - int error; - - frame = td->td_frame; - sa = &td->td_sa; - - /* Obtain system call number. */ - sa->code = frame->tf_x[0]; - sa->original_code = sa->code; - if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) - return (ENOSYS); - sa->callp = &cloudabi32_sysent[sa->code]; - - /* - * Fetch system call arguments. - * - * The vDSO has already made sure that the arguments are - * eight-byte aligned. Pointers and size_t parameters are - * zero-extended. This makes it possible to copy in the - * arguments directly. As long as the call doesn't use 32-bit - * data structures, we can just invoke the same system call - * implementation used by 64-bit processes. - */ - error = copyin((void *)frame->tf_x[2], sa->args, - sa->callp->sy_narg * sizeof(sa->args[0])); - if (error != 0) - return (error); - - /* Default system call return values. */ - td->td_retval[0] = 0; - td->td_retval[1] = 0; - return (0); -} - -static void -cloudabi32_set_syscall_retval(struct thread *td, int error) -{ - struct trapframe *frame = td->td_frame; - - switch (error) { - case 0: - /* - * System call succeeded. - * - * Simply copy out the 64-bit return values into the - * same buffer provided for system call arguments. The - * vDSO will copy them to the right spot, truncating - * pointers and size_t values to 32 bits. - */ - if (copyout(td->td_retval, (void *)frame->tf_x[2], - sizeof(td->td_retval)) == 0) { - frame->tf_x[0] = 0; - frame->tf_spsr &= ~PSR_C; - } else { - frame->tf_x[0] = CLOUDABI_EFAULT; - frame->tf_spsr |= PSR_C; - } - break; - case ERESTART: - /* Restart system call. */ - frame->tf_elr -= 4; - break; - case EJUSTRETURN: - break; - default: - /* System call returned an error. */ - frame->tf_x[0] = cloudabi_convert_errno(error); - frame->tf_spsr |= PSR_C; - break; - } -} - -static void -cloudabi32_schedtail(struct thread *td) -{ - struct trapframe *frame = td->td_frame; - register_t retval[2]; - - /* Return values for processes returning from fork. */ - if ((td->td_pflags & TDP_FORKING) != 0) { - retval[0] = CLOUDABI_PROCESS_CHILD; - retval[1] = td->td_tid; - copyout(retval, (void *)frame->tf_x[2], sizeof(retval)); - } - frame->tf_spsr |= PSR_AARCH32; -} - -int -cloudabi32_thread_setregs(struct thread *td, - const cloudabi32_threadattr_t *attr, uint32_t tcb) -{ - struct trapframe *frame; - - /* - * Pass in the thread ID of the new thread and the argument - * pointer provided by the parent thread in as arguments to the - * entry point. - */ - frame = td->td_frame; - memset(frame, 0, sizeof(*frame)); - frame->tf_x[0] = td->td_tid; - frame->tf_x[1] = attr->argument; - frame->tf_x[13] = STACKALIGN(attr->stack + attr->stack_len); - frame->tf_elr = attr->entry_point; - - /* Set up TLS. */ - return (cpu_set_user_tls(td, TO_PTR(tcb))); -} - -static struct sysentvec cloudabi32_elf_sysvec = { - .sv_size = CLOUDABI32_SYS_MAXSYSCALL, - .sv_table = cloudabi32_sysent, - .sv_fixup = cloudabi32_fixup, - .sv_name = "CloudABI ELF32", - .sv_coredump = elf32_coredump, - .sv_elf_core_osabi = ELFOSABI_FREEBSD, - .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, - .sv_elf_core_prepare_notes = elf32_prepare_notes, - .sv_minuser = VM_MIN_ADDRESS, - .sv_maxuser = (uintmax_t)1 << 32, - .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, - .sv_copyout_strings = cloudabi32_copyout_strings, - .sv_setregs = cloudabi32_proc_setregs, - .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_ILP32, - .sv_set_syscall_retval = cloudabi32_set_syscall_retval, - .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, - .sv_syscallnames = cloudabi32_syscallnames, - .sv_schedtail = cloudabi32_schedtail, -}; - -INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); - -Elf32_Brandinfo cloudabi32_brand = { - .brand = ELFOSABI_CLOUDABI, - .machine = EM_ARM, - .sysvec = &cloudabi32_elf_sysvec, - .flags = BI_BRAND_ONLY_STATIC, -}; diff --git a/sys/arm64/cloudabi64/cloudabi64_sysvec.c b/sys/arm64/cloudabi64/cloudabi64_sysvec.c deleted file mode 100644 --- a/sys/arm64/cloudabi64/cloudabi64_sysvec.c +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -extern const char *cloudabi64_syscallnames[]; -extern struct sysent cloudabi64_sysent[]; - -static void -cloudabi64_proc_setregs(struct thread *td, struct image_params *imgp, - uintptr_t stack) -{ - struct trapframe *regs; - - exec_setregs(td, imgp, stack); - - /* - * The stack now contains a pointer to the TCB and the auxiliary - * vector. Let x0 point to the auxiliary vector, and set - * tpidr_el0 to the TCB. - */ - regs = td->td_frame; - regs->tf_x[0] = - stack + roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t)); - (void)cpu_set_user_tls(td, TO_PTR(stack)); -} - -static int -cloudabi64_fetch_syscall_args(struct thread *td) -{ - struct trapframe *frame; - struct syscall_args *sa; - int i; - - frame = td->td_frame; - sa = &td->td_sa; - - /* Obtain system call number. */ - sa->code = frame->tf_x[8]; - sa->original_code = sa->code; - if (sa->code >= CLOUDABI64_SYS_MAXSYSCALL) - return (ENOSYS); - sa->callp = &cloudabi64_sysent[sa->code]; - - /* Fetch system call arguments. */ - for (i = 0; i < MAXARGS; i++) - sa->args[i] = frame->tf_x[i]; - - /* Default system call return values. */ - td->td_retval[0] = 0; - td->td_retval[1] = frame->tf_x[1]; - return (0); -} - -static void -cloudabi64_set_syscall_retval(struct thread *td, int error) -{ - struct trapframe *frame = td->td_frame; - - switch (error) { - case 0: - /* System call succeeded. */ - frame->tf_x[0] = td->td_retval[0]; - frame->tf_x[1] = td->td_retval[1]; - frame->tf_spsr &= ~PSR_C; - break; - case ERESTART: - /* Restart system call. */ - frame->tf_elr -= 4; - break; - case EJUSTRETURN: - break; - default: - /* System call returned an error. */ - frame->tf_x[0] = cloudabi_convert_errno(error); - frame->tf_spsr |= PSR_C; - break; - } -} - -static void -cloudabi64_schedtail(struct thread *td) -{ - struct trapframe *frame = td->td_frame; - - /* - * Initial register values for processes returning from fork. - * Make sure that we only set these values when forking, not - * when creating a new thread. - */ - if ((td->td_pflags & TDP_FORKING) != 0) { - frame->tf_x[0] = CLOUDABI_PROCESS_CHILD; - frame->tf_x[1] = td->td_tid; - } -} - -int -cloudabi64_thread_setregs(struct thread *td, - const cloudabi64_threadattr_t *attr, uint64_t tcb) -{ - struct trapframe *frame; - stack_t stack; - - /* Perform standard register initialization. */ - stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_len; - cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); - - /* - * Pass in the thread ID of the new thread and the argument - * pointer provided by the parent thread in as arguments to the - * entry point. - */ - frame = td->td_frame; - frame->tf_x[0] = td->td_tid; - frame->tf_x[1] = attr->argument; - - /* Set up TLS. */ - return (cpu_set_user_tls(td, TO_PTR(tcb))); -} - -static struct sysentvec cloudabi64_elf_sysvec = { - .sv_size = CLOUDABI64_SYS_MAXSYSCALL, - .sv_table = cloudabi64_sysent, - .sv_fixup = cloudabi64_fixup, - .sv_name = "CloudABI ELF64", - .sv_coredump = elf64_coredump, - .sv_elf_core_osabi = ELFOSABI_FREEBSD, - .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, - .sv_elf_core_prepare_notes = elf64_prepare_notes, - .sv_minuser = VM_MIN_ADDRESS, - .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, - .sv_copyout_strings = cloudabi64_copyout_strings, - .sv_setregs = cloudabi64_proc_setregs, - .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_LP64, - .sv_set_syscall_retval = cloudabi64_set_syscall_retval, - .sv_fetch_syscall_args = cloudabi64_fetch_syscall_args, - .sv_syscallnames = cloudabi64_syscallnames, - .sv_schedtail = cloudabi64_schedtail, -}; - -INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec); - -Elf64_Brandinfo cloudabi64_brand = { - .brand = ELFOSABI_CLOUDABI, - .machine = EM_AARCH64, - .sysvec = &cloudabi64_elf_sysvec, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_ONLY_STATIC, -}; diff --git a/sys/compat/cloudabi/cloudabi_clock.c b/sys/compat/cloudabi/cloudabi_clock.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_clock.c +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include - -#include -#include - -/* Converts a CloudABI clock ID to a FreeBSD clock ID. */ -static int -cloudabi_convert_clockid(cloudabi_clockid_t in, clockid_t *out) -{ - switch (in) { - case CLOUDABI_CLOCK_MONOTONIC: - *out = CLOCK_MONOTONIC; - return (0); - case CLOUDABI_CLOCK_PROCESS_CPUTIME_ID: - *out = CLOCK_PROCESS_CPUTIME_ID; - return (0); - case CLOUDABI_CLOCK_REALTIME: - *out = CLOCK_REALTIME; - return (0); - case CLOUDABI_CLOCK_THREAD_CPUTIME_ID: - *out = CLOCK_THREAD_CPUTIME_ID; - return (0); - default: - return (EINVAL); - } -} - -/* Converts a struct timespec to a CloudABI timestamp. */ -int -cloudabi_convert_timespec(const struct timespec *in, cloudabi_timestamp_t *out) -{ - cloudabi_timestamp_t s, ns; - - if (in->tv_sec < 0) { - /* Timestamps from before the Epoch cannot be expressed. */ - *out = 0; - return (EOVERFLOW); - } - s = in->tv_sec; - ns = in->tv_nsec; - if (s > UINT64_MAX / 1000000000 || - (s == UINT64_MAX / 1000000000 && ns > UINT64_MAX % 1000000000)) { - /* Addition of seconds and nanoseconds would overflow. */ - *out = UINT64_MAX; - return (EOVERFLOW); - } - *out = s * 1000000000 + ns; - return (0); -} - -/* Fetches the time value of a clock. */ -int -cloudabi_clock_time_get(struct thread *td, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t *ret) -{ - struct timespec ts; - int error; - clockid_t clockid; - - error = cloudabi_convert_clockid(clock_id, &clockid); - if (error != 0) - return (error); - error = kern_clock_gettime(td, clockid, &ts); - if (error != 0) - return (error); - return (cloudabi_convert_timespec(&ts, ret)); -} - -int -cloudabi_sys_clock_res_get(struct thread *td, - struct cloudabi_sys_clock_res_get_args *uap) -{ - struct timespec ts; - cloudabi_timestamp_t cts; - int error; - clockid_t clockid; - - error = cloudabi_convert_clockid(uap->clock_id, &clockid); - if (error != 0) - return (error); - error = kern_clock_getres(td, clockid, &ts); - if (error != 0) - return (error); - error = cloudabi_convert_timespec(&ts, &cts); - if (error != 0) - return (error); - memcpy(td->td_retval, &cts, sizeof(cts)); - return (0); -} - -int -cloudabi_sys_clock_time_get(struct thread *td, - struct cloudabi_sys_clock_time_get_args *uap) -{ - cloudabi_timestamp_t ts; - int error; - - error = cloudabi_clock_time_get(td, uap->clock_id, &ts); - memcpy(td->td_retval, &ts, sizeof(ts)); - return (error); -} diff --git a/sys/compat/cloudabi/cloudabi_errno.c b/sys/compat/cloudabi/cloudabi_errno.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_errno.c +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include - -#include - -#include - -/* Converts a FreeBSD errno to a CloudABI errno. */ -cloudabi_errno_t -cloudabi_convert_errno(int error) -{ - static const int table[] = { - [E2BIG] = CLOUDABI_E2BIG, - [EACCES] = CLOUDABI_EACCES, - [EADDRINUSE] = CLOUDABI_EADDRINUSE, - [EADDRNOTAVAIL] = CLOUDABI_EADDRNOTAVAIL, - [EAFNOSUPPORT] = CLOUDABI_EAFNOSUPPORT, - [EAGAIN] = CLOUDABI_EAGAIN, - [EALREADY] = CLOUDABI_EALREADY, - [EBADF] = CLOUDABI_EBADF, - [EBADMSG] = CLOUDABI_EBADMSG, - [EBUSY] = CLOUDABI_EBUSY, - [ECANCELED] = CLOUDABI_ECANCELED, - [ECHILD] = CLOUDABI_ECHILD, - [ECONNABORTED] = CLOUDABI_ECONNABORTED, - [ECONNREFUSED] = CLOUDABI_ECONNREFUSED, - [ECONNRESET] = CLOUDABI_ECONNRESET, - [EDEADLK] = CLOUDABI_EDEADLK, - [EDESTADDRREQ] = CLOUDABI_EDESTADDRREQ, - [EDOM] = CLOUDABI_EDOM, - [EDQUOT] = CLOUDABI_EDQUOT, - [EEXIST] = CLOUDABI_EEXIST, - [EFAULT] = CLOUDABI_EFAULT, - [EFBIG] = CLOUDABI_EFBIG, - [EHOSTUNREACH] = CLOUDABI_EHOSTUNREACH, - [EIDRM] = CLOUDABI_EIDRM, - [EILSEQ] = CLOUDABI_EILSEQ, - [EINPROGRESS] = CLOUDABI_EINPROGRESS, - [EINTEGRITY] = CLOUDABI_EINVAL, - [EINTR] = CLOUDABI_EINTR, - [EINVAL] = CLOUDABI_EINVAL, - [EIO] = CLOUDABI_EIO, - [EISCONN] = CLOUDABI_EISCONN, - [EISDIR] = CLOUDABI_EISDIR, - [ELOOP] = CLOUDABI_ELOOP, - [EMFILE] = CLOUDABI_EMFILE, - [EMLINK] = CLOUDABI_EMLINK, - [EMSGSIZE] = CLOUDABI_EMSGSIZE, - [EMULTIHOP] = CLOUDABI_EMULTIHOP, - [ENAMETOOLONG] = CLOUDABI_ENAMETOOLONG, - [ENETDOWN] = CLOUDABI_ENETDOWN, - [ENETRESET] = CLOUDABI_ENETRESET, - [ENETUNREACH] = CLOUDABI_ENETUNREACH, - [ENFILE] = CLOUDABI_ENFILE, - [ENOBUFS] = CLOUDABI_ENOBUFS, - [ENODEV] = CLOUDABI_ENODEV, - [ENOENT] = CLOUDABI_ENOENT, - [ENOEXEC] = CLOUDABI_ENOEXEC, - [ENOLCK] = CLOUDABI_ENOLCK, - [ENOLINK] = CLOUDABI_ENOLINK, - [ENOMEM] = CLOUDABI_ENOMEM, - [ENOMSG] = CLOUDABI_ENOMSG, - [ENOPROTOOPT] = CLOUDABI_ENOPROTOOPT, - [ENOSPC] = CLOUDABI_ENOSPC, - [ENOSYS] = CLOUDABI_ENOSYS, - [ENOTCONN] = CLOUDABI_ENOTCONN, - [ENOTDIR] = CLOUDABI_ENOTDIR, - [ENOTEMPTY] = CLOUDABI_ENOTEMPTY, - [ENOTRECOVERABLE] = CLOUDABI_ENOTRECOVERABLE, - [ENOTSOCK] = CLOUDABI_ENOTSOCK, - [ENOTSUP] = CLOUDABI_ENOTSUP, - [ENOTTY] = CLOUDABI_ENOTTY, - [ENXIO] = CLOUDABI_ENXIO, - [EOVERFLOW] = CLOUDABI_EOVERFLOW, - [EOWNERDEAD] = CLOUDABI_EOWNERDEAD, - [EPERM] = CLOUDABI_EPERM, - [EPIPE] = CLOUDABI_EPIPE, - [EPROTO] = CLOUDABI_EPROTO, - [EPROTONOSUPPORT] = CLOUDABI_EPROTONOSUPPORT, - [EPROTOTYPE] = CLOUDABI_EPROTOTYPE, - [ERANGE] = CLOUDABI_ERANGE, - [EROFS] = CLOUDABI_EROFS, - [ESPIPE] = CLOUDABI_ESPIPE, - [ESRCH] = CLOUDABI_ESRCH, - [ESTALE] = CLOUDABI_ESTALE, - [ETIMEDOUT] = CLOUDABI_ETIMEDOUT, - [ETXTBSY] = CLOUDABI_ETXTBSY, - [EXDEV] = CLOUDABI_EXDEV, - [ENOTCAPABLE] = CLOUDABI_ENOTCAPABLE, - }; - - /* Unknown error: fall back to returning ENOSYS. */ - if (error < 0 || error >= nitems(table) || table[error] == 0) - return (error == 0 ? 0 : CLOUDABI_ENOSYS); - return (table[error]); -} diff --git a/sys/compat/cloudabi/cloudabi_fd.c b/sys/compat/cloudabi/cloudabi_fd.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_fd.c +++ /dev/null @@ -1,475 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -/* Translation between CloudABI and Capsicum rights. */ -#define RIGHTS_MAPPINGS \ - MAPPING(CLOUDABI_RIGHT_FD_DATASYNC, CAP_FSYNC) \ - MAPPING(CLOUDABI_RIGHT_FD_READ, CAP_READ) \ - MAPPING(CLOUDABI_RIGHT_FD_SEEK, CAP_SEEK) \ - MAPPING(CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS, CAP_FCNTL) \ - MAPPING(CLOUDABI_RIGHT_FD_SYNC, CAP_FSYNC) \ - MAPPING(CLOUDABI_RIGHT_FD_TELL, CAP_SEEK_TELL) \ - MAPPING(CLOUDABI_RIGHT_FD_WRITE, CAP_WRITE) \ - MAPPING(CLOUDABI_RIGHT_FILE_ADVISE) \ - MAPPING(CLOUDABI_RIGHT_FILE_ALLOCATE, CAP_WRITE) \ - MAPPING(CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY, CAP_MKDIRAT) \ - MAPPING(CLOUDABI_RIGHT_FILE_CREATE_FILE, CAP_CREATE) \ - MAPPING(CLOUDABI_RIGHT_FILE_LINK_SOURCE, CAP_LINKAT_SOURCE) \ - MAPPING(CLOUDABI_RIGHT_FILE_LINK_TARGET, CAP_LINKAT_TARGET) \ - MAPPING(CLOUDABI_RIGHT_FILE_OPEN, CAP_LOOKUP) \ - MAPPING(CLOUDABI_RIGHT_FILE_READDIR, CAP_READ) \ - MAPPING(CLOUDABI_RIGHT_FILE_READLINK, CAP_LOOKUP) \ - MAPPING(CLOUDABI_RIGHT_FILE_RENAME_SOURCE, CAP_RENAMEAT_SOURCE) \ - MAPPING(CLOUDABI_RIGHT_FILE_RENAME_TARGET, CAP_RENAMEAT_TARGET) \ - MAPPING(CLOUDABI_RIGHT_FILE_STAT_FGET, CAP_FSTAT) \ - MAPPING(CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE, CAP_FTRUNCATE) \ - MAPPING(CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES, CAP_FUTIMES) \ - MAPPING(CLOUDABI_RIGHT_FILE_STAT_GET, CAP_FSTATAT) \ - MAPPING(CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES, CAP_FUTIMESAT) \ - MAPPING(CLOUDABI_RIGHT_FILE_SYMLINK, CAP_SYMLINKAT) \ - MAPPING(CLOUDABI_RIGHT_FILE_UNLINK, CAP_UNLINKAT) \ - MAPPING(CLOUDABI_RIGHT_MEM_MAP, CAP_MMAP) \ - MAPPING(CLOUDABI_RIGHT_MEM_MAP_EXEC, CAP_MMAP_X) \ - MAPPING(CLOUDABI_RIGHT_POLL_FD_READWRITE, CAP_EVENT) \ - MAPPING(CLOUDABI_RIGHT_POLL_PROC_TERMINATE, CAP_EVENT) \ - MAPPING(CLOUDABI_RIGHT_PROC_EXEC, CAP_FEXECVE) \ - MAPPING(CLOUDABI_RIGHT_SOCK_SHUTDOWN, CAP_SHUTDOWN) \ - -int -cloudabi_sys_fd_close(struct thread *td, struct cloudabi_sys_fd_close_args *uap) -{ - - return (kern_close(td, uap->fd)); -} - -int -cloudabi_sys_fd_create1(struct thread *td, - struct cloudabi_sys_fd_create1_args *uap) -{ - struct filecaps fcaps = {}; - - switch (uap->type) { - case CLOUDABI_FILETYPE_SHARED_MEMORY: - cap_rights_init(&fcaps.fc_rights, CAP_FSTAT, CAP_FTRUNCATE, - CAP_MMAP_RWX); - return (kern_shm_open(td, SHM_ANON, O_RDWR | O_CLOEXEC, 0, - &fcaps)); - default: - return (EINVAL); - } -} - -int -cloudabi_sys_fd_create2(struct thread *td, - struct cloudabi_sys_fd_create2_args *uap) -{ - int fds[2]; - int error, type; - - switch (uap->type) { - case CLOUDABI_FILETYPE_SOCKET_DGRAM: - type = SOCK_DGRAM; - break; - case CLOUDABI_FILETYPE_SOCKET_STREAM: - type = SOCK_STREAM; - break; - default: - return (EINVAL); - } - - error = kern_socketpair(td, AF_UNIX, type, 0, fds); - if (error == 0) { - td->td_retval[0] = fds[0]; - td->td_retval[1] = fds[1]; - } - return (0); -} - -int -cloudabi_sys_fd_datasync(struct thread *td, - struct cloudabi_sys_fd_datasync_args *uap) -{ - - return (kern_fsync(td, uap->fd, false)); -} - -int -cloudabi_sys_fd_dup(struct thread *td, struct cloudabi_sys_fd_dup_args *uap) -{ - - return (kern_dup(td, FDDUP_NORMAL, 0, uap->from, 0)); -} - -int -cloudabi_sys_fd_replace(struct thread *td, - struct cloudabi_sys_fd_replace_args *uap) -{ - int error; - - /* - * CloudABI's equivalent to dup2(). CloudABI processes should - * not depend on hardcoded file descriptor layouts, but simply - * use the file descriptor numbers that are allocated by the - * kernel. Duplicating file descriptors to arbitrary numbers - * should not be done. - * - * Invoke kern_dup() with FDDUP_MUSTREPLACE, so that we return - * EBADF when duplicating to a nonexistent file descriptor. Also - * clear the return value, as this system call yields no return - * value. - */ - error = kern_dup(td, FDDUP_MUSTREPLACE, 0, uap->from, uap->to); - td->td_retval[0] = 0; - return (error); -} - -int -cloudabi_sys_fd_seek(struct thread *td, struct cloudabi_sys_fd_seek_args *uap) -{ - int whence; - - switch (uap->whence) { - case CLOUDABI_WHENCE_CUR: - whence = SEEK_CUR; - break; - case CLOUDABI_WHENCE_END: - whence = SEEK_END; - break; - case CLOUDABI_WHENCE_SET: - whence = SEEK_SET; - break; - default: - return (EINVAL); - } - - return (kern_lseek(td, uap->fd, uap->offset, whence)); -} - -/* Converts a file descriptor to a CloudABI file descriptor type. */ -cloudabi_filetype_t -cloudabi_convert_filetype(const struct file *fp) -{ - struct socket *so; - struct vnode *vp; - - switch (fp->f_type) { - case DTYPE_FIFO: - return (CLOUDABI_FILETYPE_SOCKET_STREAM); - case DTYPE_PIPE: - return (CLOUDABI_FILETYPE_SOCKET_STREAM); - case DTYPE_PROCDESC: - return (CLOUDABI_FILETYPE_PROCESS); - case DTYPE_SHM: - return (CLOUDABI_FILETYPE_SHARED_MEMORY); - case DTYPE_SOCKET: - so = fp->f_data; - switch (so->so_type) { - case SOCK_DGRAM: - return (CLOUDABI_FILETYPE_SOCKET_DGRAM); - case SOCK_STREAM: - return (CLOUDABI_FILETYPE_SOCKET_STREAM); - default: - return (CLOUDABI_FILETYPE_UNKNOWN); - } - case DTYPE_VNODE: - vp = fp->f_vnode; - switch (vp->v_type) { - case VBLK: - return (CLOUDABI_FILETYPE_BLOCK_DEVICE); - case VCHR: - return (CLOUDABI_FILETYPE_CHARACTER_DEVICE); - case VDIR: - return (CLOUDABI_FILETYPE_DIRECTORY); - case VFIFO: - return (CLOUDABI_FILETYPE_SOCKET_STREAM); - case VLNK: - return (CLOUDABI_FILETYPE_SYMBOLIC_LINK); - case VREG: - return (CLOUDABI_FILETYPE_REGULAR_FILE); - case VSOCK: - return (CLOUDABI_FILETYPE_SOCKET_STREAM); - default: - return (CLOUDABI_FILETYPE_UNKNOWN); - } - default: - return (CLOUDABI_FILETYPE_UNKNOWN); - } -} - -/* Removes rights that conflict with the file descriptor type. */ -void -cloudabi_remove_conflicting_rights(cloudabi_filetype_t filetype, - cloudabi_rights_t *base, cloudabi_rights_t *inheriting) -{ - - /* - * CloudABI has a small number of additional rights bits to - * disambiguate between multiple purposes. Remove the bits that - * don't apply to the type of the file descriptor. - * - * As file descriptor access modes (O_ACCMODE) has been fully - * replaced by rights bits, CloudABI distinguishes between - * rights that apply to the file descriptor itself (base) versus - * rights of new file descriptors derived from them - * (inheriting). The code below approximates the pair by - * decomposing depending on the file descriptor type. - * - * We need to be somewhat accurate about which actions can - * actually be performed on the file descriptor, as functions - * like fcntl(fd, F_GETFL) are emulated on top of this. - */ - switch (filetype) { - case CLOUDABI_FILETYPE_DIRECTORY: - *base &= CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS | - CLOUDABI_RIGHT_FD_SYNC | CLOUDABI_RIGHT_FILE_ADVISE | - CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY | - CLOUDABI_RIGHT_FILE_CREATE_FILE | - CLOUDABI_RIGHT_FILE_LINK_SOURCE | - CLOUDABI_RIGHT_FILE_LINK_TARGET | - CLOUDABI_RIGHT_FILE_OPEN | - CLOUDABI_RIGHT_FILE_READDIR | - CLOUDABI_RIGHT_FILE_READLINK | - CLOUDABI_RIGHT_FILE_RENAME_SOURCE | - CLOUDABI_RIGHT_FILE_RENAME_TARGET | - CLOUDABI_RIGHT_FILE_STAT_FGET | - CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES | - CLOUDABI_RIGHT_FILE_STAT_GET | - CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES | - CLOUDABI_RIGHT_FILE_SYMLINK | - CLOUDABI_RIGHT_FILE_UNLINK | - CLOUDABI_RIGHT_POLL_FD_READWRITE; - *inheriting &= CLOUDABI_RIGHT_FD_DATASYNC | - CLOUDABI_RIGHT_FD_READ | - CLOUDABI_RIGHT_FD_SEEK | - CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS | - CLOUDABI_RIGHT_FD_SYNC | - CLOUDABI_RIGHT_FD_TELL | - CLOUDABI_RIGHT_FD_WRITE | - CLOUDABI_RIGHT_FILE_ADVISE | - CLOUDABI_RIGHT_FILE_ALLOCATE | - CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY | - CLOUDABI_RIGHT_FILE_CREATE_FILE | - CLOUDABI_RIGHT_FILE_LINK_SOURCE | - CLOUDABI_RIGHT_FILE_LINK_TARGET | - CLOUDABI_RIGHT_FILE_OPEN | - CLOUDABI_RIGHT_FILE_READDIR | - CLOUDABI_RIGHT_FILE_READLINK | - CLOUDABI_RIGHT_FILE_RENAME_SOURCE | - CLOUDABI_RIGHT_FILE_RENAME_TARGET | - CLOUDABI_RIGHT_FILE_STAT_FGET | - CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE | - CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES | - CLOUDABI_RIGHT_FILE_STAT_GET | - CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES | - CLOUDABI_RIGHT_FILE_SYMLINK | - CLOUDABI_RIGHT_FILE_UNLINK | - CLOUDABI_RIGHT_MEM_MAP | - CLOUDABI_RIGHT_MEM_MAP_EXEC | - CLOUDABI_RIGHT_POLL_FD_READWRITE | - CLOUDABI_RIGHT_PROC_EXEC; - break; - case CLOUDABI_FILETYPE_PROCESS: - *base &= ~(CLOUDABI_RIGHT_FILE_ADVISE | - CLOUDABI_RIGHT_POLL_FD_READWRITE); - *inheriting = 0; - break; - case CLOUDABI_FILETYPE_REGULAR_FILE: - *base &= CLOUDABI_RIGHT_FD_DATASYNC | - CLOUDABI_RIGHT_FD_READ | - CLOUDABI_RIGHT_FD_SEEK | - CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS | - CLOUDABI_RIGHT_FD_SYNC | - CLOUDABI_RIGHT_FD_TELL | - CLOUDABI_RIGHT_FD_WRITE | - CLOUDABI_RIGHT_FILE_ADVISE | - CLOUDABI_RIGHT_FILE_ALLOCATE | - CLOUDABI_RIGHT_FILE_STAT_FGET | - CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE | - CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES | - CLOUDABI_RIGHT_MEM_MAP | - CLOUDABI_RIGHT_MEM_MAP_EXEC | - CLOUDABI_RIGHT_POLL_FD_READWRITE | - CLOUDABI_RIGHT_PROC_EXEC; - *inheriting = 0; - break; - case CLOUDABI_FILETYPE_SHARED_MEMORY: - *base &= ~(CLOUDABI_RIGHT_FD_SEEK | - CLOUDABI_RIGHT_FD_TELL | - CLOUDABI_RIGHT_FILE_ADVISE | - CLOUDABI_RIGHT_FILE_ALLOCATE | - CLOUDABI_RIGHT_FILE_READDIR); - *inheriting = 0; - break; - case CLOUDABI_FILETYPE_SOCKET_DGRAM: - case CLOUDABI_FILETYPE_SOCKET_STREAM: - *base &= CLOUDABI_RIGHT_FD_READ | - CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS | - CLOUDABI_RIGHT_FD_WRITE | - CLOUDABI_RIGHT_FILE_STAT_FGET | - CLOUDABI_RIGHT_POLL_FD_READWRITE | - CLOUDABI_RIGHT_SOCK_SHUTDOWN; - break; - default: - *inheriting = 0; - break; - } -} - -/* Converts FreeBSD's Capsicum rights to CloudABI's set of rights. */ -static void -convert_capabilities(const cap_rights_t *capabilities, - cloudabi_filetype_t filetype, cloudabi_rights_t *base, - cloudabi_rights_t *inheriting) -{ - cloudabi_rights_t rights; - - /* Convert FreeBSD bits to CloudABI bits. */ - rights = 0; -#define MAPPING(cloudabi, ...) do { \ - if (cap_rights_is_set(capabilities, ##__VA_ARGS__)) \ - rights |= (cloudabi); \ -} while (0); - RIGHTS_MAPPINGS -#undef MAPPING - - *base = rights; - *inheriting = rights; - cloudabi_remove_conflicting_rights(filetype, base, inheriting); -} - -int -cloudabi_sys_fd_stat_get(struct thread *td, - struct cloudabi_sys_fd_stat_get_args *uap) -{ - cloudabi_fdstat_t fsb = {0}; - struct file *fp; - cap_rights_t rights; - struct filecaps fcaps; - int error, oflags; - - /* Obtain file descriptor properties. */ - error = fget_cap(td, uap->fd, cap_rights_init(&rights), &fp, - &fcaps); - if (error != 0) - return (error); - oflags = OFLAGS(fp->f_flag); - fsb.fs_filetype = cloudabi_convert_filetype(fp); - fdrop(fp, td); - - /* Convert file descriptor flags. */ - if (oflags & O_APPEND) - fsb.fs_flags |= CLOUDABI_FDFLAG_APPEND; - if (oflags & O_NONBLOCK) - fsb.fs_flags |= CLOUDABI_FDFLAG_NONBLOCK; - if (oflags & O_SYNC) - fsb.fs_flags |= CLOUDABI_FDFLAG_SYNC; - - /* Convert capabilities to CloudABI rights. */ - convert_capabilities(&fcaps.fc_rights, fsb.fs_filetype, - &fsb.fs_rights_base, &fsb.fs_rights_inheriting); - filecaps_free(&fcaps); - return (copyout(&fsb, (void *)uap->buf, sizeof(fsb))); -} - -/* Converts CloudABI rights to a set of Capsicum capabilities. */ -int -cloudabi_convert_rights(cloudabi_rights_t in, cap_rights_t *out) -{ - - cap_rights_init(out); -#define MAPPING(cloudabi, ...) do { \ - if (in & (cloudabi)) { \ - cap_rights_set(out, ##__VA_ARGS__); \ - in &= ~(cloudabi); \ - } \ -} while (0); - RIGHTS_MAPPINGS -#undef MAPPING - if (in != 0) - return (ENOTCAPABLE); - return (0); -} - -int -cloudabi_sys_fd_stat_put(struct thread *td, - struct cloudabi_sys_fd_stat_put_args *uap) -{ - cloudabi_fdstat_t fsb; - cap_rights_t rights; - int error, oflags; - - error = copyin(uap->buf, &fsb, sizeof(fsb)); - if (error != 0) - return (error); - - if (uap->flags == CLOUDABI_FDSTAT_FLAGS) { - /* Convert flags. */ - oflags = 0; - if (fsb.fs_flags & CLOUDABI_FDFLAG_APPEND) - oflags |= O_APPEND; - if (fsb.fs_flags & CLOUDABI_FDFLAG_NONBLOCK) - oflags |= O_NONBLOCK; - if (fsb.fs_flags & (CLOUDABI_FDFLAG_SYNC | - CLOUDABI_FDFLAG_DSYNC | CLOUDABI_FDFLAG_RSYNC)) - oflags |= O_SYNC; - return (kern_fcntl(td, uap->fd, F_SETFL, oflags)); - } else if (uap->flags == CLOUDABI_FDSTAT_RIGHTS) { - /* Convert rights. */ - error = cloudabi_convert_rights( - fsb.fs_rights_base | fsb.fs_rights_inheriting, &rights); - if (error != 0) - return (error); - return (kern_cap_rights_limit(td, uap->fd, &rights)); - } - return (EINVAL); -} - -int -cloudabi_sys_fd_sync(struct thread *td, struct cloudabi_sys_fd_sync_args *uap) -{ - - return (kern_fsync(td, uap->fd, true)); -} diff --git a/sys/compat/cloudabi/cloudabi_file.c b/sys/compat/cloudabi/cloudabi_file.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_file.c +++ /dev/null @@ -1,763 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -static MALLOC_DEFINE(M_CLOUDABI_PATH, "cloudabipath", "CloudABI pathnames"); - -/* - * Copying pathnames from userspace to kernelspace. - * - * Unlike most operating systems, CloudABI doesn't use null-terminated - * pathname strings. Processes always pass pathnames to the kernel by - * providing a base pointer and a length. This has a couple of reasons: - * - * - It makes it easier to use CloudABI in combination with programming - * languages other than C, that may use non-null terminated strings. - * - It allows for calling system calls on individual components of the - * pathname without modifying the input string. - * - * The function below copies in pathname strings and null-terminates it. - * It also ensure that the string itself does not contain any null - * bytes. - * - * TODO(ed): Add an abstraction to vfs_lookup.c that allows us to pass - * in unterminated pathname strings, so we can do away with - * the copying. - */ - -static int -copyin_path(const char *uaddr, size_t len, char **result) -{ - char *buf; - int error; - - if (len >= PATH_MAX) - return (ENAMETOOLONG); - buf = malloc(len + 1, M_CLOUDABI_PATH, M_WAITOK); - error = copyin(uaddr, buf, len); - if (error != 0) { - free(buf, M_CLOUDABI_PATH); - return (error); - } - if (memchr(buf, '\0', len) != NULL) { - free(buf, M_CLOUDABI_PATH); - return (EINVAL); - } - buf[len] = '\0'; - *result = buf; - return (0); -} - -static void -cloudabi_freestr(char *buf) -{ - - free(buf, M_CLOUDABI_PATH); -} - -int -cloudabi_sys_file_advise(struct thread *td, - struct cloudabi_sys_file_advise_args *uap) -{ - int advice; - - switch (uap->advice) { - case CLOUDABI_ADVICE_DONTNEED: - advice = POSIX_FADV_DONTNEED; - break; - case CLOUDABI_ADVICE_NOREUSE: - advice = POSIX_FADV_NOREUSE; - break; - case CLOUDABI_ADVICE_NORMAL: - advice = POSIX_FADV_NORMAL; - break; - case CLOUDABI_ADVICE_RANDOM: - advice = POSIX_FADV_RANDOM; - break; - case CLOUDABI_ADVICE_SEQUENTIAL: - advice = POSIX_FADV_SEQUENTIAL; - break; - case CLOUDABI_ADVICE_WILLNEED: - advice = POSIX_FADV_WILLNEED; - break; - default: - return (EINVAL); - } - - return (kern_posix_fadvise(td, uap->fd, uap->offset, uap->len, advice)); -} - -int -cloudabi_sys_file_allocate(struct thread *td, - struct cloudabi_sys_file_allocate_args *uap) -{ - - return (kern_posix_fallocate(td, uap->fd, uap->offset, uap->len)); -} - -int -cloudabi_sys_file_create(struct thread *td, - struct cloudabi_sys_file_create_args *uap) -{ - char *path; - int error; - - error = copyin_path(uap->path, uap->path_len, &path); - if (error != 0) - return (error); - - /* - * CloudABI processes cannot interact with UNIX credentials and - * permissions. Depend on the umask that is set prior to - * execution to restrict the file permissions. - */ - switch (uap->type) { - case CLOUDABI_FILETYPE_DIRECTORY: - error = kern_mkdirat(td, uap->fd, path, UIO_SYSSPACE, 0777); - break; - default: - error = EINVAL; - break; - } - cloudabi_freestr(path); - return (error); -} - -int -cloudabi_sys_file_link(struct thread *td, - struct cloudabi_sys_file_link_args *uap) -{ - char *path1, *path2; - int error; - - error = copyin_path(uap->path1, uap->path1_len, &path1); - if (error != 0) - return (error); - error = copyin_path(uap->path2, uap->path2_len, &path2); - if (error != 0) { - cloudabi_freestr(path1); - return (error); - } - - error = kern_linkat(td, uap->fd1.fd, uap->fd2, path1, path2, - UIO_SYSSPACE, (uap->fd1.flags & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) ? - AT_SYMLINK_FOLLOW : 0); - cloudabi_freestr(path1); - cloudabi_freestr(path2); - return (error); -} - -int -cloudabi_sys_file_open(struct thread *td, - struct cloudabi_sys_file_open_args *uap) -{ - cloudabi_fdstat_t fds; - cap_rights_t rights; - struct filecaps fcaps = {}; - struct nameidata nd; - struct file *fp; - struct vnode *vp; - char *path; - int error, fd, fflags; - bool read, write; - - error = copyin(uap->fds, &fds, sizeof(fds)); - if (error != 0) - return (error); - - /* All the requested rights should be set on the descriptor. */ - error = cloudabi_convert_rights( - fds.fs_rights_base | fds.fs_rights_inheriting, &rights); - if (error != 0) - return (error); - cap_rights_set_one(&rights, CAP_LOOKUP); - - /* Convert rights to corresponding access mode. */ - read = (fds.fs_rights_base & (CLOUDABI_RIGHT_FD_READ | - CLOUDABI_RIGHT_FILE_READDIR | CLOUDABI_RIGHT_MEM_MAP_EXEC)) != 0; - write = (fds.fs_rights_base & (CLOUDABI_RIGHT_FD_DATASYNC | - CLOUDABI_RIGHT_FD_WRITE | CLOUDABI_RIGHT_FILE_ALLOCATE | - CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE)) != 0; - fflags = write ? read ? FREAD | FWRITE : FWRITE : FREAD; - - /* Convert open flags. */ - if ((uap->oflags & CLOUDABI_O_CREAT) != 0) { - fflags |= O_CREAT; - cap_rights_set_one(&rights, CAP_CREATE); - } - if ((uap->oflags & CLOUDABI_O_DIRECTORY) != 0) - fflags |= O_DIRECTORY; - if ((uap->oflags & CLOUDABI_O_EXCL) != 0) - fflags |= O_EXCL; - if ((uap->oflags & CLOUDABI_O_TRUNC) != 0) { - fflags |= O_TRUNC; - cap_rights_set_one(&rights, CAP_FTRUNCATE); - } - if ((fds.fs_flags & CLOUDABI_FDFLAG_APPEND) != 0) - fflags |= O_APPEND; - if ((fds.fs_flags & CLOUDABI_FDFLAG_NONBLOCK) != 0) - fflags |= O_NONBLOCK; - if ((fds.fs_flags & (CLOUDABI_FDFLAG_SYNC | CLOUDABI_FDFLAG_DSYNC | - CLOUDABI_FDFLAG_RSYNC)) != 0) { - fflags |= O_SYNC; - cap_rights_set_one(&rights, CAP_FSYNC); - } - if ((uap->dirfd.flags & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) == 0) - fflags |= O_NOFOLLOW; - if (write && (fflags & (O_APPEND | O_TRUNC)) == 0) - cap_rights_set_one(&rights, CAP_SEEK); - - /* Allocate new file descriptor. */ - error = falloc_noinstall(td, &fp); - if (error != 0) - return (error); - fp->f_flag = fflags & FMASK; - - /* Open path. */ - error = copyin_path(uap->path, uap->path_len, &path); - if (error != 0) { - fdrop(fp, td); - return (error); - } - NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, uap->dirfd.fd, - &rights, td); - error = vn_open(&nd, &fflags, 0777 & ~td->td_proc->p_pd->pd_cmask, fp); - cloudabi_freestr(path); - if (error != 0) { - /* Custom operations provided. */ - if (error == ENXIO && fp->f_ops != &badfileops) - goto success; - - /* - * POSIX compliance: return ELOOP in case openat() is - * called on a symbolic link and O_NOFOLLOW is set. - */ - if (error == EMLINK) - error = ELOOP; - fdrop(fp, td); - return (error); - } - NDFREE(&nd, NDF_ONLY_PNBUF); - filecaps_free(&nd.ni_filecaps); - fp->f_vnode = vp = nd.ni_vp; - - /* Install vnode operations if no custom operations are provided. */ - if (fp->f_ops == &badfileops) { - fp->f_seqcount[UIO_READ] = 1; - fp->f_seqcount[UIO_WRITE] = 1; - finit(fp, (fflags & FMASK) | (fp->f_flag & FHASLOCK), - DTYPE_VNODE, vp, &vnops); - } - VOP_UNLOCK(vp); - - /* Truncate file. */ - if (fflags & O_TRUNC) { - error = fo_truncate(fp, 0, td->td_ucred, td); - if (error != 0) { - fdrop(fp, td); - return (error); - } - } - -success: - /* Determine which Capsicum rights to set on the file descriptor. */ - cloudabi_remove_conflicting_rights(cloudabi_convert_filetype(fp), - &fds.fs_rights_base, &fds.fs_rights_inheriting); - cloudabi_convert_rights(fds.fs_rights_base | fds.fs_rights_inheriting, - &fcaps.fc_rights); - if (cap_rights_is_set(&fcaps.fc_rights)) - fcaps.fc_fcntls = CAP_FCNTL_SETFL; - - error = finstall(td, fp, &fd, fflags, &fcaps); - fdrop(fp, td); - if (error != 0) - return (error); - td->td_retval[0] = fd; - return (0); -} - -/* Converts a FreeBSD directory entry structure and writes it to userspace. */ -static int -write_dirent(struct dirent *bde, cloudabi_dircookie_t cookie, struct uio *uio) -{ - cloudabi_dirent_t cde = { - .d_next = cookie, - .d_ino = bde->d_fileno, - .d_namlen = bde->d_namlen, - }; - size_t len; - int error; - - /* Convert file type. */ - switch (bde->d_type) { - case DT_BLK: - cde.d_type = CLOUDABI_FILETYPE_BLOCK_DEVICE; - break; - case DT_CHR: - cde.d_type = CLOUDABI_FILETYPE_CHARACTER_DEVICE; - break; - case DT_DIR: - cde.d_type = CLOUDABI_FILETYPE_DIRECTORY; - break; - case DT_FIFO: - cde.d_type = CLOUDABI_FILETYPE_SOCKET_STREAM; - break; - case DT_LNK: - cde.d_type = CLOUDABI_FILETYPE_SYMBOLIC_LINK; - break; - case DT_REG: - cde.d_type = CLOUDABI_FILETYPE_REGULAR_FILE; - break; - case DT_SOCK: - /* The exact socket type cannot be derived. */ - cde.d_type = CLOUDABI_FILETYPE_SOCKET_STREAM; - break; - default: - cde.d_type = CLOUDABI_FILETYPE_UNKNOWN; - break; - } - - /* Write directory entry structure. */ - len = sizeof(cde) < uio->uio_resid ? sizeof(cde) : uio->uio_resid; - error = uiomove(&cde, len, uio); - if (error != 0) - return (error); - - /* Write filename. */ - len = bde->d_namlen < uio->uio_resid ? bde->d_namlen : uio->uio_resid; - return (uiomove(bde->d_name, len, uio)); -} - -int -cloudabi_sys_file_readdir(struct thread *td, - struct cloudabi_sys_file_readdir_args *uap) -{ - struct iovec iov = { - .iov_base = uap->buf, - .iov_len = uap->buf_len - }; - struct uio uio = { - .uio_iov = &iov, - .uio_iovcnt = 1, - .uio_resid = iov.iov_len, - .uio_segflg = UIO_USERSPACE, - .uio_rw = UIO_READ, - .uio_td = td - }; - struct file *fp; - struct vnode *vp; - void *readbuf; - cloudabi_dircookie_t offset; - int error; - - /* Obtain directory vnode. */ - error = getvnode(td, uap->fd, &cap_read_rights, &fp); - if (error != 0) { - if (error == EINVAL) - return (ENOTDIR); - return (error); - } - if ((fp->f_flag & FREAD) == 0) { - fdrop(fp, td); - return (EBADF); - } - - /* - * Call VOP_READDIR() and convert resulting data until the user - * provided buffer is filled. - */ - readbuf = malloc(MAXBSIZE, M_TEMP, M_WAITOK); - offset = uap->cookie; - vp = fp->f_vnode; - while (uio.uio_resid > 0) { - struct iovec readiov = { - .iov_base = readbuf, - .iov_len = MAXBSIZE - }; - struct uio readuio = { - .uio_iov = &readiov, - .uio_iovcnt = 1, - .uio_rw = UIO_READ, - .uio_segflg = UIO_SYSSPACE, - .uio_td = td, - .uio_resid = MAXBSIZE, - .uio_offset = offset - }; - struct dirent *bde; - unsigned long *cookies, *cookie; - size_t readbuflen; - int eof, ncookies; - - /* Validate file type. */ - vn_lock(vp, LK_SHARED | LK_RETRY); - if (vp->v_type != VDIR) { - VOP_UNLOCK(vp); - error = ENOTDIR; - goto done; - } -#ifdef MAC - error = mac_vnode_check_readdir(td->td_ucred, vp); - if (error != 0) { - VOP_UNLOCK(vp); - goto done; - } -#endif /* MAC */ - - /* Read new directory entries. */ - cookies = NULL; - ncookies = 0; - error = VOP_READDIR(vp, &readuio, fp->f_cred, &eof, - &ncookies, &cookies); - VOP_UNLOCK(vp); - if (error != 0) - goto done; - - /* Convert entries to CloudABI's format. */ - readbuflen = MAXBSIZE - readuio.uio_resid; - bde = readbuf; - cookie = cookies; - while (readbuflen >= offsetof(struct dirent, d_name) && - uio.uio_resid > 0 && ncookies > 0) { - /* Ensure that the returned offset always increases. */ - if (readbuflen >= bde->d_reclen && bde->d_fileno != 0 && - *cookie > offset) { - error = write_dirent(bde, *cookie, &uio); - if (error != 0) { - free(cookies, M_TEMP); - goto done; - } - } - - if (offset < *cookie) - offset = *cookie; - ++cookie; - --ncookies; - readbuflen -= bde->d_reclen; - bde = (struct dirent *)((char *)bde + bde->d_reclen); - } - free(cookies, M_TEMP); - if (eof) - break; - } - -done: - fdrop(fp, td); - free(readbuf, M_TEMP); - if (error != 0) - return (error); - - /* Return number of bytes copied to userspace. */ - td->td_retval[0] = uap->buf_len - uio.uio_resid; - return (0); -} - -int -cloudabi_sys_file_readlink(struct thread *td, - struct cloudabi_sys_file_readlink_args *uap) -{ - char *path; - int error; - - error = copyin_path(uap->path, uap->path_len, &path); - if (error != 0) - return (error); - - error = kern_readlinkat(td, uap->fd, path, UIO_SYSSPACE, - uap->buf, UIO_USERSPACE, uap->buf_len); - cloudabi_freestr(path); - return (error); -} - -int -cloudabi_sys_file_rename(struct thread *td, - struct cloudabi_sys_file_rename_args *uap) -{ - char *old, *new; - int error; - - error = copyin_path(uap->path1, uap->path1_len, &old); - if (error != 0) - return (error); - error = copyin_path(uap->path2, uap->path2_len, &new); - if (error != 0) { - cloudabi_freestr(old); - return (error); - } - - error = kern_renameat(td, uap->fd1, old, uap->fd2, new, - UIO_SYSSPACE); - cloudabi_freestr(old); - cloudabi_freestr(new); - return (error); -} - -/* Converts a FreeBSD stat structure to a CloudABI stat structure. */ -static void -convert_stat(const struct stat *sb, cloudabi_filestat_t *csb) -{ - cloudabi_filestat_t res = { - .st_dev = sb->st_dev, - .st_ino = sb->st_ino, - .st_nlink = sb->st_nlink, - .st_size = sb->st_size, - }; - - cloudabi_convert_timespec(&sb->st_atim, &res.st_atim); - cloudabi_convert_timespec(&sb->st_mtim, &res.st_mtim); - cloudabi_convert_timespec(&sb->st_ctim, &res.st_ctim); - *csb = res; -} - -int -cloudabi_sys_file_stat_fget(struct thread *td, - struct cloudabi_sys_file_stat_fget_args *uap) -{ - struct stat sb; - cloudabi_filestat_t csb; - struct file *fp; - cloudabi_filetype_t filetype; - int error; - - memset(&csb, 0, sizeof(csb)); - - /* Fetch file descriptor attributes. */ - error = fget(td, uap->fd, &cap_fstat_rights, &fp); - if (error != 0) - return (error); - error = fo_stat(fp, &sb, td->td_ucred, td); - if (error != 0) { - fdrop(fp, td); - return (error); - } - filetype = cloudabi_convert_filetype(fp); - fdrop(fp, td); - - /* Convert attributes to CloudABI's format. */ - convert_stat(&sb, &csb); - csb.st_filetype = filetype; - return (copyout(&csb, uap->buf, sizeof(csb))); -} - -/* Converts timestamps to arguments to futimens() and utimensat(). */ -static void -convert_utimens_arguments(const cloudabi_filestat_t *fs, - cloudabi_fsflags_t flags, struct timespec *ts) -{ - - if ((flags & CLOUDABI_FILESTAT_ATIM_NOW) != 0) { - ts[0].tv_nsec = UTIME_NOW; - } else if ((flags & CLOUDABI_FILESTAT_ATIM) != 0) { - ts[0].tv_sec = fs->st_atim / 1000000000; - ts[0].tv_nsec = fs->st_atim % 1000000000; - } else { - ts[0].tv_nsec = UTIME_OMIT; - } - - if ((flags & CLOUDABI_FILESTAT_MTIM_NOW) != 0) { - ts[1].tv_nsec = UTIME_NOW; - } else if ((flags & CLOUDABI_FILESTAT_MTIM) != 0) { - ts[1].tv_sec = fs->st_mtim / 1000000000; - ts[1].tv_nsec = fs->st_mtim % 1000000000; - } else { - ts[1].tv_nsec = UTIME_OMIT; - } -} - -int -cloudabi_sys_file_stat_fput(struct thread *td, - struct cloudabi_sys_file_stat_fput_args *uap) -{ - cloudabi_filestat_t fs; - struct timespec ts[2]; - int error; - - error = copyin(uap->buf, &fs, sizeof(fs)); - if (error != 0) - return (error); - - /* - * Only support truncation and timestamp modification separately - * for now, to prevent unnecessary code duplication. - */ - if ((uap->flags & CLOUDABI_FILESTAT_SIZE) != 0) { - /* Call into kern_ftruncate() for file truncation. */ - if ((uap->flags & ~CLOUDABI_FILESTAT_SIZE) != 0) - return (EINVAL); - return (kern_ftruncate(td, uap->fd, fs.st_size)); - } else if ((uap->flags & (CLOUDABI_FILESTAT_ATIM | - CLOUDABI_FILESTAT_ATIM_NOW | CLOUDABI_FILESTAT_MTIM | - CLOUDABI_FILESTAT_MTIM_NOW)) != 0) { - /* Call into kern_futimens() for timestamp modification. */ - if ((uap->flags & ~(CLOUDABI_FILESTAT_ATIM | - CLOUDABI_FILESTAT_ATIM_NOW | CLOUDABI_FILESTAT_MTIM | - CLOUDABI_FILESTAT_MTIM_NOW)) != 0) - return (EINVAL); - convert_utimens_arguments(&fs, uap->flags, ts); - return (kern_futimens(td, uap->fd, ts, UIO_SYSSPACE)); - } - return (EINVAL); -} - -int -cloudabi_sys_file_stat_get(struct thread *td, - struct cloudabi_sys_file_stat_get_args *uap) -{ - struct stat sb; - cloudabi_filestat_t csb; - char *path; - int error; - - memset(&csb, 0, sizeof(csb)); - - error = copyin_path(uap->path, uap->path_len, &path); - if (error != 0) - return (error); - - error = kern_statat(td, - (uap->fd.flags & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) != 0 ? 0 : - AT_SYMLINK_NOFOLLOW, uap->fd.fd, path, UIO_SYSSPACE, &sb, NULL); - cloudabi_freestr(path); - if (error != 0) - return (error); - - /* Convert results and return them. */ - convert_stat(&sb, &csb); - if (S_ISBLK(sb.st_mode)) - csb.st_filetype = CLOUDABI_FILETYPE_BLOCK_DEVICE; - else if (S_ISCHR(sb.st_mode)) - csb.st_filetype = CLOUDABI_FILETYPE_CHARACTER_DEVICE; - else if (S_ISDIR(sb.st_mode)) - csb.st_filetype = CLOUDABI_FILETYPE_DIRECTORY; - else if (S_ISFIFO(sb.st_mode)) - csb.st_filetype = CLOUDABI_FILETYPE_SOCKET_STREAM; - else if (S_ISREG(sb.st_mode)) - csb.st_filetype = CLOUDABI_FILETYPE_REGULAR_FILE; - else if (S_ISSOCK(sb.st_mode)) { - /* Inaccurate, but the best that we can do. */ - csb.st_filetype = CLOUDABI_FILETYPE_SOCKET_STREAM; - } else if (S_ISLNK(sb.st_mode)) - csb.st_filetype = CLOUDABI_FILETYPE_SYMBOLIC_LINK; - else - csb.st_filetype = CLOUDABI_FILETYPE_UNKNOWN; - return (copyout(&csb, uap->buf, sizeof(csb))); -} - -int -cloudabi_sys_file_stat_put(struct thread *td, - struct cloudabi_sys_file_stat_put_args *uap) -{ - cloudabi_filestat_t fs; - struct timespec ts[2]; - char *path; - int error; - - /* - * Only support timestamp modification for now, as there is no - * truncateat(). - */ - if ((uap->flags & ~(CLOUDABI_FILESTAT_ATIM | - CLOUDABI_FILESTAT_ATIM_NOW | CLOUDABI_FILESTAT_MTIM | - CLOUDABI_FILESTAT_MTIM_NOW)) != 0) - return (EINVAL); - - error = copyin(uap->buf, &fs, sizeof(fs)); - if (error != 0) - return (error); - error = copyin_path(uap->path, uap->path_len, &path); - if (error != 0) - return (error); - - convert_utimens_arguments(&fs, uap->flags, ts); - error = kern_utimensat(td, uap->fd.fd, path, UIO_SYSSPACE, ts, - UIO_SYSSPACE, (uap->fd.flags & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) ? - 0 : AT_SYMLINK_NOFOLLOW); - cloudabi_freestr(path); - return (error); -} - -int -cloudabi_sys_file_symlink(struct thread *td, - struct cloudabi_sys_file_symlink_args *uap) -{ - char *path1, *path2; - int error; - - error = copyin_path(uap->path1, uap->path1_len, &path1); - if (error != 0) - return (error); - error = copyin_path(uap->path2, uap->path2_len, &path2); - if (error != 0) { - cloudabi_freestr(path1); - return (error); - } - - error = kern_symlinkat(td, path1, uap->fd, path2, UIO_SYSSPACE); - cloudabi_freestr(path1); - cloudabi_freestr(path2); - return (error); -} - -int -cloudabi_sys_file_unlink(struct thread *td, - struct cloudabi_sys_file_unlink_args *uap) -{ - char *path; - int error; - - error = copyin_path(uap->path, uap->path_len, &path); - if (error != 0) - return (error); - - if (uap->flags & CLOUDABI_UNLINK_REMOVEDIR) - error = kern_frmdirat(td, uap->fd, path, FD_NONE, - UIO_SYSSPACE, 0); - else - error = kern_funlinkat(td, uap->fd, path, FD_NONE, - UIO_SYSSPACE, 0, 0); - cloudabi_freestr(path); - return (error); -} diff --git a/sys/compat/cloudabi/cloudabi_futex.c b/sys/compat/cloudabi/cloudabi_futex.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_futex.c +++ /dev/null @@ -1,1165 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -/* - * Futexes for CloudABI. - * - * On most systems, futexes are implemented as objects of a single type - * on which a set of operations can be performed. CloudABI makes a clear - * distinction between locks and condition variables. A lock may have - * zero or more associated condition variables. A condition variable is - * always associated with exactly one lock. There is a strict topology. - * This approach has two advantages: - * - * - This topology is guaranteed to be acyclic. Requeueing of threads - * only happens in one direction (from condition variables to locks). - * This eases locking. - * - It means that a futex object for a lock exists when it is unlocked, - * but has threads waiting on associated condition variables. Threads - * can be requeued to a lock even if the thread performing the wakeup - * does not have the lock mapped in its address space. - * - * This futex implementation only implements a single lock type, namely - * a read-write lock. A regular mutex type would not be necessary, as - * the read-write lock is as efficient as a mutex if used as such. - * Userspace futex locks are 32 bits in size: - * - * - 1 bit: has threads waiting in kernel-space. - * - 1 bit: is write-locked. - * - 30 bits: - * - if write-locked: thread ID of owner. - * - if not write-locked: number of read locks held. - * - * Condition variables are also 32 bits in size. Its value is modified - * by kernel-space exclusively. Zero indicates that it has no waiting - * threads. Non-zero indicates the opposite. - * - * This implementation is optimal, in the sense that it only wakes up - * threads if they can actually continue execution. It does not suffer - * from the thundering herd problem. If multiple threads waiting on a - * condition variable need to be woken up, only a single thread is - * scheduled. All other threads are 'donated' to this thread. After the - * thread manages to reacquire the lock, it requeues its donated threads - * to the lock. - * - * TODO(ed): Integrate this functionality into kern_umtx.c instead. - * TODO(ed): Store futex objects in a hash table. - * TODO(ed): Add actual priority inheritance. - * TODO(ed): Let futex_queue also take priorities into account. - * TODO(ed): Make locking fine-grained. - * TODO(ed): Perform sleeps until an actual absolute point in time, - * instead of converting the timestamp to a relative value. - */ - -struct futex_address; -struct futex_condvar; -struct futex_lock; -struct futex_queue; -struct futex_waiter; - -/* Identifier of a location in memory. */ -struct futex_address { - struct umtx_key fa_key; -}; - -/* A set of waiting threads. */ -struct futex_queue { - STAILQ_HEAD(, futex_waiter) fq_list; - unsigned int fq_count; -}; - -/* Condition variables. */ -struct futex_condvar { - /* Address of the condition variable. */ - struct futex_address fc_address; - - /* The lock the waiters should be moved to when signalled. */ - struct futex_lock * fc_lock; - - /* Threads waiting on the condition variable. */ - struct futex_queue fc_waiters; - /* - * Number of threads blocked on this condition variable, or - * being blocked on the lock after being requeued. - */ - unsigned int fc_waitcount; - - /* Global list pointers. */ - LIST_ENTRY(futex_condvar) fc_next; -}; - -/* Read-write locks. */ -struct futex_lock { - /* Address of the lock. */ - struct futex_address fl_address; - - /* - * Current owner of the lock. LOCK_UNMANAGED if the lock is - * currently not owned by the kernel. LOCK_OWNER_UNKNOWN in case - * the owner is not known (e.g., when the lock is read-locked). - */ - cloudabi_tid_t fl_owner; -#define LOCK_UNMANAGED 0x0 -#define LOCK_OWNER_UNKNOWN 0x1 - - /* Writers blocked on the lock. */ - struct futex_queue fl_writers; - /* Readers blocked on the lock. */ - struct futex_queue fl_readers; - /* Number of threads blocked on this lock + condition variables. */ - unsigned int fl_waitcount; - - /* Global list pointers. */ - LIST_ENTRY(futex_lock) fl_next; -}; - -/* Information associated with a thread blocked on an object. */ -struct futex_waiter { - /* Thread ID. */ - cloudabi_tid_t fw_tid; - /* Condition variable used for waiting. */ - struct cv fw_wait; - - /* Queue this waiter is currently placed in. */ - struct futex_queue * fw_queue; - /* List pointers of fw_queue. */ - STAILQ_ENTRY(futex_waiter) fw_next; - - /* Lock has been acquired. */ - bool fw_locked; - /* If not locked, threads that should block after acquiring. */ - struct futex_queue fw_donated; -}; - -/* Global data structures. */ -static MALLOC_DEFINE(M_FUTEX, "futex", "CloudABI futex"); - -static struct sx futex_global_lock; -SX_SYSINIT(futex_global_lock, &futex_global_lock, "CloudABI futex global lock"); - -static LIST_HEAD(, futex_lock) futex_lock_list = - LIST_HEAD_INITIALIZER(&futex_lock_list); -static LIST_HEAD(, futex_condvar) futex_condvar_list = - LIST_HEAD_INITIALIZER(&futex_condvar_list); - -/* Utility functions. */ -static void futex_lock_assert(const struct futex_lock *); -static struct futex_lock *futex_lock_lookup_locked(struct futex_address *); -static void futex_lock_release(struct futex_lock *); -static int futex_lock_tryrdlock(struct futex_lock *, cloudabi_lock_t *); -static int futex_lock_unmanage(struct futex_lock *, cloudabi_lock_t *); -static int futex_lock_update_owner(struct futex_lock *, cloudabi_lock_t *); -static int futex_lock_wake_up_next(struct futex_lock *, cloudabi_lock_t *); -static unsigned int futex_queue_count(const struct futex_queue *); -static void futex_queue_init(struct futex_queue *); -static void futex_queue_requeue(struct futex_queue *, struct futex_queue *, - unsigned int); -static int futex_queue_sleep(struct futex_queue *, struct futex_lock *, - struct futex_waiter *, struct thread *, cloudabi_clockid_t, - cloudabi_timestamp_t, cloudabi_timestamp_t, bool); -static cloudabi_tid_t futex_queue_tid_best(const struct futex_queue *); -static void futex_queue_wake_up_all(struct futex_queue *); -static void futex_queue_wake_up_best(struct futex_queue *); -static void futex_queue_wake_up_donate(struct futex_queue *, unsigned int); -static int futex_user_load(uint32_t *, uint32_t *); -static int futex_user_store(uint32_t *, uint32_t); -static int futex_user_cmpxchg(uint32_t *, uint32_t, uint32_t *, uint32_t); - -/* - * futex_address operations. - */ - -static int -futex_address_create(struct futex_address *fa, struct thread *td, - const void *object, cloudabi_scope_t scope) -{ - - KASSERT(td == curthread, - ("Can only create umtx keys for the current thread")); - switch (scope) { - case CLOUDABI_SCOPE_PRIVATE: - return (umtx_key_get(object, TYPE_FUTEX, THREAD_SHARE, - &fa->fa_key)); - case CLOUDABI_SCOPE_SHARED: - return (umtx_key_get(object, TYPE_FUTEX, AUTO_SHARE, - &fa->fa_key)); - default: - return (EINVAL); - } -} - -static void -futex_address_free(struct futex_address *fa) -{ - - umtx_key_release(&fa->fa_key); -} - -static bool -futex_address_match(const struct futex_address *fa1, - const struct futex_address *fa2) -{ - - return (umtx_key_match(&fa1->fa_key, &fa2->fa_key)); -} - -/* - * futex_condvar operations. - */ - -static void -futex_condvar_assert(const struct futex_condvar *fc) -{ - - KASSERT(fc->fc_waitcount >= futex_queue_count(&fc->fc_waiters), - ("Total number of waiters cannot be smaller than the wait queue")); - futex_lock_assert(fc->fc_lock); -} - -static int -futex_condvar_lookup(struct thread *td, const cloudabi_condvar_t *address, - cloudabi_scope_t scope, struct futex_condvar **fcret) -{ - struct futex_address fa_condvar; - struct futex_condvar *fc; - int error; - - error = futex_address_create(&fa_condvar, td, address, scope); - if (error != 0) - return (error); - - sx_xlock(&futex_global_lock); - LIST_FOREACH(fc, &futex_condvar_list, fc_next) { - if (futex_address_match(&fc->fc_address, &fa_condvar)) { - /* Found matching lock object. */ - futex_address_free(&fa_condvar); - futex_condvar_assert(fc); - *fcret = fc; - return (0); - } - } - sx_xunlock(&futex_global_lock); - futex_address_free(&fa_condvar); - return (ENOENT); -} - -static int -futex_condvar_lookup_or_create(struct thread *td, - const cloudabi_condvar_t *condvar, cloudabi_scope_t condvar_scope, - const cloudabi_lock_t *lock, cloudabi_scope_t lock_scope, - struct futex_condvar **fcret) -{ - struct futex_address fa_condvar, fa_lock; - struct futex_condvar *fc; - struct futex_lock *fl; - int error; - - error = futex_address_create(&fa_condvar, td, condvar, condvar_scope); - if (error != 0) - return (error); - error = futex_address_create(&fa_lock, td, lock, lock_scope); - if (error != 0) { - futex_address_free(&fa_condvar); - return (error); - } - - sx_xlock(&futex_global_lock); - LIST_FOREACH(fc, &futex_condvar_list, fc_next) { - if (!futex_address_match(&fc->fc_address, &fa_condvar)) - continue; - fl = fc->fc_lock; - if (!futex_address_match(&fl->fl_address, &fa_lock)) { - /* Condition variable is owned by a different lock. */ - futex_address_free(&fa_condvar); - futex_address_free(&fa_lock); - sx_xunlock(&futex_global_lock); - return (EINVAL); - } - - /* Found fully matching condition variable. */ - futex_address_free(&fa_condvar); - futex_address_free(&fa_lock); - futex_condvar_assert(fc); - *fcret = fc; - return (0); - } - - /* None found. Create new condition variable object. */ - fc = malloc(sizeof(*fc), M_FUTEX, M_WAITOK); - fc->fc_address = fa_condvar; - fc->fc_lock = futex_lock_lookup_locked(&fa_lock); - futex_queue_init(&fc->fc_waiters); - fc->fc_waitcount = 0; - LIST_INSERT_HEAD(&futex_condvar_list, fc, fc_next); - *fcret = fc; - return (0); -} - -static void -futex_condvar_release(struct futex_condvar *fc) -{ - struct futex_lock *fl; - - futex_condvar_assert(fc); - fl = fc->fc_lock; - if (fc->fc_waitcount == 0) { - /* Condition variable has no waiters. Deallocate it. */ - futex_address_free(&fc->fc_address); - LIST_REMOVE(fc, fc_next); - free(fc, M_FUTEX); - } - futex_lock_release(fl); -} - -static int -futex_condvar_unmanage(struct futex_condvar *fc, - cloudabi_condvar_t *condvar) -{ - - if (futex_queue_count(&fc->fc_waiters) != 0) - return (0); - return (futex_user_store(condvar, CLOUDABI_CONDVAR_HAS_NO_WAITERS)); -} - -/* - * futex_lock operations. - */ - -static void -futex_lock_assert(const struct futex_lock *fl) -{ - - /* - * A futex lock can only be kernel-managed if it has waiters. - * Vice versa: if a futex lock has waiters, it must be - * kernel-managed. - */ - KASSERT((fl->fl_owner == LOCK_UNMANAGED) == - (futex_queue_count(&fl->fl_readers) == 0 && - futex_queue_count(&fl->fl_writers) == 0), - ("Managed locks must have waiting threads")); - KASSERT(fl->fl_waitcount != 0 || fl->fl_owner == LOCK_UNMANAGED, - ("Lock with no waiters must be unmanaged")); -} - -static int -futex_lock_lookup(struct thread *td, const cloudabi_lock_t *address, - cloudabi_scope_t scope, struct futex_lock **flret) -{ - struct futex_address fa; - int error; - - error = futex_address_create(&fa, td, address, scope); - if (error != 0) - return (error); - - sx_xlock(&futex_global_lock); - *flret = futex_lock_lookup_locked(&fa); - return (0); -} - -static struct futex_lock * -futex_lock_lookup_locked(struct futex_address *fa) -{ - struct futex_lock *fl; - - LIST_FOREACH(fl, &futex_lock_list, fl_next) { - if (futex_address_match(&fl->fl_address, fa)) { - /* Found matching lock object. */ - futex_address_free(fa); - futex_lock_assert(fl); - return (fl); - } - } - - /* None found. Create new lock object. */ - fl = malloc(sizeof(*fl), M_FUTEX, M_WAITOK); - fl->fl_address = *fa; - fl->fl_owner = LOCK_UNMANAGED; - futex_queue_init(&fl->fl_readers); - futex_queue_init(&fl->fl_writers); - fl->fl_waitcount = 0; - LIST_INSERT_HEAD(&futex_lock_list, fl, fl_next); - return (fl); -} - -static int -futex_lock_rdlock(struct futex_lock *fl, struct thread *td, - cloudabi_lock_t *lock, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime) -{ - struct futex_waiter fw; - int error; - - error = futex_lock_tryrdlock(fl, lock); - if (error == EBUSY) { - /* Suspend execution. */ - KASSERT(fl->fl_owner != LOCK_UNMANAGED, - ("Attempted to sleep on an unmanaged lock")); - error = futex_queue_sleep(&fl->fl_readers, fl, &fw, td, - clock_id, timeout, precision, abstime); - KASSERT((error == 0) == fw.fw_locked, - ("Should have locked write lock on success")); - KASSERT(futex_queue_count(&fw.fw_donated) == 0, - ("Lock functions cannot receive threads")); - } - if (error != 0) - futex_lock_unmanage(fl, lock); - return (error); -} - -static void -futex_lock_release(struct futex_lock *fl) -{ - - futex_lock_assert(fl); - if (fl->fl_waitcount == 0) { - /* Lock object is unreferenced. Deallocate it. */ - KASSERT(fl->fl_owner == LOCK_UNMANAGED, - ("Attempted to free a managed lock")); - futex_address_free(&fl->fl_address); - LIST_REMOVE(fl, fl_next); - free(fl, M_FUTEX); - } - sx_xunlock(&futex_global_lock); -} - -static int -futex_lock_unmanage(struct futex_lock *fl, cloudabi_lock_t *lock) -{ - cloudabi_lock_t cmp, old; - int error; - - if (futex_queue_count(&fl->fl_readers) == 0 && - futex_queue_count(&fl->fl_writers) == 0) { - /* Lock should be unmanaged. */ - fl->fl_owner = LOCK_UNMANAGED; - - /* Clear kernel-managed bit. */ - error = futex_user_load(lock, &old); - if (error != 0) - return (error); - for (;;) { - cmp = old; - error = futex_user_cmpxchg(lock, cmp, &old, - cmp & ~CLOUDABI_LOCK_KERNEL_MANAGED); - if (error != 0) - return (error); - if (old == cmp) - break; - } - } - return (0); -} - -/* Sets an owner of a lock, based on a userspace lock value. */ -static void -futex_lock_set_owner(struct futex_lock *fl, cloudabi_lock_t lock) -{ - - /* Lock has no explicit owner. */ - if ((lock & ~CLOUDABI_LOCK_WRLOCKED) == 0) { - fl->fl_owner = LOCK_OWNER_UNKNOWN; - return; - } - lock &= ~(CLOUDABI_LOCK_WRLOCKED | CLOUDABI_LOCK_KERNEL_MANAGED); - - /* Don't allow userspace to silently unlock. */ - if (lock == LOCK_UNMANAGED) { - fl->fl_owner = LOCK_OWNER_UNKNOWN; - return; - } - fl->fl_owner = lock; -} - -static int -futex_lock_unlock(struct futex_lock *fl, struct thread *td, - cloudabi_lock_t *lock) -{ - int error; - - /* Validate that this thread is allowed to unlock. */ - error = futex_lock_update_owner(fl, lock); - if (error != 0) - return (error); - if (fl->fl_owner != LOCK_UNMANAGED && fl->fl_owner != td->td_tid) - return (EPERM); - return (futex_lock_wake_up_next(fl, lock)); -} - -/* Syncs in the owner of the lock from userspace if needed. */ -static int -futex_lock_update_owner(struct futex_lock *fl, cloudabi_lock_t *address) -{ - cloudabi_lock_t lock; - int error; - - if (fl->fl_owner == LOCK_OWNER_UNKNOWN) { - error = futex_user_load(address, &lock); - if (error != 0) - return (error); - futex_lock_set_owner(fl, lock); - } - return (0); -} - -static int -futex_lock_tryrdlock(struct futex_lock *fl, cloudabi_lock_t *address) -{ - cloudabi_lock_t old, cmp; - int error; - - if (fl->fl_owner != LOCK_UNMANAGED) { - /* Lock is already acquired. */ - return (EBUSY); - } - - old = CLOUDABI_LOCK_UNLOCKED; - for (;;) { - if ((old & CLOUDABI_LOCK_KERNEL_MANAGED) != 0) { - /* - * Userspace lock is kernel-managed, even though - * the kernel disagrees. - */ - return (EINVAL); - } - - if ((old & CLOUDABI_LOCK_WRLOCKED) == 0) { - /* - * Lock is not write-locked. Attempt to acquire - * it by increasing the read count. - */ - cmp = old; - error = futex_user_cmpxchg(address, cmp, &old, cmp + 1); - if (error != 0) - return (error); - if (old == cmp) { - /* Success. */ - return (0); - } - } else { - /* Lock is write-locked. Make it kernel-managed. */ - cmp = old; - error = futex_user_cmpxchg(address, cmp, &old, - cmp | CLOUDABI_LOCK_KERNEL_MANAGED); - if (error != 0) - return (error); - if (old == cmp) { - /* Success. */ - futex_lock_set_owner(fl, cmp); - return (EBUSY); - } - } - } -} - -static int -futex_lock_trywrlock(struct futex_lock *fl, cloudabi_lock_t *address, - cloudabi_tid_t tid, bool force_kernel_managed) -{ - cloudabi_lock_t old, new, cmp; - int error; - - if (fl->fl_owner == tid) { - /* Attempted to acquire lock recursively. */ - return (EDEADLK); - } - if (fl->fl_owner != LOCK_UNMANAGED) { - /* Lock is already acquired. */ - return (EBUSY); - } - - old = CLOUDABI_LOCK_UNLOCKED; - for (;;) { - if ((old & CLOUDABI_LOCK_KERNEL_MANAGED) != 0) { - /* - * Userspace lock is kernel-managed, even though - * the kernel disagrees. - */ - return (EINVAL); - } - if (old == (tid | CLOUDABI_LOCK_WRLOCKED)) { - /* Attempted to acquire lock recursively. */ - return (EDEADLK); - } - - if (old == CLOUDABI_LOCK_UNLOCKED) { - /* Lock is unlocked. Attempt to acquire it. */ - new = tid | CLOUDABI_LOCK_WRLOCKED; - if (force_kernel_managed) - new |= CLOUDABI_LOCK_KERNEL_MANAGED; - error = futex_user_cmpxchg(address, - CLOUDABI_LOCK_UNLOCKED, &old, new); - if (error != 0) - return (error); - if (old == CLOUDABI_LOCK_UNLOCKED) { - /* Success. */ - if (force_kernel_managed) - fl->fl_owner = tid; - return (0); - } - } else { - /* Lock is still locked. Make it kernel-managed. */ - cmp = old; - error = futex_user_cmpxchg(address, cmp, &old, - cmp | CLOUDABI_LOCK_KERNEL_MANAGED); - if (error != 0) - return (error); - if (old == cmp) { - /* Success. */ - futex_lock_set_owner(fl, cmp); - return (EBUSY); - } - } - } -} - -static int -futex_lock_wake_up_next(struct futex_lock *fl, cloudabi_lock_t *lock) -{ - cloudabi_tid_t tid; - int error; - - /* - * Determine which thread(s) to wake up. Prefer waking up - * writers over readers to prevent write starvation. - */ - if (futex_queue_count(&fl->fl_writers) > 0) { - /* Transfer ownership to a single write-locker. */ - if (futex_queue_count(&fl->fl_writers) > 1 || - futex_queue_count(&fl->fl_readers) > 0) { - /* Lock should remain managed afterwards. */ - tid = futex_queue_tid_best(&fl->fl_writers); - error = futex_user_store(lock, - tid | CLOUDABI_LOCK_WRLOCKED | - CLOUDABI_LOCK_KERNEL_MANAGED); - if (error != 0) - return (error); - - futex_queue_wake_up_best(&fl->fl_writers); - fl->fl_owner = tid; - } else { - /* Lock can become unmanaged afterwards. */ - error = futex_user_store(lock, - futex_queue_tid_best(&fl->fl_writers) | - CLOUDABI_LOCK_WRLOCKED); - if (error != 0) - return (error); - - futex_queue_wake_up_best(&fl->fl_writers); - fl->fl_owner = LOCK_UNMANAGED; - } - } else { - /* Transfer ownership to all read-lockers (if any). */ - error = futex_user_store(lock, - futex_queue_count(&fl->fl_readers)); - if (error != 0) - return (error); - - /* Wake up all threads. */ - futex_queue_wake_up_all(&fl->fl_readers); - fl->fl_owner = LOCK_UNMANAGED; - } - return (0); -} - -static int -futex_lock_wrlock(struct futex_lock *fl, struct thread *td, - cloudabi_lock_t *lock, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime, - struct futex_queue *donated) -{ - struct futex_waiter fw; - int error; - - error = futex_lock_trywrlock(fl, lock, td->td_tid, - futex_queue_count(donated) > 0); - - if (error == 0 || error == EBUSY) { - /* Put donated threads in queue before suspending. */ - KASSERT(futex_queue_count(donated) == 0 || - fl->fl_owner != LOCK_UNMANAGED, - ("Lock should be managed if we are going to donate")); - futex_queue_requeue(donated, &fl->fl_writers, UINT_MAX); - } else { - /* - * This thread cannot deal with the donated threads. - * Wake up the next thread and let it try it by itself. - */ - futex_queue_wake_up_donate(donated, UINT_MAX); - } - - if (error == EBUSY) { - /* Suspend execution if the lock was busy. */ - KASSERT(fl->fl_owner != LOCK_UNMANAGED, - ("Attempted to sleep on an unmanaged lock")); - error = futex_queue_sleep(&fl->fl_writers, fl, &fw, td, - clock_id, timeout, precision, abstime); - KASSERT((error == 0) == fw.fw_locked, - ("Should have locked write lock on success")); - KASSERT(futex_queue_count(&fw.fw_donated) == 0, - ("Lock functions cannot receive threads")); - } - if (error != 0) - futex_lock_unmanage(fl, lock); - return (error); -} - -/* - * futex_queue operations. - */ - -static cloudabi_tid_t -futex_queue_tid_best(const struct futex_queue *fq) -{ - - return (STAILQ_FIRST(&fq->fq_list)->fw_tid); -} - -static unsigned int -futex_queue_count(const struct futex_queue *fq) -{ - - return (fq->fq_count); -} - -static void -futex_queue_init(struct futex_queue *fq) -{ - - STAILQ_INIT(&fq->fq_list); - fq->fq_count = 0; -} - -/* Converts a relative timestamp to an sbintime. */ -static sbintime_t -futex_queue_convert_timestamp_relative(cloudabi_timestamp_t ts) -{ - cloudabi_timestamp_t s, ns; - - s = ts / 1000000000; - ns = ts % 1000000000; - if (s > INT32_MAX) - return (INT64_MAX); - return ((s << 32) + (ns << 32) / 1000000000); -} - -/* Converts an absolute timestamp and precision to a pair of sbintime values. */ -static int -futex_queue_convert_timestamp(struct thread *td, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, - sbintime_t *sbttimeout, sbintime_t *sbtprecision, bool abstime) -{ - cloudabi_timestamp_t now; - int error; - - if (abstime) { - /* Make the time relative. */ - error = cloudabi_clock_time_get(td, clock_id, &now); - if (error != 0) - return (error); - timeout = timeout < now ? 0 : timeout - now; - } - - *sbttimeout = futex_queue_convert_timestamp_relative(timeout); - *sbtprecision = futex_queue_convert_timestamp_relative(precision); - return (0); -} - -static int -futex_queue_sleep(struct futex_queue *fq, struct futex_lock *fl, - struct futex_waiter *fw, struct thread *td, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime) -{ - sbintime_t sbttimeout, sbtprecision; - int error; - - /* Initialize futex_waiter object. */ - fw->fw_tid = td->td_tid; - fw->fw_locked = false; - futex_queue_init(&fw->fw_donated); - - if (timeout != UINT64_MAX) { - /* Convert timeout duration. */ - error = futex_queue_convert_timestamp(td, clock_id, timeout, - precision, &sbttimeout, &sbtprecision, abstime); - if (error != 0) - return (error); - } - - /* Place object in the queue. */ - fw->fw_queue = fq; - STAILQ_INSERT_TAIL(&fq->fq_list, fw, fw_next); - ++fq->fq_count; - - cv_init(&fw->fw_wait, "futex"); - ++fl->fl_waitcount; - - futex_lock_assert(fl); - if (timeout == UINT64_MAX) { - /* Wait without a timeout. */ - error = cv_wait_sig(&fw->fw_wait, &futex_global_lock); - } else { - /* Wait respecting the timeout. */ - error = cv_timedwait_sig_sbt(&fw->fw_wait, &futex_global_lock, - sbttimeout, sbtprecision, 0); - futex_lock_assert(fl); - if (error == EWOULDBLOCK && - fw->fw_queue != NULL && fw->fw_queue != fq) { - /* - * We got signalled on a condition variable, but - * observed a timeout while waiting to reacquire - * the lock. In other words, we didn't actually - * time out. Go back to sleep and wait for the - * lock to be reacquired. - */ - error = cv_wait_sig(&fw->fw_wait, &futex_global_lock); - } - } - futex_lock_assert(fl); - - --fl->fl_waitcount; - cv_destroy(&fw->fw_wait); - - fq = fw->fw_queue; - if (fq == NULL) { - /* Thread got dequeued, so we've slept successfully. */ - return (0); - } - - /* Thread is still enqueued. Remove it. */ - KASSERT(error != 0, ("Woken up thread is still enqueued")); - STAILQ_REMOVE(&fq->fq_list, fw, futex_waiter, fw_next); - --fq->fq_count; - return (error == EWOULDBLOCK ? ETIMEDOUT : error); -} - -/* Moves up to nwaiters waiters from one queue to another. */ -static void -futex_queue_requeue(struct futex_queue *fqfrom, struct futex_queue *fqto, - unsigned int nwaiters) -{ - struct futex_waiter *fw; - - /* Move waiters to the target queue. */ - while (nwaiters-- > 0 && !STAILQ_EMPTY(&fqfrom->fq_list)) { - fw = STAILQ_FIRST(&fqfrom->fq_list); - STAILQ_REMOVE_HEAD(&fqfrom->fq_list, fw_next); - --fqfrom->fq_count; - - fw->fw_queue = fqto; - STAILQ_INSERT_TAIL(&fqto->fq_list, fw, fw_next); - ++fqto->fq_count; - } -} - -/* Wakes up all waiters in a queue. */ -static void -futex_queue_wake_up_all(struct futex_queue *fq) -{ - struct futex_waiter *fw; - - STAILQ_FOREACH(fw, &fq->fq_list, fw_next) { - fw->fw_locked = true; - fw->fw_queue = NULL; - cv_signal(&fw->fw_wait); - } - - STAILQ_INIT(&fq->fq_list); - fq->fq_count = 0; -} - -/* - * Wakes up the best waiter (i.e., the waiter having the highest - * priority) in a queue. - */ -static void -futex_queue_wake_up_best(struct futex_queue *fq) -{ - struct futex_waiter *fw; - - fw = STAILQ_FIRST(&fq->fq_list); - fw->fw_locked = true; - fw->fw_queue = NULL; - cv_signal(&fw->fw_wait); - - STAILQ_REMOVE_HEAD(&fq->fq_list, fw_next); - --fq->fq_count; -} - -static void -futex_queue_wake_up_donate(struct futex_queue *fq, unsigned int nwaiters) -{ - struct futex_waiter *fw; - - fw = STAILQ_FIRST(&fq->fq_list); - if (fw == NULL) - return; - fw->fw_locked = false; - fw->fw_queue = NULL; - cv_signal(&fw->fw_wait); - - STAILQ_REMOVE_HEAD(&fq->fq_list, fw_next); - --fq->fq_count; - futex_queue_requeue(fq, &fw->fw_donated, nwaiters); -} - -/* - * futex_user operations. Used to adjust values in userspace. - */ - -static int -futex_user_load(uint32_t *obj, uint32_t *val) -{ - - return (fueword32(obj, val) != 0 ? EFAULT : 0); -} - -static int -futex_user_store(uint32_t *obj, uint32_t val) -{ - - return (suword32(obj, val) != 0 ? EFAULT : 0); -} - -static int -futex_user_cmpxchg(uint32_t *obj, uint32_t cmp, uint32_t *old, uint32_t new) -{ - - return (casueword32(obj, cmp, old, new) != 0 ? EFAULT : 0); -} - -/* - * Blocking calls: acquiring locks, waiting on condition variables. - */ - -int -cloudabi_futex_condvar_wait(struct thread *td, cloudabi_condvar_t *condvar, - cloudabi_scope_t condvar_scope, cloudabi_lock_t *lock, - cloudabi_scope_t lock_scope, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime) -{ - struct futex_condvar *fc; - struct futex_lock *fl; - struct futex_waiter fw; - int error, error2; - - /* Lookup condition variable object. */ - error = futex_condvar_lookup_or_create(td, condvar, condvar_scope, lock, - lock_scope, &fc); - if (error != 0) - return (error); - fl = fc->fc_lock; - - /* - * Set the condition variable to something other than - * CLOUDABI_CONDVAR_HAS_NO_WAITERS to make userspace threads - * call into the kernel to perform wakeups. - */ - error = futex_user_store(condvar, ~CLOUDABI_CONDVAR_HAS_NO_WAITERS); - if (error != 0) { - futex_condvar_release(fc); - return (error); - } - - /* Drop the lock. */ - error = futex_lock_unlock(fl, td, lock); - if (error != 0) { - futex_condvar_unmanage(fc, condvar); - futex_condvar_release(fc); - return (error); - } - - /* Go to sleep. */ - ++fc->fc_waitcount; - error = futex_queue_sleep(&fc->fc_waiters, fc->fc_lock, &fw, td, - clock_id, timeout, precision, abstime); - if (fw.fw_locked) { - /* Waited and got the lock assigned to us. */ - KASSERT(futex_queue_count(&fw.fw_donated) == 0, - ("Received threads while being locked")); - } else if (error == 0 || error == ETIMEDOUT) { - if (error != 0) - futex_condvar_unmanage(fc, condvar); - /* - * Got woken up without having the lock assigned to us. - * This can happen in two cases: - * - * 1. We observed a timeout on a condition variable. - * 2. We got signalled on a condition variable while the - * associated lock is unlocked. We are the first - * thread that gets woken up. This thread is - * responsible for reacquiring the userspace lock. - */ - error2 = futex_lock_wrlock(fl, td, lock, - CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0, abstime, - &fw.fw_donated); - if (error2 != 0) - error = error2; - } else { - KASSERT(futex_queue_count(&fw.fw_donated) == 0, - ("Received threads on error")); - futex_condvar_unmanage(fc, condvar); - futex_lock_unmanage(fl, lock); - } - --fc->fc_waitcount; - futex_condvar_release(fc); - return (error); -} - -int -cloudabi_futex_lock_rdlock(struct thread *td, cloudabi_lock_t *lock, - cloudabi_scope_t scope, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime) -{ - struct futex_lock *fl; - int error; - - /* Look up lock object. */ - error = futex_lock_lookup(td, lock, scope, &fl); - if (error != 0) - return (error); - - error = futex_lock_rdlock(fl, td, lock, clock_id, timeout, - precision, abstime); - futex_lock_release(fl); - return (error); -} - -int -cloudabi_futex_lock_wrlock(struct thread *td, cloudabi_lock_t *lock, - cloudabi_scope_t scope, cloudabi_clockid_t clock_id, - cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, bool abstime) -{ - struct futex_lock *fl; - struct futex_queue fq; - int error; - - /* Look up lock object. */ - error = futex_lock_lookup(td, lock, scope, &fl); - if (error != 0) - return (error); - - futex_queue_init(&fq); - error = futex_lock_wrlock(fl, td, lock, clock_id, timeout, - precision, abstime, &fq); - futex_lock_release(fl); - return (error); -} - -/* - * Non-blocking calls: releasing locks, signalling condition variables. - */ - -int -cloudabi_sys_condvar_signal(struct thread *td, - struct cloudabi_sys_condvar_signal_args *uap) -{ - struct futex_condvar *fc; - struct futex_lock *fl; - cloudabi_nthreads_t nwaiters; - int error; - - nwaiters = uap->nwaiters; - if (nwaiters == 0) { - /* No threads to wake up. */ - return (0); - } - - /* Look up futex object. */ - error = futex_condvar_lookup(td, uap->condvar, uap->scope, &fc); - if (error != 0) { - /* Race condition: condition variable with no waiters. */ - return (error == ENOENT ? 0 : error); - } - fl = fc->fc_lock; - - if (fl->fl_owner == LOCK_UNMANAGED) { - /* - * The lock is currently not managed by the kernel, - * meaning we must attempt to acquire the userspace lock - * first. We cannot requeue threads to an unmanaged lock, - * as these threads will then never be scheduled. - * - * Unfortunately, the memory address of the lock is - * unknown from this context, meaning that we cannot - * acquire the lock on behalf of the first thread to be - * scheduled. The lock may even not be mapped within the - * address space of the current thread. - * - * To solve this, wake up a single waiter that will - * attempt to acquire the lock. Donate all of the other - * waiters that need to be woken up to this waiter, so - * it can requeue them after acquiring the lock. - */ - futex_queue_wake_up_donate(&fc->fc_waiters, nwaiters - 1); - } else { - /* - * Lock is already managed by the kernel. This makes it - * easy, as we can requeue the threads from the - * condition variable directly to the associated lock. - */ - futex_queue_requeue(&fc->fc_waiters, &fl->fl_writers, nwaiters); - } - - /* Clear userspace condition variable if all waiters are gone. */ - error = futex_condvar_unmanage(fc, uap->condvar); - futex_condvar_release(fc); - return (error); -} - -int -cloudabi_sys_lock_unlock(struct thread *td, - struct cloudabi_sys_lock_unlock_args *uap) -{ - struct futex_lock *fl; - int error; - - error = futex_lock_lookup(td, uap->lock, uap->scope, &fl); - if (error != 0) - return (error); - error = futex_lock_unlock(fl, td, uap->lock); - futex_lock_release(fl); - return (error); -} diff --git a/sys/compat/cloudabi/cloudabi_mem.c b/sys/compat/cloudabi/cloudabi_mem.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_mem.c +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include - -#include - -/* Converts CloudABI's memory protection flags to FreeBSD's. */ -static int -convert_mprot(cloudabi_mprot_t in, int *out) -{ - - /* Unknown protection flags. */ - if ((in & ~(CLOUDABI_PROT_EXEC | CLOUDABI_PROT_WRITE | - CLOUDABI_PROT_READ)) != 0) - return (ENOTSUP); - /* W^X: Write and exec cannot be enabled at the same time. */ - if ((in & (CLOUDABI_PROT_EXEC | CLOUDABI_PROT_WRITE)) == - (CLOUDABI_PROT_EXEC | CLOUDABI_PROT_WRITE)) - return (ENOTSUP); - - *out = 0; - if (in & CLOUDABI_PROT_EXEC) - *out |= PROT_EXEC; - if (in & CLOUDABI_PROT_WRITE) - *out |= PROT_WRITE; - if (in & CLOUDABI_PROT_READ) - *out |= PROT_READ; - return (0); -} - -int -cloudabi_sys_mem_advise(struct thread *td, - struct cloudabi_sys_mem_advise_args *uap) -{ - int behav; - - switch (uap->advice) { - case CLOUDABI_ADVICE_DONTNEED: - behav = MADV_DONTNEED; - break; - case CLOUDABI_ADVICE_NORMAL: - behav = MADV_NORMAL; - break; - case CLOUDABI_ADVICE_RANDOM: - behav = MADV_RANDOM; - break; - case CLOUDABI_ADVICE_SEQUENTIAL: - behav = MADV_SEQUENTIAL; - break; - case CLOUDABI_ADVICE_WILLNEED: - behav = MADV_WILLNEED; - break; - default: - return (EINVAL); - } - - return (kern_madvise(td, (uintptr_t)uap->mapping, uap->mapping_len, - behav)); -} - -int -cloudabi_sys_mem_map(struct thread *td, struct cloudabi_sys_mem_map_args *uap) -{ - int error, flags, prot; - - /* Translate flags. */ - flags = 0; - if (uap->flags & CLOUDABI_MAP_ANON) - flags |= MAP_ANON; - if (uap->flags & CLOUDABI_MAP_FIXED) - flags |= MAP_FIXED; - if (uap->flags & CLOUDABI_MAP_PRIVATE) - flags |= MAP_PRIVATE; - if (uap->flags & CLOUDABI_MAP_SHARED) - flags |= MAP_SHARED; - - /* Translate protection. */ - error = convert_mprot(uap->prot, &prot); - if (error != 0) - return (error); - - return (kern_mmap(td, &(struct mmap_req){ - .mr_hint = (uintptr_t)uap->addr, - .mr_len = uap->len, - .mr_prot = prot, - .mr_flags = flags, - .mr_fd = uap->fd, - .mr_pos = uap->off, - })); -} - -int -cloudabi_sys_mem_protect(struct thread *td, - struct cloudabi_sys_mem_protect_args *uap) -{ - int error, prot; - - /* Translate protection. */ - error = convert_mprot(uap->prot, &prot); - if (error != 0) - return (error); - - return (kern_mprotect(td, (uintptr_t)uap->mapping, uap->mapping_len, - prot)); -} - -int -cloudabi_sys_mem_sync(struct thread *td, struct cloudabi_sys_mem_sync_args *uap) -{ - int flags; - - /* Convert flags. */ - switch (uap->flags & (CLOUDABI_MS_ASYNC | CLOUDABI_MS_SYNC)) { - case CLOUDABI_MS_ASYNC: - flags = MS_ASYNC; - break; - case CLOUDABI_MS_SYNC: - flags = MS_SYNC; - break; - default: - return (EINVAL); - } - if ((uap->flags & CLOUDABI_MS_INVALIDATE) != 0) - flags |= MS_INVALIDATE; - - return (kern_msync(td, (uintptr_t)uap->mapping, uap->mapping_len, - flags)); -} - -int -cloudabi_sys_mem_unmap(struct thread *td, - struct cloudabi_sys_mem_unmap_args *uap) -{ - - return (kern_munmap(td, (uintptr_t)uap->mapping, uap->mapping_len)); -} diff --git a/sys/compat/cloudabi/cloudabi_proc.c b/sys/compat/cloudabi/cloudabi_proc.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_proc.c +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -int -cloudabi_sys_proc_exec(struct thread *td, - struct cloudabi_sys_proc_exec_args *uap) -{ - struct image_args args; - struct vmspace *oldvmspace; - int error; - - error = pre_execve(td, &oldvmspace); - if (error != 0) - return (error); - error = exec_copyin_data_fds(td, &args, uap->data, uap->data_len, - uap->fds, uap->fds_len); - if (error == 0) { - args.fd = uap->fd; - error = kern_execve(td, &args, NULL, oldvmspace); - } - post_execve(td, error, oldvmspace); - return (error); -} - -int -cloudabi_sys_proc_exit(struct thread *td, - struct cloudabi_sys_proc_exit_args *uap) -{ - - exit1(td, uap->rval, 0); - /* NOTREACHED */ -} - -int -cloudabi_sys_proc_fork(struct thread *td, - struct cloudabi_sys_proc_fork_args *uap) -{ - struct fork_req fr; - struct filecaps fcaps = {}; - int error, fd; - - cap_rights_init(&fcaps.fc_rights, CAP_FSTAT, CAP_EVENT); - bzero(&fr, sizeof(fr)); - fr.fr_flags = RFFDG | RFPROC | RFPROCDESC; - fr.fr_pd_fd = &fd; - fr.fr_pd_fcaps = &fcaps; - error = fork1(td, &fr); - if (error != 0) - return (error); - /* Return the file descriptor to the parent process. */ - td->td_retval[0] = fd; - return (0); -} - -int -cloudabi_sys_proc_raise(struct thread *td, - struct cloudabi_sys_proc_raise_args *uap) -{ - static const int signals[] = { - [CLOUDABI_SIGABRT] = SIGABRT, - [CLOUDABI_SIGALRM] = SIGALRM, - [CLOUDABI_SIGBUS] = SIGBUS, - [CLOUDABI_SIGCHLD] = SIGCHLD, - [CLOUDABI_SIGCONT] = SIGCONT, - [CLOUDABI_SIGFPE] = SIGFPE, - [CLOUDABI_SIGHUP] = SIGHUP, - [CLOUDABI_SIGILL] = SIGILL, - [CLOUDABI_SIGINT] = SIGINT, - [CLOUDABI_SIGKILL] = SIGKILL, - [CLOUDABI_SIGPIPE] = SIGPIPE, - [CLOUDABI_SIGQUIT] = SIGQUIT, - [CLOUDABI_SIGSEGV] = SIGSEGV, - [CLOUDABI_SIGSTOP] = SIGSTOP, - [CLOUDABI_SIGSYS] = SIGSYS, - [CLOUDABI_SIGTERM] = SIGTERM, - [CLOUDABI_SIGTRAP] = SIGTRAP, - [CLOUDABI_SIGTSTP] = SIGTSTP, - [CLOUDABI_SIGTTIN] = SIGTTIN, - [CLOUDABI_SIGTTOU] = SIGTTOU, - [CLOUDABI_SIGURG] = SIGURG, - [CLOUDABI_SIGUSR1] = SIGUSR1, - [CLOUDABI_SIGUSR2] = SIGUSR2, - [CLOUDABI_SIGVTALRM] = SIGVTALRM, - [CLOUDABI_SIGXCPU] = SIGXCPU, - [CLOUDABI_SIGXFSZ] = SIGXFSZ, - }; - ksiginfo_t ksi; - struct proc *p; - - if (uap->sig >= nitems(signals) || signals[uap->sig] == 0) { - /* Invalid signal, or the null signal. */ - return (uap->sig == 0 ? 0 : EINVAL); - } - - p = td->td_proc; - ksiginfo_init(&ksi); - ksi.ksi_signo = signals[uap->sig]; - ksi.ksi_code = SI_USER; - ksi.ksi_pid = p->p_pid; - ksi.ksi_uid = td->td_ucred->cr_ruid; - PROC_LOCK(p); - pksignal(p, ksi.ksi_signo, &ksi); - PROC_UNLOCK(p); - return (0); -} - -MODULE_VERSION(cloudabi, 1); diff --git a/sys/compat/cloudabi/cloudabi_proto.h b/sys/compat/cloudabi/cloudabi_proto.h deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_proto.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * 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$ - */ - -/* - * This should provide all prototypes for the machine-independent system - * calls. Unfortunately, we don't have a separate system call table for - * those, so rely on the system call table from COMPAT_CLOUDABI64. - */ - -#include - -#include diff --git a/sys/compat/cloudabi/cloudabi_random.c b/sys/compat/cloudabi/cloudabi_random.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_random.c +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -int -cloudabi_sys_random_get(struct thread *td, - struct cloudabi_sys_random_get_args *uap) -{ - struct iovec iov = { - .iov_base = uap->buf, - .iov_len = uap->buf_len - }; - struct uio uio = { - .uio_iov = &iov, - .uio_iovcnt = 1, - .uio_resid = iov.iov_len, - .uio_segflg = UIO_USERSPACE, - .uio_rw = UIO_READ, - .uio_td = td - }; - - return (read_random_uio(&uio, false)); -} diff --git a/sys/compat/cloudabi/cloudabi_sock.c b/sys/compat/cloudabi/cloudabi_sock.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_sock.c +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * Copyright (c) 2015-2017 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -int -cloudabi_sys_sock_shutdown(struct thread *td, - struct cloudabi_sys_sock_shutdown_args *uap) -{ - int how; - - switch (uap->how) { - case CLOUDABI_SHUT_RD: - how = SHUT_RD; - break; - case CLOUDABI_SHUT_WR: - how = SHUT_WR; - break; - case CLOUDABI_SHUT_RD | CLOUDABI_SHUT_WR: - how = SHUT_RDWR; - break; - default: - return (EINVAL); - } - - return (kern_shutdown(td, uap->sock, how)); -} - -int -cloudabi_sock_recv(struct thread *td, cloudabi_fd_t fd, struct iovec *data, - size_t datalen, cloudabi_fd_t *fds, size_t fdslen, - cloudabi_riflags_t flags, size_t *rdatalen, size_t *rfdslen, - cloudabi_roflags_t *rflags) -{ - struct msghdr hdr = { - .msg_iov = data, - .msg_iovlen = datalen, - }; - struct mbuf *control; - int error; - - /* Convert flags. */ - if (flags & CLOUDABI_SOCK_RECV_PEEK) - hdr.msg_flags |= MSG_PEEK; - if (flags & CLOUDABI_SOCK_RECV_WAITALL) - hdr.msg_flags |= MSG_WAITALL; - - control = NULL; - error = kern_recvit(td, fd, &hdr, UIO_SYSSPACE, - fdslen > 0 ? &control : NULL); - if (error != 0) - return (error); - - /* Convert return values. */ - *rdatalen = td->td_retval[0]; - td->td_retval[0] = 0; - *rfdslen = 0; - *rflags = 0; - if (hdr.msg_flags & MSG_TRUNC) - *rflags |= CLOUDABI_SOCK_RECV_DATA_TRUNCATED; - - /* Extract file descriptors from SCM_RIGHTS messages. */ - if (control != NULL) { - struct cmsghdr *chdr; - - hdr.msg_control = mtod(control, void *); - hdr.msg_controllen = control->m_len; - for (chdr = CMSG_FIRSTHDR(&hdr); chdr != NULL; - chdr = CMSG_NXTHDR(&hdr, chdr)) { - if (chdr->cmsg_level == SOL_SOCKET && - chdr->cmsg_type == SCM_RIGHTS) { - size_t nfds; - - nfds = (chdr->cmsg_len - CMSG_LEN(0)) / - sizeof(int); - if (nfds > fdslen) { - /* Unable to store file descriptors. */ - *rflags |= - CLOUDABI_SOCK_RECV_FDS_TRUNCATED; - m_dispose_extcontrolm(control); - break; - } - error = copyout(CMSG_DATA(chdr), fds, - nfds * sizeof(int)); - if (error != 0) - break; - fds += nfds; - fdslen -= nfds; - *rfdslen += nfds; - } - } - if (control != NULL) { - if (error != 0) - m_dispose_extcontrolm(control); - m_free(control); - } - } - return (error); -} - -int -cloudabi_sock_send(struct thread *td, cloudabi_fd_t fd, struct iovec *data, - size_t datalen, const cloudabi_fd_t *fds, size_t fdslen, size_t *rdatalen) -{ - struct msghdr hdr = { - .msg_iov = data, - .msg_iovlen = datalen, - }; - struct mbuf *control; - int error; - - /* Convert file descriptor array to an SCM_RIGHTS message. */ - if (fdslen > MCLBYTES || CMSG_SPACE(fdslen * sizeof(int)) > MCLBYTES) { - return (EINVAL); - } else if (fdslen > 0) { - struct cmsghdr *chdr; - - control = m_get2(CMSG_SPACE(fdslen * sizeof(int)), - M_WAITOK, MT_CONTROL, 0); - control->m_len = CMSG_SPACE(fdslen * sizeof(int)); - - chdr = mtod(control, struct cmsghdr *); - chdr->cmsg_len = CMSG_LEN(fdslen * sizeof(int)); - chdr->cmsg_level = SOL_SOCKET; - chdr->cmsg_type = SCM_RIGHTS; - error = copyin(fds, CMSG_DATA(chdr), fdslen * sizeof(int)); - if (error != 0) { - m_free(control); - return (error); - } - } else { - control = NULL; - } - - error = kern_sendit(td, fd, &hdr, MSG_NOSIGNAL, control, UIO_USERSPACE); - if (error != 0) - return (error); - *rdatalen = td->td_retval[0]; - td->td_retval[0] = 0; - return (0); -} diff --git a/sys/compat/cloudabi/cloudabi_thread.c b/sys/compat/cloudabi/cloudabi_thread.c deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_thread.c +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include - -#include - -int -cloudabi_sys_thread_exit(struct thread *td, - struct cloudabi_sys_thread_exit_args *uap) -{ - struct cloudabi_sys_lock_unlock_args cloudabi_sys_lock_unlock_args = { - .lock = uap->lock, - .scope = uap->scope, - }; - - /* Wake up joining thread. */ - cloudabi_sys_lock_unlock(td, &cloudabi_sys_lock_unlock_args); - - /* - * Attempt to terminate the thread. Terminate the process if - * it's the last thread. - */ - kern_thr_exit(td); - exit1(td, 0, 0); - /* NOTREACHED */ -} - -int -cloudabi_sys_thread_yield(struct thread *td, - struct cloudabi_sys_thread_yield_args *uap) -{ - - sched_relinquish(td); - return (0); -} diff --git a/sys/compat/cloudabi/cloudabi_util.h b/sys/compat/cloudabi/cloudabi_util.h deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_util.h +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 2015-2017 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 _CLOUDABI_UTIL_H_ -#define _CLOUDABI_UTIL_H_ - -#include - -#include - -struct file; -struct sysentvec; -struct thread; -struct timespec; - -/* Fetches the time value of a clock. */ -int cloudabi_clock_time_get(struct thread *, cloudabi_clockid_t, - cloudabi_timestamp_t *); - -/* Converts a FreeBSD errno to a CloudABI errno. */ -cloudabi_errno_t cloudabi_convert_errno(int); - -/* Converts a file descriptor to a CloudABI file descriptor type. */ -cloudabi_filetype_t cloudabi_convert_filetype(const struct file *); - -/* Converts CloudABI rights to a set of Capsicum capabilities. */ -int cloudabi_convert_rights(cloudabi_rights_t, cap_rights_t *); - -/* Removes rights that conflict with the file descriptor type. */ -void cloudabi_remove_conflicting_rights(cloudabi_filetype_t, - cloudabi_rights_t *, cloudabi_rights_t *); - -/* Converts a struct timespec to a CloudABI timestamp. */ -int cloudabi_convert_timespec(const struct timespec *, cloudabi_timestamp_t *); - -/* - * Blocking futex functions. - * - * These functions are called by CloudABI's polling system calls to - * sleep on a lock or condition variable. - */ -int cloudabi_futex_condvar_wait(struct thread *, cloudabi_condvar_t *, - cloudabi_scope_t, cloudabi_lock_t *, cloudabi_scope_t, cloudabi_clockid_t, - cloudabi_timestamp_t, cloudabi_timestamp_t, bool); -int cloudabi_futex_lock_rdlock(struct thread *, cloudabi_lock_t *, - cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, - cloudabi_timestamp_t, bool); -int cloudabi_futex_lock_wrlock(struct thread *, cloudabi_lock_t *, - cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, - cloudabi_timestamp_t, bool); - -/* Socket operations. */ -int cloudabi_sock_recv(struct thread *, cloudabi_fd_t, struct iovec *, size_t, - cloudabi_fd_t *, size_t, cloudabi_riflags_t, size_t *, size_t *, - cloudabi_roflags_t *); -int cloudabi_sock_send(struct thread *, cloudabi_fd_t, struct iovec *, size_t, - const cloudabi_fd_t *, size_t, size_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 deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_vdso.c +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -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_ZERO); - VM_OBJECT_WUNLOCK(obj); - vm_page_valid(m); - vm_page_xunbusy(m); - - 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 deleted file mode 100644 --- a/sys/compat/cloudabi/cloudabi_vdso.lds +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 deleted file mode 100644 --- a/sys/compat/cloudabi32/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ - -SYSENT_FILE= ${SYSDIR}/contrib/cloudabi/syscalls32.master -GENERATED_PREFIX= cloudabi32_ - -.include "../../conf/sysent.mk" diff --git a/sys/compat/cloudabi32/cloudabi32_fd.c b/sys/compat/cloudabi32/cloudabi32_fd.c deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_fd.c +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -/* 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.buf); - iov[i].iov_len = iovobj.buf_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->iovs, uap->iovs_len, &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->iovs), uap->iovs_len, &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->iovs, uap->iovs_len, &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->iovs), uap->iovs_len, &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 deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_module.c +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -extern char _binary_cloudabi32_vdso_o_start[]; -extern char _binary_cloudabi32_vdso_o_end[]; - -int -cloudabi32_copyout_strings(struct image_params *imgp, uintptr_t *stack_base) -{ - struct image_args *args; - uintptr_t begin; - size_t len; - - /* Copy out program arguments. */ - args = imgp->args; - len = exec_args_get_begin_envv(args) - args->begin_argv; - begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t)); - *stack_base = begin; - return (copyout(args->begin_argv, (void *)begin, len)); -} - -int -cloudabi32_fixup(uintptr_t *stack_base, struct image_params *imgp) -{ - char canarybuf[64], pidbuf[16]; - Elf32_Auxargs *args; - struct thread *td; - void *argdata, *canary, *pid; - 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; - - argdata = (void *)*stack_base; - - /* Store canary for stack smashing protection. */ - arc4rand(canarybuf, sizeof(canarybuf), 0); - *stack_base -= roundup(sizeof(canarybuf), sizeof(register_t)); - canary = (void *)*stack_base; - error = copyout(canarybuf, canary, sizeof(canarybuf)); - if (error != 0) - return (error); - - /* - * Generate a random UUID that identifies the process. Right now - * we don't store this UUID in the kernel. Ideally, it should be - * exposed through ps(1). - */ - arc4rand(pidbuf, sizeof(pidbuf), 0); - pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40; - pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80; - *stack_base -= roundup(sizeof(pidbuf), sizeof(register_t)); - pid = (void *)*stack_base; - error = copyout(pidbuf, pid, sizeof(pidbuf)); - 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 = exec_args_get_begin_envv(imgp->args) - - 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), - PTR(CLOUDABI_AT_PID, pid), - PTR(CLOUDABI_AT_SYSINFO_EHDR, - imgp->proc->p_sysent->sv_shared_page_base), - VAL(CLOUDABI_AT_TID, td->td_tid), -#undef VAL -#undef PTR - { .a_type = CLOUDABI_AT_NULL }, - }; - *stack_base -= roundup(sizeof(auxv), sizeof(register_t)); - error = copyout(auxv, (void *)*stack_base, sizeof(auxv)); - if (error != 0) - return (error); - - /* Reserve space for storing the TCB. */ - *stack_base -= roundup(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 deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_poll.c +++ /dev/null @@ -1,340 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -#include - -#include -#include - -/* 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; - cloudabi_event_t *out; -}; - -/* 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; - 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; - } - kevp->flags = EV_ADD | 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) -{ - cloudabi_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; - break; - case EVFILT_READ: - ev.type = CLOUDABI_EVENTTYPE_FD_READ; - break; - case EVFILT_WRITE: - ev.type = CLOUDABI_EVENTTYPE_FD_WRITE; - break; - case EVFILT_PROCDESC: - ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE; - 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, - }; - 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; - cloudabi_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.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, true)); - 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.error = cloudabi_convert_errno( - cloudabi_futex_lock_rdlock( - td, TO_PTR(sub.lock.lock), - sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, - UINT64_MAX, 0, true)); - 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.error = cloudabi_convert_errno( - cloudabi_futex_lock_wrlock( - td, TO_PTR(sub.lock.lock), - sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, - UINT64_MAX, 0, true)); - td->td_retval[0] = 1; - return (copyout(&ev, uap->out, sizeof(ev))); - } - } else if (uap->nsubscriptions == 2) { - cloudabi32_subscription_t sub[2]; - cloudabi_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) { - /* Wait for a condition variable with timeout. */ - 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, - (sub[1].clock.flags & - CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0); - 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) { - /* Acquire a read lock with a timeout. */ - 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, - (sub[1].clock.flags & - CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0); - 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) { - /* Acquire a write lock with a timeout. */ - 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, - (sub[1].clock.flags & - CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0); - 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, ©ops)); -} diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_proto.h +++ /dev/null @@ -1,420 +0,0 @@ -/* - * System call prototypes. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -#ifndef _CLOUDABI32_SYSPROTO_H_ -#define _CLOUDABI32_SYSPROTO_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -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 iovs_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_iovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_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 iovs_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_ciovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_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 iovs_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_iovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_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 iovs_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iovs; char iovs_r_[PADR_(const cloudabi32_ciovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 path1_len_l_[PADL_(size_t)]; size_t path1_len; char path1_len_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 path2_len_l_[PADL_(size_t)]; size_t path2_len; char path2_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_r_[PADR_(size_t)]; - char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)]; - char buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_r_[PADR_(size_t)]; -}; -struct cloudabi_sys_file_rename_args { - char fd1_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd1; char fd1_r_[PADR_(cloudabi_fd_t)]; - char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)]; - char path1_len_l_[PADL_(size_t)]; size_t path1_len; char path1_len_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 path2_len_l_[PADL_(size_t)]; size_t path2_len; char path2_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 path1_len_l_[PADL_(size_t)]; size_t path1_len; char path1_len_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 path2_len_l_[PADL_(size_t)]; size_t path2_len; char path2_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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_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 mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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 mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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_unmap_args { - char mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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_(cloudabi_event_t *)]; cloudabi_event_t * out; char out_r_[PADR_(cloudabi_event_t *)]; - char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_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 data_len_l_[PADL_(size_t)]; size_t data_len; char data_len_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 fds_len_l_[PADL_(size_t)]; size_t fds_len; char fds_len_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 buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_r_[PADR_(size_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 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_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_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *); -int cloudabi32_sys_poll(struct thread *, struct cloudabi32_sys_poll_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 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 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 */ - - -#ifdef COMPAT_FREEBSD11 - - -#endif /* COMPAT_FREEBSD11 */ - - -#ifdef COMPAT_FREEBSD12 - - -#endif /* COMPAT_FREEBSD12 */ - -#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_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_unmap AUE_NULL -#define CLOUDABI32_SYS_AUE_cloudabi32_sys_poll 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_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_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 deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_sock.c +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * Copyright (c) 2015-2017 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket"); - -int -cloudabi32_sys_sock_recv(struct thread *td, - struct cloudabi32_sys_sock_recv_args *uap) -{ - cloudabi32_recv_in_t ri; - cloudabi32_recv_out_t ro = {}; - cloudabi32_iovec_t iovobj; - struct iovec *iov; - const cloudabi32_iovec_t *user_iov; - size_t i, rdatalen, rfdslen; - int error; - - error = copyin(uap->in, &ri, sizeof(ri)); - if (error != 0) - return (error); - - /* Convert iovecs to native format. */ - if (ri.ri_data_len > UIO_MAXIOV) - return (EINVAL); - iov = mallocarray(ri.ri_data_len, sizeof(struct iovec), - M_SOCKET, M_WAITOK); - user_iov = TO_PTR(ri.ri_data); - for (i = 0; i < ri.ri_data_len; i++) { - error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); - if (error != 0) { - free(iov, M_SOCKET); - return (error); - } - iov[i].iov_base = TO_PTR(iovobj.buf); - iov[i].iov_len = iovobj.buf_len; - } - - error = cloudabi_sock_recv(td, uap->sock, iov, ri.ri_data_len, - TO_PTR(ri.ri_fds), ri.ri_fds_len, ri.ri_flags, &rdatalen, - &rfdslen, &ro.ro_flags); - free(iov, M_SOCKET); - if (error != 0) - return (error); - - ro.ro_datalen = rdatalen; - ro.ro_fdslen = rfdslen; - 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 iovec *iov; - const cloudabi32_ciovec_t *user_iov; - size_t datalen, i; - int error; - - error = copyin(uap->in, &si, sizeof(si)); - if (error != 0) - return (error); - - /* Convert iovecs to native format. */ - if (si.si_data_len > UIO_MAXIOV) - return (EINVAL); - iov = mallocarray(si.si_data_len, sizeof(struct iovec), - M_SOCKET, M_WAITOK); - user_iov = TO_PTR(si.si_data); - for (i = 0; i < si.si_data_len; i++) { - error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); - if (error != 0) { - free(iov, M_SOCKET); - return (error); - } - iov[i].iov_base = TO_PTR(iovobj.buf); - iov[i].iov_len = iovobj.buf_len; - } - - error = cloudabi_sock_send(td, uap->sock, iov, si.si_data_len, - TO_PTR(si.si_fds), si.si_fds_len, &datalen); - free(iov, M_SOCKET); - if (error != 0) - return (error); - - so.so_datalen = datalen; - return (copyout(&so, uap->out, sizeof(so))); -} diff --git a/sys/compat/cloudabi32/cloudabi32_syscall.h b/sys/compat/cloudabi32/cloudabi32_syscall.h deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_syscall.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -#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_map 33 -#define CLOUDABI32_SYS_cloudabi_sys_mem_protect 34 -#define CLOUDABI32_SYS_cloudabi_sys_mem_sync 35 -#define CLOUDABI32_SYS_cloudabi_sys_mem_unmap 36 -#define CLOUDABI32_SYS_cloudabi32_sys_poll 37 -#define CLOUDABI32_SYS_cloudabi_sys_proc_exec 38 -#define CLOUDABI32_SYS_cloudabi_sys_proc_exit 39 -#define CLOUDABI32_SYS_cloudabi_sys_proc_fork 40 -#define CLOUDABI32_SYS_cloudabi_sys_proc_raise 41 -#define CLOUDABI32_SYS_cloudabi_sys_random_get 42 -#define CLOUDABI32_SYS_cloudabi32_sys_sock_recv 43 -#define CLOUDABI32_SYS_cloudabi32_sys_sock_send 44 -#define CLOUDABI32_SYS_cloudabi_sys_sock_shutdown 45 -#define CLOUDABI32_SYS_cloudabi32_sys_thread_create 46 -#define CLOUDABI32_SYS_cloudabi_sys_thread_exit 47 -#define CLOUDABI32_SYS_cloudabi_sys_thread_yield 48 -#define CLOUDABI32_SYS_MAXSYSCALL 49 diff --git a/sys/compat/cloudabi32/cloudabi32_syscalls.c b/sys/compat/cloudabi32/cloudabi32_syscalls.c deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_syscalls.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * System call names. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -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_map", /* 33 = cloudabi_sys_mem_map */ - "cloudabi_sys_mem_protect", /* 34 = cloudabi_sys_mem_protect */ - "cloudabi_sys_mem_sync", /* 35 = cloudabi_sys_mem_sync */ - "cloudabi_sys_mem_unmap", /* 36 = cloudabi_sys_mem_unmap */ - "cloudabi32_sys_poll", /* 37 = cloudabi32_sys_poll */ - "cloudabi_sys_proc_exec", /* 38 = cloudabi_sys_proc_exec */ - "cloudabi_sys_proc_exit", /* 39 = cloudabi_sys_proc_exit */ - "cloudabi_sys_proc_fork", /* 40 = cloudabi_sys_proc_fork */ - "cloudabi_sys_proc_raise", /* 41 = cloudabi_sys_proc_raise */ - "cloudabi_sys_random_get", /* 42 = cloudabi_sys_random_get */ - "cloudabi32_sys_sock_recv", /* 43 = cloudabi32_sys_sock_recv */ - "cloudabi32_sys_sock_send", /* 44 = cloudabi32_sys_sock_send */ - "cloudabi_sys_sock_shutdown", /* 45 = cloudabi_sys_sock_shutdown */ - "cloudabi32_sys_thread_create", /* 46 = cloudabi32_sys_thread_create */ - "cloudabi_sys_thread_exit", /* 47 = cloudabi_sys_thread_exit */ - "cloudabi_sys_thread_yield", /* 48 = cloudabi_sys_thread_yield */ -}; diff --git a/sys/compat/cloudabi32/cloudabi32_sysent.c b/sys/compat/cloudabi32/cloudabi32_sysent.c deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_sysent.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#define AS(name) (sizeof(struct name) / sizeof(register_t)) - -/* The casts are bogus but will do for now. */ -struct sysent cloudabi32_sysent[] = { - { .sy_narg = AS(cloudabi_sys_clock_res_get_args), .sy_call = (sy_call_t *)cloudabi_sys_clock_res_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 0 = cloudabi_sys_clock_res_get */ - { .sy_narg = AS(cloudabi_sys_clock_time_get_args), .sy_call = (sy_call_t *)cloudabi_sys_clock_time_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 1 = cloudabi_sys_clock_time_get */ - { .sy_narg = AS(cloudabi_sys_condvar_signal_args), .sy_call = (sy_call_t *)cloudabi_sys_condvar_signal, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 2 = cloudabi_sys_condvar_signal */ - { .sy_narg = AS(cloudabi_sys_fd_close_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_close, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 3 = cloudabi_sys_fd_close */ - { .sy_narg = AS(cloudabi_sys_fd_create1_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_create1, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 4 = cloudabi_sys_fd_create1 */ - { .sy_narg = AS(cloudabi_sys_fd_create2_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_create2, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 5 = cloudabi_sys_fd_create2 */ - { .sy_narg = AS(cloudabi_sys_fd_datasync_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_datasync, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 6 = cloudabi_sys_fd_datasync */ - { .sy_narg = AS(cloudabi_sys_fd_dup_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_dup, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 7 = cloudabi_sys_fd_dup */ - { .sy_narg = AS(cloudabi32_sys_fd_pread_args), .sy_call = (sy_call_t *)cloudabi32_sys_fd_pread, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 8 = cloudabi32_sys_fd_pread */ - { .sy_narg = AS(cloudabi32_sys_fd_pwrite_args), .sy_call = (sy_call_t *)cloudabi32_sys_fd_pwrite, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 9 = cloudabi32_sys_fd_pwrite */ - { .sy_narg = AS(cloudabi32_sys_fd_read_args), .sy_call = (sy_call_t *)cloudabi32_sys_fd_read, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 10 = cloudabi32_sys_fd_read */ - { .sy_narg = AS(cloudabi_sys_fd_replace_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_replace, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 11 = cloudabi_sys_fd_replace */ - { .sy_narg = AS(cloudabi_sys_fd_seek_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_seek, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 12 = cloudabi_sys_fd_seek */ - { .sy_narg = AS(cloudabi_sys_fd_stat_get_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_stat_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 13 = cloudabi_sys_fd_stat_get */ - { .sy_narg = AS(cloudabi_sys_fd_stat_put_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_stat_put, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 14 = cloudabi_sys_fd_stat_put */ - { .sy_narg = AS(cloudabi_sys_fd_sync_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_sync, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 15 = cloudabi_sys_fd_sync */ - { .sy_narg = AS(cloudabi32_sys_fd_write_args), .sy_call = (sy_call_t *)cloudabi32_sys_fd_write, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 16 = cloudabi32_sys_fd_write */ - { .sy_narg = AS(cloudabi_sys_file_advise_args), .sy_call = (sy_call_t *)cloudabi_sys_file_advise, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 17 = cloudabi_sys_file_advise */ - { .sy_narg = AS(cloudabi_sys_file_allocate_args), .sy_call = (sy_call_t *)cloudabi_sys_file_allocate, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 18 = cloudabi_sys_file_allocate */ - { .sy_narg = AS(cloudabi_sys_file_create_args), .sy_call = (sy_call_t *)cloudabi_sys_file_create, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 19 = cloudabi_sys_file_create */ - { .sy_narg = AS(cloudabi_sys_file_link_args), .sy_call = (sy_call_t *)cloudabi_sys_file_link, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 20 = cloudabi_sys_file_link */ - { .sy_narg = AS(cloudabi_sys_file_open_args), .sy_call = (sy_call_t *)cloudabi_sys_file_open, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 21 = cloudabi_sys_file_open */ - { .sy_narg = AS(cloudabi_sys_file_readdir_args), .sy_call = (sy_call_t *)cloudabi_sys_file_readdir, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 22 = cloudabi_sys_file_readdir */ - { .sy_narg = AS(cloudabi_sys_file_readlink_args), .sy_call = (sy_call_t *)cloudabi_sys_file_readlink, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 23 = cloudabi_sys_file_readlink */ - { .sy_narg = AS(cloudabi_sys_file_rename_args), .sy_call = (sy_call_t *)cloudabi_sys_file_rename, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 24 = cloudabi_sys_file_rename */ - { .sy_narg = AS(cloudabi_sys_file_stat_fget_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_fget, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 25 = cloudabi_sys_file_stat_fget */ - { .sy_narg = AS(cloudabi_sys_file_stat_fput_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_fput, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 26 = cloudabi_sys_file_stat_fput */ - { .sy_narg = AS(cloudabi_sys_file_stat_get_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 27 = cloudabi_sys_file_stat_get */ - { .sy_narg = AS(cloudabi_sys_file_stat_put_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_put, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 28 = cloudabi_sys_file_stat_put */ - { .sy_narg = AS(cloudabi_sys_file_symlink_args), .sy_call = (sy_call_t *)cloudabi_sys_file_symlink, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 29 = cloudabi_sys_file_symlink */ - { .sy_narg = AS(cloudabi_sys_file_unlink_args), .sy_call = (sy_call_t *)cloudabi_sys_file_unlink, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 30 = cloudabi_sys_file_unlink */ - { .sy_narg = AS(cloudabi_sys_lock_unlock_args), .sy_call = (sy_call_t *)cloudabi_sys_lock_unlock, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 31 = cloudabi_sys_lock_unlock */ - { .sy_narg = AS(cloudabi_sys_mem_advise_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_advise, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 32 = cloudabi_sys_mem_advise */ - { .sy_narg = AS(cloudabi_sys_mem_map_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_map, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 33 = cloudabi_sys_mem_map */ - { .sy_narg = AS(cloudabi_sys_mem_protect_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_protect, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 34 = cloudabi_sys_mem_protect */ - { .sy_narg = AS(cloudabi_sys_mem_sync_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_sync, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 35 = cloudabi_sys_mem_sync */ - { .sy_narg = AS(cloudabi_sys_mem_unmap_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_unmap, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 36 = cloudabi_sys_mem_unmap */ - { .sy_narg = AS(cloudabi32_sys_poll_args), .sy_call = (sy_call_t *)cloudabi32_sys_poll, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 37 = cloudabi32_sys_poll */ - { .sy_narg = AS(cloudabi_sys_proc_exec_args), .sy_call = (sy_call_t *)cloudabi_sys_proc_exec, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 38 = cloudabi_sys_proc_exec */ - { .sy_narg = AS(cloudabi_sys_proc_exit_args), .sy_call = (sy_call_t *)cloudabi_sys_proc_exit, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 39 = cloudabi_sys_proc_exit */ - { .sy_narg = 0, .sy_call = (sy_call_t *)cloudabi_sys_proc_fork, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 40 = cloudabi_sys_proc_fork */ - { .sy_narg = AS(cloudabi_sys_proc_raise_args), .sy_call = (sy_call_t *)cloudabi_sys_proc_raise, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_raise */ - { .sy_narg = AS(cloudabi_sys_random_get_args), .sy_call = (sy_call_t *)cloudabi_sys_random_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 42 = cloudabi_sys_random_get */ - { .sy_narg = AS(cloudabi32_sys_sock_recv_args), .sy_call = (sy_call_t *)cloudabi32_sys_sock_recv, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 43 = cloudabi32_sys_sock_recv */ - { .sy_narg = AS(cloudabi32_sys_sock_send_args), .sy_call = (sy_call_t *)cloudabi32_sys_sock_send, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 44 = cloudabi32_sys_sock_send */ - { .sy_narg = AS(cloudabi_sys_sock_shutdown_args), .sy_call = (sy_call_t *)cloudabi_sys_sock_shutdown, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 45 = cloudabi_sys_sock_shutdown */ - { .sy_narg = AS(cloudabi32_sys_thread_create_args), .sy_call = (sy_call_t *)cloudabi32_sys_thread_create, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 46 = cloudabi32_sys_thread_create */ - { .sy_narg = AS(cloudabi_sys_thread_exit_args), .sy_call = (sy_call_t *)cloudabi_sys_thread_exit, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 47 = cloudabi_sys_thread_exit */ - { .sy_narg = 0, .sy_call = (sy_call_t *)cloudabi_sys_thread_yield, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 48 = cloudabi_sys_thread_yield */ -}; diff --git a/sys/compat/cloudabi32/cloudabi32_systrace_args.c b/sys/compat/cloudabi32/cloudabi32_systrace_args.c deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_systrace_args.c +++ /dev/null @@ -1,1458 +0,0 @@ -/* - * 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->iovs; /* const cloudabi32_iovec_t * */ - uarg[2] = p->iovs_len; /* 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->iovs; /* const cloudabi32_ciovec_t * */ - uarg[2] = p->iovs_len; /* 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->iovs; /* const cloudabi32_iovec_t * */ - uarg[2] = p->iovs_len; /* 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->iovs; /* const cloudabi32_ciovec_t * */ - uarg[2] = p->iovs_len; /* 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->path_len; /* 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->path1_len; /* size_t */ - iarg[3] = p->fd2; /* cloudabi_fd_t */ - uarg[4] = (intptr_t)p->path2; /* const char * */ - uarg[5] = p->path2_len; /* 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->path_len; /* 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->buf_len; /* 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->path_len; /* size_t */ - uarg[3] = (intptr_t)p->buf; /* char * */ - uarg[4] = p->buf_len; /* size_t */ - *n_args = 5; - break; - } - /* cloudabi_sys_file_rename */ - case 24: { - struct cloudabi_sys_file_rename_args *p = params; - iarg[0] = p->fd1; /* cloudabi_fd_t */ - uarg[1] = (intptr_t)p->path1; /* const char * */ - uarg[2] = p->path1_len; /* size_t */ - iarg[3] = p->fd2; /* cloudabi_fd_t */ - uarg[4] = (intptr_t)p->path2; /* const char * */ - uarg[5] = p->path2_len; /* 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->path_len; /* 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->path_len; /* 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->path1_len; /* size_t */ - iarg[2] = p->fd; /* cloudabi_fd_t */ - uarg[3] = (intptr_t)p->path2; /* const char * */ - uarg[4] = p->path2_len; /* 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->path_len; /* 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->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - iarg[2] = p->advice; /* cloudabi_advice_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_mem_map */ - case 33: { - 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 34: { - struct cloudabi_sys_mem_protect_args *p = params; - uarg[0] = (intptr_t)p->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - iarg[2] = p->prot; /* cloudabi_mprot_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_mem_sync */ - case 35: { - struct cloudabi_sys_mem_sync_args *p = params; - uarg[0] = (intptr_t)p->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - iarg[2] = p->flags; /* cloudabi_msflags_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_mem_unmap */ - case 36: { - struct cloudabi_sys_mem_unmap_args *p = params; - uarg[0] = (intptr_t)p->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - *n_args = 2; - break; - } - /* cloudabi32_sys_poll */ - case 37: { - struct cloudabi32_sys_poll_args *p = params; - uarg[0] = (intptr_t)p->in; /* const cloudabi32_subscription_t * */ - uarg[1] = (intptr_t)p->out; /* cloudabi_event_t * */ - uarg[2] = p->nsubscriptions; /* size_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_proc_exec */ - case 38: { - 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->data_len; /* size_t */ - uarg[3] = (intptr_t)p->fds; /* const cloudabi_fd_t * */ - uarg[4] = p->fds_len; /* size_t */ - *n_args = 5; - break; - } - /* cloudabi_sys_proc_exit */ - case 39: { - struct cloudabi_sys_proc_exit_args *p = params; - iarg[0] = p->rval; /* cloudabi_exitcode_t */ - *n_args = 1; - break; - } - /* cloudabi_sys_proc_fork */ - case 40: { - *n_args = 0; - break; - } - /* cloudabi_sys_proc_raise */ - case 41: { - struct cloudabi_sys_proc_raise_args *p = params; - iarg[0] = p->sig; /* cloudabi_signal_t */ - *n_args = 1; - break; - } - /* cloudabi_sys_random_get */ - case 42: { - struct cloudabi_sys_random_get_args *p = params; - uarg[0] = (intptr_t)p->buf; /* void * */ - uarg[1] = p->buf_len; /* size_t */ - *n_args = 2; - break; - } - /* cloudabi32_sys_sock_recv */ - case 43: { - 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 44: { - 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 45: { - 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; - } - /* cloudabi32_sys_thread_create */ - case 46: { - 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 47: { - 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 48: { - *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 = "userland 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 = "userland 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 = "userland 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 = "userland 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 = "userland 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 = "userland 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 = "userland 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 = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_fd_t"; - break; - case 4: - p = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_oflags_t"; - break; - case 4: - p = "userland 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 = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_fd_t"; - break; - case 4: - p = "userland 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 = "userland 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 = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland 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 = "userland const char *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_fd_t"; - break; - case 3: - p = "userland 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 = "userland 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 = "userland 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 = "userland void *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_advice_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_mem_map */ - case 33: - switch (ndx) { - case 0: - p = "userland 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 34: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_mprot_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_mem_sync */ - case 35: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_msflags_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_mem_unmap */ - case 36: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi32_sys_poll */ - case 37: - switch (ndx) { - case 0: - p = "userland const cloudabi32_subscription_t *"; - break; - case 1: - p = "userland cloudabi_event_t *"; - break; - case 2: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_proc_exec */ - case 38: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const void *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland const cloudabi_fd_t *"; - break; - case 4: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_proc_exit */ - case 39: - switch (ndx) { - case 0: - p = "cloudabi_exitcode_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_proc_fork */ - case 40: - break; - /* cloudabi_sys_proc_raise */ - case 41: - switch (ndx) { - case 0: - p = "cloudabi_signal_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_random_get */ - case 42: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi32_sys_sock_recv */ - case 43: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi32_recv_in_t *"; - break; - case 2: - p = "userland cloudabi32_recv_out_t *"; - break; - default: - break; - }; - break; - /* cloudabi32_sys_sock_send */ - case 44: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi32_send_in_t *"; - break; - case 2: - p = "userland cloudabi32_send_out_t *"; - break; - default: - break; - }; - break; - /* cloudabi_sys_sock_shutdown */ - case 45: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "cloudabi_sdflags_t"; - break; - default: - break; - }; - break; - /* cloudabi32_sys_thread_create */ - case 46: - switch (ndx) { - case 0: - p = "userland cloudabi32_threadattr_t *"; - break; - default: - break; - }; - break; - /* cloudabi_sys_thread_exit */ - case 47: - switch (ndx) { - case 0: - p = "userland cloudabi_lock_t *"; - break; - case 1: - p = "cloudabi_scope_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_thread_yield */ - case 48: - 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_map */ - case 33: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_mem_protect */ - case 34: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_mem_sync */ - case 35: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_mem_unmap */ - case 36: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi32_sys_poll */ - case 37: - if (ndx == 0 || ndx == 1) - p = "size_t"; - break; - /* cloudabi_sys_proc_exec */ - case 38: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_proc_exit */ - case 39: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_proc_fork */ - case 40: - /* cloudabi_sys_proc_raise */ - case 41: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_random_get */ - case 42: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi32_sys_sock_recv */ - case 43: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi32_sys_sock_send */ - case 44: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_sock_shutdown */ - case 45: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi32_sys_thread_create */ - case 46: - if (ndx == 0 || ndx == 1) - p = "cloudabi_tid_t"; - break; - /* cloudabi_sys_thread_exit */ - case 47: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_thread_yield */ - case 48: - 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 deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_thread.c +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -#include -#include - -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_len - - sizeof(cloudabi32_tcb_t), _Alignof(cloudabi32_tcb_t)); - args.attr.stack_len = 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 deleted file mode 100644 --- a/sys/compat/cloudabi32/cloudabi32_util.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * 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 -#define __ELF_WORD_SIZE 32 -#include - -#include - -struct image_params; -struct thread; - -extern Elf32_Brandinfo cloudabi32_brand; - -#define TO_PTR(x) ((void *)(uintptr_t)(x)) - -/* Stack initialization during process execution. */ -int cloudabi32_copyout_strings(struct image_params *, uintptr_t *); -int cloudabi32_fixup(uintptr_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 deleted file mode 100644 --- a/sys/compat/cloudabi32/syscalls.conf +++ /dev/null @@ -1,15 +0,0 @@ -# $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 deleted file mode 100644 --- a/sys/compat/cloudabi64/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $FreeBSD$ - -SYSENT_FILE= ${SYSDIR}/contrib/cloudabi/syscalls64.master -GENERATED_PREFIX= cloudabi64_ - -.include "../../conf/sysent.mk" diff --git a/sys/compat/cloudabi64/cloudabi64_fd.c b/sys/compat/cloudabi64/cloudabi64_fd.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_fd.c +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -/* Copies in 64-bit iovec structures from userspace. */ -static int -cloudabi64_copyinuio(const cloudabi64_iovec_t *iovp, size_t iovcnt, - struct uio **uiop) -{ - cloudabi64_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.buf); - iov[i].iov_len = iovobj.buf_len; - if (iov[i].iov_len > INT64_MAX - uio->uio_resid) { - free(uio, M_IOV); - return (EINVAL); - } - uio->uio_resid += iov[i].iov_len; - } - - *uiop = uio; - return (0); -} - -int -cloudabi64_sys_fd_pread(struct thread *td, - struct cloudabi64_sys_fd_pread_args *uap) -{ - struct uio *uio; - int error; - - error = cloudabi64_copyinuio(uap->iovs, uap->iovs_len, &uio); - if (error != 0) - return (error); - error = kern_preadv(td, uap->fd, uio, uap->offset); - free(uio, M_IOV); - return (error); -} - -int -cloudabi64_sys_fd_pwrite(struct thread *td, - struct cloudabi64_sys_fd_pwrite_args *uap) -{ - struct uio *uio; - int error; - - error = cloudabi64_copyinuio(TO_PTR(uap->iovs), uap->iovs_len, &uio); - if (error != 0) - return (error); - error = kern_pwritev(td, uap->fd, uio, uap->offset); - free(uio, M_IOV); - return (error); -} - -int -cloudabi64_sys_fd_read(struct thread *td, - struct cloudabi64_sys_fd_read_args *uap) -{ - struct uio *uio; - int error; - - error = cloudabi64_copyinuio(uap->iovs, uap->iovs_len, &uio); - if (error != 0) - return (error); - error = kern_readv(td, uap->fd, uio); - free(uio, M_IOV); - return (error); -} - -int -cloudabi64_sys_fd_write(struct thread *td, - struct cloudabi64_sys_fd_write_args *uap) -{ - struct uio *uio; - int error; - - error = cloudabi64_copyinuio(TO_PTR(uap->iovs), uap->iovs_len, &uio); - if (error != 0) - return (error); - error = kern_writev(td, uap->fd, uio); - free(uio, M_IOV); - return (error); -} diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_module.c +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -extern char _binary_cloudabi64_vdso_o_start[]; -extern char _binary_cloudabi64_vdso_o_end[]; - -int -cloudabi64_copyout_strings(struct image_params *imgp, uintptr_t *stack_base) -{ - struct image_args *args; - uintptr_t begin; - size_t len; - - /* Copy out program arguments. */ - args = imgp->args; - len = exec_args_get_begin_envv(args) - args->begin_argv; - begin = rounddown2(imgp->sysent->sv_usrstack - len, sizeof(register_t)); - *stack_base = begin; - return (copyout(args->begin_argv, (void *)begin, len)); -} - -int -cloudabi64_fixup(uintptr_t *stack_base, struct image_params *imgp) -{ - char canarybuf[64], pidbuf[16]; - Elf64_Auxargs *args; - struct thread *td; - void *argdata, *canary, *pid; - 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; - - argdata = (void *)*stack_base; - - /* Store canary for stack smashing protection. */ - arc4rand(canarybuf, sizeof(canarybuf), 0); - *stack_base -= roundup(sizeof(canarybuf), sizeof(register_t)); - canary = (void *)*stack_base; - error = copyout(canarybuf, canary, sizeof(canarybuf)); - if (error != 0) - return (error); - - /* - * Generate a random UUID that identifies the process. Right now - * we don't store this UUID in the kernel. Ideally, it should be - * exposed through ps(1). - */ - arc4rand(pidbuf, sizeof(pidbuf), 0); - pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40; - pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80; - *stack_base -= roundup(sizeof(pidbuf), sizeof(register_t)); - pid = (void *)*stack_base; - error = copyout(pidbuf, pid, sizeof(pidbuf)); - 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 = (Elf64_Auxargs *)imgp->auxargs; - argdatalen = exec_args_get_begin_envv(imgp->args) - - imgp->args->begin_argv; - if (argdatalen > 0) - --argdatalen; - - /* Write out an auxiliary vector. */ - cloudabi64_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), - PTR(CLOUDABI_AT_PID, pid), - PTR(CLOUDABI_AT_SYSINFO_EHDR, - imgp->proc->p_sysent->sv_shared_page_base), - VAL(CLOUDABI_AT_TID, td->td_tid), -#undef VAL -#undef PTR - { .a_type = CLOUDABI_AT_NULL }, - }; - *stack_base -= roundup(sizeof(auxv), sizeof(register_t)); - error = copyout(auxv, (void *)*stack_base, sizeof(auxv)); - if (error != 0) - return (error); - - /* Reserve space for storing the TCB. */ - *stack_base -= roundup(sizeof(cloudabi64_tcb_t), sizeof(register_t)); - return (0); -} - -static int -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); - } - return (0); - case MOD_UNLOAD: - if (elf64_brand_inuse(&cloudabi64_brand)) - return (EBUSY); - if (elf64_remove_brand_entry(&cloudabi64_brand) < 0) { - printf("Failed to remove CloudABI ELF brand handler\n"); - return (EINVAL); - } - cloudabi_vdso_destroy(cloudabi64_brand.sysvec); - return (0); - default: - return (EOPNOTSUPP); - } -} - -static moduledata_t cloudabi64_module = { - "cloudabi64", - cloudabi64_modevent, - NULL -}; - -DECLARE_MODULE_TIED(cloudabi64, cloudabi64_module, SI_SUB_EXEC, SI_ORDER_ANY); -MODULE_DEPEND(cloudabi64, cloudabi, 1, 1, 1); -FEATURE(cloudabi64, "CloudABI 64bit support"); diff --git a/sys/compat/cloudabi64/cloudabi64_poll.c b/sys/compat/cloudabi64/cloudabi64_poll.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_poll.c +++ /dev/null @@ -1,340 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -#include - -#include -#include - -/* 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 cloudabi64_kevent_args { - const cloudabi64_subscription_t *in; - cloudabi_event_t *out; -}; - -/* Converts CloudABI's subscription objects to FreeBSD's struct kevent. */ -static int -cloudabi64_kevent_copyin(void *arg, struct kevent *kevp, int count) -{ - cloudabi64_subscription_t sub; - struct cloudabi64_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; - 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; - } - kevp->flags = EV_ADD | EV_ONESHOT; - ++kevp; - } - return (0); -} - -/* Converts FreeBSD's struct kevent to CloudABI's event objects. */ -static int -cloudabi64_kevent_copyout(void *arg, struct kevent *kevp, int count) -{ - cloudabi_event_t ev; - struct cloudabi64_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; - break; - case EVFILT_READ: - ev.type = CLOUDABI_EVENTTYPE_FD_READ; - break; - case EVFILT_WRITE: - ev.type = CLOUDABI_EVENTTYPE_FD_WRITE; - break; - case EVFILT_PROCDESC: - ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE; - 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 -cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap) -{ - struct cloudabi64_kevent_args args = { - .in = uap->in, - .out = uap->out, - }; - struct kevent_copyops copyops = { - .k_copyin = cloudabi64_kevent_copyin, - .k_copyout = cloudabi64_kevent_copyout, - .arg = &args, - }; - - /* - * Bandaid to support CloudABI futex constructs that are not - * implemented through FreeBSD's kqueue(). - */ - if (uap->nsubscriptions == 1) { - cloudabi64_subscription_t sub; - cloudabi_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.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, true)); - 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.error = cloudabi_convert_errno( - cloudabi_futex_lock_rdlock( - td, TO_PTR(sub.lock.lock), - sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, - UINT64_MAX, 0, true)); - 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.error = cloudabi_convert_errno( - cloudabi_futex_lock_wrlock( - td, TO_PTR(sub.lock.lock), - sub.lock.lock_scope, CLOUDABI_CLOCK_MONOTONIC, - UINT64_MAX, 0, true)); - td->td_retval[0] = 1; - return (copyout(&ev, uap->out, sizeof(ev))); - } - } else if (uap->nsubscriptions == 2) { - cloudabi64_subscription_t sub[2]; - cloudabi_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) { - /* Wait for a condition variable with timeout. */ - 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, - (sub[1].clock.flags & - CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0); - 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) { - /* Acquire a read lock with a timeout. */ - 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, - (sub[1].clock.flags & - CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0); - 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) { - /* Acquire a write lock with a timeout. */ - 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, - (sub[1].clock.flags & - CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) != 0); - 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, ©ops)); -} diff --git a/sys/compat/cloudabi64/cloudabi64_proto.h b/sys/compat/cloudabi64/cloudabi64_proto.h deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_proto.h +++ /dev/null @@ -1,420 +0,0 @@ -/* - * System call prototypes. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -#ifndef _CLOUDABI64_SYSPROTO_H_ -#define _CLOUDABI64_SYSPROTO_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -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 cloudabi64_sys_fd_pread_args { - char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char iovs_l_[PADL_(const cloudabi64_iovec_t *)]; const cloudabi64_iovec_t * iovs; char iovs_r_[PADR_(const cloudabi64_iovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_r_[PADR_(size_t)]; - char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; -}; -struct cloudabi64_sys_fd_pwrite_args { - char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char iovs_l_[PADL_(const cloudabi64_ciovec_t *)]; const cloudabi64_ciovec_t * iovs; char iovs_r_[PADR_(const cloudabi64_ciovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_r_[PADR_(size_t)]; - char offset_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t offset; char offset_r_[PADR_(cloudabi_filesize_t)]; -}; -struct cloudabi64_sys_fd_read_args { - char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char iovs_l_[PADL_(const cloudabi64_iovec_t *)]; const cloudabi64_iovec_t * iovs; char iovs_r_[PADR_(const cloudabi64_iovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_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 cloudabi64_sys_fd_write_args { - char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char iovs_l_[PADL_(const cloudabi64_ciovec_t *)]; const cloudabi64_ciovec_t * iovs; char iovs_r_[PADR_(const cloudabi64_ciovec_t *)]; - char iovs_len_l_[PADL_(size_t)]; size_t iovs_len; char iovs_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 path1_len_l_[PADL_(size_t)]; size_t path1_len; char path1_len_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 path2_len_l_[PADL_(size_t)]; size_t path2_len; char path2_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_r_[PADR_(size_t)]; - char buf_l_[PADL_(char *)]; char * buf; char buf_r_[PADR_(char *)]; - char buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_r_[PADR_(size_t)]; -}; -struct cloudabi_sys_file_rename_args { - char fd1_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd1; char fd1_r_[PADR_(cloudabi_fd_t)]; - char path1_l_[PADL_(const char *)]; const char * path1; char path1_r_[PADR_(const char *)]; - char path1_len_l_[PADL_(size_t)]; size_t path1_len; char path1_len_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 path2_len_l_[PADL_(size_t)]; size_t path2_len; char path2_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 path1_len_l_[PADL_(size_t)]; size_t path1_len; char path1_len_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 path2_len_l_[PADL_(size_t)]; size_t path2_len; char path2_len_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 path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_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 mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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_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 mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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 mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_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_unmap_args { - char mapping_l_[PADL_(void *)]; void * mapping; char mapping_r_[PADR_(void *)]; - char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_len_r_[PADR_(size_t)]; -}; -struct cloudabi64_sys_poll_args { - char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)]; - char out_l_[PADL_(cloudabi_event_t *)]; cloudabi_event_t * out; char out_r_[PADR_(cloudabi_event_t *)]; - char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_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 data_len_l_[PADL_(size_t)]; size_t data_len; char data_len_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 fds_len_l_[PADL_(size_t)]; size_t fds_len; char fds_len_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 buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_r_[PADR_(size_t)]; -}; -struct cloudabi64_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 cloudabi64_recv_in_t *)]; const cloudabi64_recv_in_t * in; char in_r_[PADR_(const cloudabi64_recv_in_t *)]; - char out_l_[PADL_(cloudabi64_recv_out_t *)]; cloudabi64_recv_out_t * out; char out_r_[PADR_(cloudabi64_recv_out_t *)]; -}; -struct cloudabi64_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 cloudabi64_send_in_t *)]; const cloudabi64_send_in_t * in; char in_r_[PADR_(const cloudabi64_send_in_t *)]; - char out_l_[PADL_(cloudabi64_send_out_t *)]; cloudabi64_send_out_t * out; char out_r_[PADR_(cloudabi64_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 cloudabi64_sys_thread_create_args { - char attr_l_[PADL_(cloudabi64_threadattr_t *)]; cloudabi64_threadattr_t * attr; char attr_r_[PADR_(cloudabi64_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 cloudabi64_sys_fd_pread(struct thread *, struct cloudabi64_sys_fd_pread_args *); -int cloudabi64_sys_fd_pwrite(struct thread *, struct cloudabi64_sys_fd_pwrite_args *); -int cloudabi64_sys_fd_read(struct thread *, struct cloudabi64_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 cloudabi64_sys_fd_write(struct thread *, struct cloudabi64_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_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_unmap(struct thread *, struct cloudabi_sys_mem_unmap_args *); -int cloudabi64_sys_poll(struct thread *, struct cloudabi64_sys_poll_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 cloudabi64_sys_sock_recv(struct thread *, struct cloudabi64_sys_sock_recv_args *); -int cloudabi64_sys_sock_send(struct thread *, struct cloudabi64_sys_sock_send_args *); -int cloudabi_sys_sock_shutdown(struct thread *, struct cloudabi_sys_sock_shutdown_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_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 */ - - -#ifdef COMPAT_FREEBSD11 - - -#endif /* COMPAT_FREEBSD11 */ - - -#ifdef COMPAT_FREEBSD12 - - -#endif /* COMPAT_FREEBSD12 */ - -#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 -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_close AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_create1 AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_create2 AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_datasync AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_dup AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_fd_pread AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_fd_pwrite AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_fd_read AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_replace AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_seek AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_stat_get AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_stat_put AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_fd_sync AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_fd_write AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_advise AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_allocate AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_create AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_link AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_open AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_readdir AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_readlink AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_rename AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_stat_fget AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_stat_fput AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_stat_get AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_stat_put AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_symlink AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_file_unlink AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_lock_unlock AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_advise AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_map AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_protect AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_mem_sync 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_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 -#define CLOUDABI64_SYS_AUE_cloudabi_sys_proc_raise AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_random_get AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_sock_recv AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi64_sys_sock_send AUE_NULL -#define CLOUDABI64_SYS_AUE_cloudabi_sys_sock_shutdown 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_yield AUE_NULL - -#undef PAD_ -#undef PADL_ -#undef PADR_ - -#endif /* !_CLOUDABI64_SYSPROTO_H_ */ diff --git a/sys/compat/cloudabi64/cloudabi64_sock.c b/sys/compat/cloudabi64/cloudabi64_sock.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_sock.c +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * Copyright (c) 2015-2017 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket"); - -int -cloudabi64_sys_sock_recv(struct thread *td, - struct cloudabi64_sys_sock_recv_args *uap) -{ - cloudabi64_recv_in_t ri; - cloudabi64_recv_out_t ro = {}; - cloudabi64_iovec_t iovobj; - struct iovec *iov; - const cloudabi64_iovec_t *user_iov; - size_t i, rdatalen, rfdslen; - int error; - - error = copyin(uap->in, &ri, sizeof(ri)); - if (error != 0) - return (error); - - /* Convert iovecs to native format. */ - if (ri.ri_data_len > UIO_MAXIOV) - return (EINVAL); - iov = mallocarray(ri.ri_data_len, sizeof(struct iovec), - M_SOCKET, M_WAITOK); - user_iov = TO_PTR(ri.ri_data); - for (i = 0; i < ri.ri_data_len; i++) { - error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); - if (error != 0) { - free(iov, M_SOCKET); - return (error); - } - iov[i].iov_base = TO_PTR(iovobj.buf); - iov[i].iov_len = iovobj.buf_len; - } - - error = cloudabi_sock_recv(td, uap->sock, iov, ri.ri_data_len, - TO_PTR(ri.ri_fds), ri.ri_fds_len, ri.ri_flags, &rdatalen, - &rfdslen, &ro.ro_flags); - free(iov, M_SOCKET); - if (error != 0) - return (error); - - ro.ro_datalen = rdatalen; - ro.ro_fdslen = rfdslen; - return (copyout(&ro, uap->out, sizeof(ro))); -} - -int -cloudabi64_sys_sock_send(struct thread *td, - struct cloudabi64_sys_sock_send_args *uap) -{ - cloudabi64_send_in_t si; - cloudabi64_send_out_t so = {}; - cloudabi64_ciovec_t iovobj; - struct iovec *iov; - const cloudabi64_ciovec_t *user_iov; - size_t datalen, i; - int error; - - error = copyin(uap->in, &si, sizeof(si)); - if (error != 0) - return (error); - - /* Convert iovecs to native format. */ - if (si.si_data_len > UIO_MAXIOV) - return (EINVAL); - iov = mallocarray(si.si_data_len, sizeof(struct iovec), - M_SOCKET, M_WAITOK); - user_iov = TO_PTR(si.si_data); - for (i = 0; i < si.si_data_len; i++) { - error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); - if (error != 0) { - free(iov, M_SOCKET); - return (error); - } - iov[i].iov_base = TO_PTR(iovobj.buf); - iov[i].iov_len = iovobj.buf_len; - } - - error = cloudabi_sock_send(td, uap->sock, iov, si.si_data_len, - TO_PTR(si.si_fds), si.si_fds_len, &datalen); - free(iov, M_SOCKET); - if (error != 0) - return (error); - - so.so_datalen = datalen; - return (copyout(&so, uap->out, sizeof(so))); -} diff --git a/sys/compat/cloudabi64/cloudabi64_syscall.h b/sys/compat/cloudabi64/cloudabi64_syscall.h deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_syscall.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -#define CLOUDABI64_SYS_cloudabi_sys_clock_res_get 0 -#define CLOUDABI64_SYS_cloudabi_sys_clock_time_get 1 -#define CLOUDABI64_SYS_cloudabi_sys_condvar_signal 2 -#define CLOUDABI64_SYS_cloudabi_sys_fd_close 3 -#define CLOUDABI64_SYS_cloudabi_sys_fd_create1 4 -#define CLOUDABI64_SYS_cloudabi_sys_fd_create2 5 -#define CLOUDABI64_SYS_cloudabi_sys_fd_datasync 6 -#define CLOUDABI64_SYS_cloudabi_sys_fd_dup 7 -#define CLOUDABI64_SYS_cloudabi64_sys_fd_pread 8 -#define CLOUDABI64_SYS_cloudabi64_sys_fd_pwrite 9 -#define CLOUDABI64_SYS_cloudabi64_sys_fd_read 10 -#define CLOUDABI64_SYS_cloudabi_sys_fd_replace 11 -#define CLOUDABI64_SYS_cloudabi_sys_fd_seek 12 -#define CLOUDABI64_SYS_cloudabi_sys_fd_stat_get 13 -#define CLOUDABI64_SYS_cloudabi_sys_fd_stat_put 14 -#define CLOUDABI64_SYS_cloudabi_sys_fd_sync 15 -#define CLOUDABI64_SYS_cloudabi64_sys_fd_write 16 -#define CLOUDABI64_SYS_cloudabi_sys_file_advise 17 -#define CLOUDABI64_SYS_cloudabi_sys_file_allocate 18 -#define CLOUDABI64_SYS_cloudabi_sys_file_create 19 -#define CLOUDABI64_SYS_cloudabi_sys_file_link 20 -#define CLOUDABI64_SYS_cloudabi_sys_file_open 21 -#define CLOUDABI64_SYS_cloudabi_sys_file_readdir 22 -#define CLOUDABI64_SYS_cloudabi_sys_file_readlink 23 -#define CLOUDABI64_SYS_cloudabi_sys_file_rename 24 -#define CLOUDABI64_SYS_cloudabi_sys_file_stat_fget 25 -#define CLOUDABI64_SYS_cloudabi_sys_file_stat_fput 26 -#define CLOUDABI64_SYS_cloudabi_sys_file_stat_get 27 -#define CLOUDABI64_SYS_cloudabi_sys_file_stat_put 28 -#define CLOUDABI64_SYS_cloudabi_sys_file_symlink 29 -#define CLOUDABI64_SYS_cloudabi_sys_file_unlink 30 -#define CLOUDABI64_SYS_cloudabi_sys_lock_unlock 31 -#define CLOUDABI64_SYS_cloudabi_sys_mem_advise 32 -#define CLOUDABI64_SYS_cloudabi_sys_mem_map 33 -#define CLOUDABI64_SYS_cloudabi_sys_mem_protect 34 -#define CLOUDABI64_SYS_cloudabi_sys_mem_sync 35 -#define CLOUDABI64_SYS_cloudabi_sys_mem_unmap 36 -#define CLOUDABI64_SYS_cloudabi64_sys_poll 37 -#define CLOUDABI64_SYS_cloudabi_sys_proc_exec 38 -#define CLOUDABI64_SYS_cloudabi_sys_proc_exit 39 -#define CLOUDABI64_SYS_cloudabi_sys_proc_fork 40 -#define CLOUDABI64_SYS_cloudabi_sys_proc_raise 41 -#define CLOUDABI64_SYS_cloudabi_sys_random_get 42 -#define CLOUDABI64_SYS_cloudabi64_sys_sock_recv 43 -#define CLOUDABI64_SYS_cloudabi64_sys_sock_send 44 -#define CLOUDABI64_SYS_cloudabi_sys_sock_shutdown 45 -#define CLOUDABI64_SYS_cloudabi64_sys_thread_create 46 -#define CLOUDABI64_SYS_cloudabi_sys_thread_exit 47 -#define CLOUDABI64_SYS_cloudabi_sys_thread_yield 48 -#define CLOUDABI64_SYS_MAXSYSCALL 49 diff --git a/sys/compat/cloudabi64/cloudabi64_syscalls.c b/sys/compat/cloudabi64/cloudabi64_syscalls.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_syscalls.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * System call names. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -const char *cloudabi64_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 */ - "cloudabi64_sys_fd_pread", /* 8 = cloudabi64_sys_fd_pread */ - "cloudabi64_sys_fd_pwrite", /* 9 = cloudabi64_sys_fd_pwrite */ - "cloudabi64_sys_fd_read", /* 10 = cloudabi64_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 */ - "cloudabi64_sys_fd_write", /* 16 = cloudabi64_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_map", /* 33 = cloudabi_sys_mem_map */ - "cloudabi_sys_mem_protect", /* 34 = cloudabi_sys_mem_protect */ - "cloudabi_sys_mem_sync", /* 35 = cloudabi_sys_mem_sync */ - "cloudabi_sys_mem_unmap", /* 36 = cloudabi_sys_mem_unmap */ - "cloudabi64_sys_poll", /* 37 = cloudabi64_sys_poll */ - "cloudabi_sys_proc_exec", /* 38 = cloudabi_sys_proc_exec */ - "cloudabi_sys_proc_exit", /* 39 = cloudabi_sys_proc_exit */ - "cloudabi_sys_proc_fork", /* 40 = cloudabi_sys_proc_fork */ - "cloudabi_sys_proc_raise", /* 41 = cloudabi_sys_proc_raise */ - "cloudabi_sys_random_get", /* 42 = cloudabi_sys_random_get */ - "cloudabi64_sys_sock_recv", /* 43 = cloudabi64_sys_sock_recv */ - "cloudabi64_sys_sock_send", /* 44 = cloudabi64_sys_sock_send */ - "cloudabi_sys_sock_shutdown", /* 45 = cloudabi_sys_sock_shutdown */ - "cloudabi64_sys_thread_create", /* 46 = cloudabi64_sys_thread_create */ - "cloudabi_sys_thread_exit", /* 47 = cloudabi_sys_thread_exit */ - "cloudabi_sys_thread_yield", /* 48 = cloudabi_sys_thread_yield */ -}; diff --git a/sys/compat/cloudabi64/cloudabi64_sysent.c b/sys/compat/cloudabi64/cloudabi64_sysent.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_sysent.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically @generated. - * $FreeBSD$ - */ - -#include -#include -#include -#include - -#define AS(name) (sizeof(struct name) / sizeof(register_t)) - -/* The casts are bogus but will do for now. */ -struct sysent cloudabi64_sysent[] = { - { .sy_narg = AS(cloudabi_sys_clock_res_get_args), .sy_call = (sy_call_t *)cloudabi_sys_clock_res_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 0 = cloudabi_sys_clock_res_get */ - { .sy_narg = AS(cloudabi_sys_clock_time_get_args), .sy_call = (sy_call_t *)cloudabi_sys_clock_time_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 1 = cloudabi_sys_clock_time_get */ - { .sy_narg = AS(cloudabi_sys_condvar_signal_args), .sy_call = (sy_call_t *)cloudabi_sys_condvar_signal, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 2 = cloudabi_sys_condvar_signal */ - { .sy_narg = AS(cloudabi_sys_fd_close_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_close, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 3 = cloudabi_sys_fd_close */ - { .sy_narg = AS(cloudabi_sys_fd_create1_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_create1, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 4 = cloudabi_sys_fd_create1 */ - { .sy_narg = AS(cloudabi_sys_fd_create2_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_create2, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 5 = cloudabi_sys_fd_create2 */ - { .sy_narg = AS(cloudabi_sys_fd_datasync_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_datasync, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 6 = cloudabi_sys_fd_datasync */ - { .sy_narg = AS(cloudabi_sys_fd_dup_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_dup, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 7 = cloudabi_sys_fd_dup */ - { .sy_narg = AS(cloudabi64_sys_fd_pread_args), .sy_call = (sy_call_t *)cloudabi64_sys_fd_pread, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 8 = cloudabi64_sys_fd_pread */ - { .sy_narg = AS(cloudabi64_sys_fd_pwrite_args), .sy_call = (sy_call_t *)cloudabi64_sys_fd_pwrite, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 9 = cloudabi64_sys_fd_pwrite */ - { .sy_narg = AS(cloudabi64_sys_fd_read_args), .sy_call = (sy_call_t *)cloudabi64_sys_fd_read, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 10 = cloudabi64_sys_fd_read */ - { .sy_narg = AS(cloudabi_sys_fd_replace_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_replace, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 11 = cloudabi_sys_fd_replace */ - { .sy_narg = AS(cloudabi_sys_fd_seek_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_seek, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 12 = cloudabi_sys_fd_seek */ - { .sy_narg = AS(cloudabi_sys_fd_stat_get_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_stat_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 13 = cloudabi_sys_fd_stat_get */ - { .sy_narg = AS(cloudabi_sys_fd_stat_put_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_stat_put, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 14 = cloudabi_sys_fd_stat_put */ - { .sy_narg = AS(cloudabi_sys_fd_sync_args), .sy_call = (sy_call_t *)cloudabi_sys_fd_sync, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 15 = cloudabi_sys_fd_sync */ - { .sy_narg = AS(cloudabi64_sys_fd_write_args), .sy_call = (sy_call_t *)cloudabi64_sys_fd_write, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 16 = cloudabi64_sys_fd_write */ - { .sy_narg = AS(cloudabi_sys_file_advise_args), .sy_call = (sy_call_t *)cloudabi_sys_file_advise, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 17 = cloudabi_sys_file_advise */ - { .sy_narg = AS(cloudabi_sys_file_allocate_args), .sy_call = (sy_call_t *)cloudabi_sys_file_allocate, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 18 = cloudabi_sys_file_allocate */ - { .sy_narg = AS(cloudabi_sys_file_create_args), .sy_call = (sy_call_t *)cloudabi_sys_file_create, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 19 = cloudabi_sys_file_create */ - { .sy_narg = AS(cloudabi_sys_file_link_args), .sy_call = (sy_call_t *)cloudabi_sys_file_link, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 20 = cloudabi_sys_file_link */ - { .sy_narg = AS(cloudabi_sys_file_open_args), .sy_call = (sy_call_t *)cloudabi_sys_file_open, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 21 = cloudabi_sys_file_open */ - { .sy_narg = AS(cloudabi_sys_file_readdir_args), .sy_call = (sy_call_t *)cloudabi_sys_file_readdir, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 22 = cloudabi_sys_file_readdir */ - { .sy_narg = AS(cloudabi_sys_file_readlink_args), .sy_call = (sy_call_t *)cloudabi_sys_file_readlink, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 23 = cloudabi_sys_file_readlink */ - { .sy_narg = AS(cloudabi_sys_file_rename_args), .sy_call = (sy_call_t *)cloudabi_sys_file_rename, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 24 = cloudabi_sys_file_rename */ - { .sy_narg = AS(cloudabi_sys_file_stat_fget_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_fget, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 25 = cloudabi_sys_file_stat_fget */ - { .sy_narg = AS(cloudabi_sys_file_stat_fput_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_fput, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 26 = cloudabi_sys_file_stat_fput */ - { .sy_narg = AS(cloudabi_sys_file_stat_get_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 27 = cloudabi_sys_file_stat_get */ - { .sy_narg = AS(cloudabi_sys_file_stat_put_args), .sy_call = (sy_call_t *)cloudabi_sys_file_stat_put, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 28 = cloudabi_sys_file_stat_put */ - { .sy_narg = AS(cloudabi_sys_file_symlink_args), .sy_call = (sy_call_t *)cloudabi_sys_file_symlink, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 29 = cloudabi_sys_file_symlink */ - { .sy_narg = AS(cloudabi_sys_file_unlink_args), .sy_call = (sy_call_t *)cloudabi_sys_file_unlink, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 30 = cloudabi_sys_file_unlink */ - { .sy_narg = AS(cloudabi_sys_lock_unlock_args), .sy_call = (sy_call_t *)cloudabi_sys_lock_unlock, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 31 = cloudabi_sys_lock_unlock */ - { .sy_narg = AS(cloudabi_sys_mem_advise_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_advise, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 32 = cloudabi_sys_mem_advise */ - { .sy_narg = AS(cloudabi_sys_mem_map_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_map, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 33 = cloudabi_sys_mem_map */ - { .sy_narg = AS(cloudabi_sys_mem_protect_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_protect, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 34 = cloudabi_sys_mem_protect */ - { .sy_narg = AS(cloudabi_sys_mem_sync_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_sync, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 35 = cloudabi_sys_mem_sync */ - { .sy_narg = AS(cloudabi_sys_mem_unmap_args), .sy_call = (sy_call_t *)cloudabi_sys_mem_unmap, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 36 = cloudabi_sys_mem_unmap */ - { .sy_narg = AS(cloudabi64_sys_poll_args), .sy_call = (sy_call_t *)cloudabi64_sys_poll, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 37 = cloudabi64_sys_poll */ - { .sy_narg = AS(cloudabi_sys_proc_exec_args), .sy_call = (sy_call_t *)cloudabi_sys_proc_exec, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 38 = cloudabi_sys_proc_exec */ - { .sy_narg = AS(cloudabi_sys_proc_exit_args), .sy_call = (sy_call_t *)cloudabi_sys_proc_exit, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 39 = cloudabi_sys_proc_exit */ - { .sy_narg = 0, .sy_call = (sy_call_t *)cloudabi_sys_proc_fork, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 40 = cloudabi_sys_proc_fork */ - { .sy_narg = AS(cloudabi_sys_proc_raise_args), .sy_call = (sy_call_t *)cloudabi_sys_proc_raise, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 41 = cloudabi_sys_proc_raise */ - { .sy_narg = AS(cloudabi_sys_random_get_args), .sy_call = (sy_call_t *)cloudabi_sys_random_get, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 42 = cloudabi_sys_random_get */ - { .sy_narg = AS(cloudabi64_sys_sock_recv_args), .sy_call = (sy_call_t *)cloudabi64_sys_sock_recv, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 43 = cloudabi64_sys_sock_recv */ - { .sy_narg = AS(cloudabi64_sys_sock_send_args), .sy_call = (sy_call_t *)cloudabi64_sys_sock_send, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 44 = cloudabi64_sys_sock_send */ - { .sy_narg = AS(cloudabi_sys_sock_shutdown_args), .sy_call = (sy_call_t *)cloudabi_sys_sock_shutdown, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 45 = cloudabi_sys_sock_shutdown */ - { .sy_narg = AS(cloudabi64_sys_thread_create_args), .sy_call = (sy_call_t *)cloudabi64_sys_thread_create, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 46 = cloudabi64_sys_thread_create */ - { .sy_narg = AS(cloudabi_sys_thread_exit_args), .sy_call = (sy_call_t *)cloudabi_sys_thread_exit, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 47 = cloudabi_sys_thread_exit */ - { .sy_narg = 0, .sy_call = (sy_call_t *)cloudabi_sys_thread_yield, .sy_auevent = AUE_NULL, .sy_flags = SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC }, /* 48 = cloudabi_sys_thread_yield */ -}; diff --git a/sys/compat/cloudabi64/cloudabi64_systrace_args.c b/sys/compat/cloudabi64/cloudabi64_systrace_args.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_systrace_args.c +++ /dev/null @@ -1,1458 +0,0 @@ -/* - * 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; - } - /* cloudabi64_sys_fd_pread */ - case 8: { - struct cloudabi64_sys_fd_pread_args *p = params; - iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t)p->iovs; /* const cloudabi64_iovec_t * */ - uarg[2] = p->iovs_len; /* size_t */ - iarg[3] = p->offset; /* cloudabi_filesize_t */ - *n_args = 4; - break; - } - /* cloudabi64_sys_fd_pwrite */ - case 9: { - struct cloudabi64_sys_fd_pwrite_args *p = params; - iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t)p->iovs; /* const cloudabi64_ciovec_t * */ - uarg[2] = p->iovs_len; /* size_t */ - iarg[3] = p->offset; /* cloudabi_filesize_t */ - *n_args = 4; - break; - } - /* cloudabi64_sys_fd_read */ - case 10: { - struct cloudabi64_sys_fd_read_args *p = params; - iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t)p->iovs; /* const cloudabi64_iovec_t * */ - uarg[2] = p->iovs_len; /* 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; - } - /* cloudabi64_sys_fd_write */ - case 16: { - struct cloudabi64_sys_fd_write_args *p = params; - iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t)p->iovs; /* const cloudabi64_ciovec_t * */ - uarg[2] = p->iovs_len; /* 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->path_len; /* 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->path1_len; /* size_t */ - iarg[3] = p->fd2; /* cloudabi_fd_t */ - uarg[4] = (intptr_t)p->path2; /* const char * */ - uarg[5] = p->path2_len; /* 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->path_len; /* 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->buf_len; /* 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->path_len; /* size_t */ - uarg[3] = (intptr_t)p->buf; /* char * */ - uarg[4] = p->buf_len; /* size_t */ - *n_args = 5; - break; - } - /* cloudabi_sys_file_rename */ - case 24: { - struct cloudabi_sys_file_rename_args *p = params; - iarg[0] = p->fd1; /* cloudabi_fd_t */ - uarg[1] = (intptr_t)p->path1; /* const char * */ - uarg[2] = p->path1_len; /* size_t */ - iarg[3] = p->fd2; /* cloudabi_fd_t */ - uarg[4] = (intptr_t)p->path2; /* const char * */ - uarg[5] = p->path2_len; /* 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->path_len; /* 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->path_len; /* 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->path1_len; /* size_t */ - iarg[2] = p->fd; /* cloudabi_fd_t */ - uarg[3] = (intptr_t)p->path2; /* const char * */ - uarg[4] = p->path2_len; /* 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->path_len; /* 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->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - iarg[2] = p->advice; /* cloudabi_advice_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_mem_map */ - case 33: { - 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 34: { - struct cloudabi_sys_mem_protect_args *p = params; - uarg[0] = (intptr_t)p->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - iarg[2] = p->prot; /* cloudabi_mprot_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_mem_sync */ - case 35: { - struct cloudabi_sys_mem_sync_args *p = params; - uarg[0] = (intptr_t)p->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - iarg[2] = p->flags; /* cloudabi_msflags_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_mem_unmap */ - case 36: { - struct cloudabi_sys_mem_unmap_args *p = params; - uarg[0] = (intptr_t)p->mapping; /* void * */ - uarg[1] = p->mapping_len; /* size_t */ - *n_args = 2; - break; - } - /* cloudabi64_sys_poll */ - case 37: { - struct cloudabi64_sys_poll_args *p = params; - uarg[0] = (intptr_t)p->in; /* const cloudabi64_subscription_t * */ - uarg[1] = (intptr_t)p->out; /* cloudabi_event_t * */ - uarg[2] = p->nsubscriptions; /* size_t */ - *n_args = 3; - break; - } - /* cloudabi_sys_proc_exec */ - case 38: { - 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->data_len; /* size_t */ - uarg[3] = (intptr_t)p->fds; /* const cloudabi_fd_t * */ - uarg[4] = p->fds_len; /* size_t */ - *n_args = 5; - break; - } - /* cloudabi_sys_proc_exit */ - case 39: { - struct cloudabi_sys_proc_exit_args *p = params; - iarg[0] = p->rval; /* cloudabi_exitcode_t */ - *n_args = 1; - break; - } - /* cloudabi_sys_proc_fork */ - case 40: { - *n_args = 0; - break; - } - /* cloudabi_sys_proc_raise */ - case 41: { - struct cloudabi_sys_proc_raise_args *p = params; - iarg[0] = p->sig; /* cloudabi_signal_t */ - *n_args = 1; - break; - } - /* cloudabi_sys_random_get */ - case 42: { - struct cloudabi_sys_random_get_args *p = params; - uarg[0] = (intptr_t)p->buf; /* void * */ - uarg[1] = p->buf_len; /* size_t */ - *n_args = 2; - break; - } - /* cloudabi64_sys_sock_recv */ - case 43: { - 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 * */ - uarg[2] = (intptr_t)p->out; /* cloudabi64_recv_out_t * */ - *n_args = 3; - break; - } - /* cloudabi64_sys_sock_send */ - case 44: { - 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 * */ - uarg[2] = (intptr_t)p->out; /* cloudabi64_send_out_t * */ - *n_args = 3; - break; - } - /* cloudabi_sys_sock_shutdown */ - case 45: { - 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; - } - /* cloudabi64_sys_thread_create */ - case 46: { - 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 47: { - 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 48: { - *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 = "userland 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; - /* cloudabi64_sys_fd_pread */ - case 8: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi64_iovec_t *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_filesize_t"; - break; - default: - break; - }; - break; - /* cloudabi64_sys_fd_pwrite */ - case 9: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi64_ciovec_t *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_filesize_t"; - break; - default: - break; - }; - break; - /* cloudabi64_sys_fd_read */ - case 10: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi64_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 = "userland 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 = "userland 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; - /* cloudabi64_sys_fd_write */ - case 16: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi64_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 = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_fd_t"; - break; - case 4: - p = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_oflags_t"; - break; - case 4: - p = "userland 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 = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "cloudabi_fd_t"; - break; - case 4: - p = "userland 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 = "userland 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 = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland 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 = "userland const char *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland 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 = "userland const char *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_fd_t"; - break; - case 3: - p = "userland 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 = "userland 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 = "userland 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 = "userland void *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_advice_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_mem_map */ - case 33: - switch (ndx) { - case 0: - p = "userland 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 34: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_mprot_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_mem_sync */ - case 35: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - case 2: - p = "cloudabi_msflags_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_mem_unmap */ - case 36: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi64_sys_poll */ - case 37: - switch (ndx) { - case 0: - p = "userland const cloudabi64_subscription_t *"; - break; - case 1: - p = "userland cloudabi_event_t *"; - break; - case 2: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_proc_exec */ - case 38: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const void *"; - break; - case 2: - p = "size_t"; - break; - case 3: - p = "userland const cloudabi_fd_t *"; - break; - case 4: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_proc_exit */ - case 39: - switch (ndx) { - case 0: - p = "cloudabi_exitcode_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_proc_fork */ - case 40: - break; - /* cloudabi_sys_proc_raise */ - case 41: - switch (ndx) { - case 0: - p = "cloudabi_signal_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_random_get */ - case 42: - switch (ndx) { - case 0: - p = "userland void *"; - break; - case 1: - p = "size_t"; - break; - default: - break; - }; - break; - /* cloudabi64_sys_sock_recv */ - case 43: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi64_recv_in_t *"; - break; - case 2: - p = "userland cloudabi64_recv_out_t *"; - break; - default: - break; - }; - break; - /* cloudabi64_sys_sock_send */ - case 44: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "userland const cloudabi64_send_in_t *"; - break; - case 2: - p = "userland cloudabi64_send_out_t *"; - break; - default: - break; - }; - break; - /* cloudabi_sys_sock_shutdown */ - case 45: - switch (ndx) { - case 0: - p = "cloudabi_fd_t"; - break; - case 1: - p = "cloudabi_sdflags_t"; - break; - default: - break; - }; - break; - /* cloudabi64_sys_thread_create */ - case 46: - switch (ndx) { - case 0: - p = "userland cloudabi64_threadattr_t *"; - break; - default: - break; - }; - break; - /* cloudabi_sys_thread_exit */ - case 47: - switch (ndx) { - case 0: - p = "userland cloudabi_lock_t *"; - break; - case 1: - p = "cloudabi_scope_t"; - break; - default: - break; - }; - break; - /* cloudabi_sys_thread_yield */ - case 48: - 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; - /* cloudabi64_sys_fd_pread */ - case 8: - if (ndx == 0 || ndx == 1) - p = "size_t"; - break; - /* cloudabi64_sys_fd_pwrite */ - case 9: - if (ndx == 0 || ndx == 1) - p = "size_t"; - break; - /* cloudabi64_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; - /* cloudabi64_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_map */ - case 33: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_mem_protect */ - case 34: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_mem_sync */ - case 35: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_mem_unmap */ - case 36: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi64_sys_poll */ - case 37: - if (ndx == 0 || ndx == 1) - p = "size_t"; - break; - /* cloudabi_sys_proc_exec */ - case 38: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_proc_exit */ - case 39: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_proc_fork */ - case 40: - /* cloudabi_sys_proc_raise */ - case 41: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_random_get */ - case 42: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi64_sys_sock_recv */ - case 43: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi64_sys_sock_send */ - case 44: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_sock_shutdown */ - case 45: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi64_sys_thread_create */ - case 46: - if (ndx == 0 || ndx == 1) - p = "cloudabi_tid_t"; - break; - /* cloudabi_sys_thread_exit */ - case 47: - if (ndx == 0 || ndx == 1) - p = "void"; - break; - /* cloudabi_sys_thread_yield */ - case 48: - default: - break; - }; - if (p != NULL) - strlcpy(desc, p, descsz); -} diff --git a/sys/compat/cloudabi64/cloudabi64_thread.c b/sys/compat/cloudabi64/cloudabi64_thread.c deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_thread.c +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * 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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include - -#include -#include - -struct thread_create_args { - cloudabi64_threadattr_t attr; - uint64_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 (cloudabi64_thread_setregs(td, &args->attr, args->tcb)); -} - -int -cloudabi64_sys_thread_create(struct thread *td, - struct cloudabi64_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_len - - sizeof(cloudabi64_tcb_t), _Alignof(cloudabi64_tcb_t)); - args.attr.stack_len = 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/cloudabi64/cloudabi64_util.h b/sys/compat/cloudabi64/cloudabi64_util.h deleted file mode 100644 --- a/sys/compat/cloudabi64/cloudabi64_util.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * 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 _CLOUDABI64_UTIL_H_ -#define _CLOUDABI64_UTIL_H_ - -#include -#define __ELF_WORD_SIZE 64 -#include - -#include - -struct image_params; -struct thread; - -extern Elf64_Brandinfo cloudabi64_brand; - -#define TO_PTR(x) ((void *)(uintptr_t)(x)) - -/* Stack initialization during process execution. */ -int cloudabi64_copyout_strings(struct image_params *, uintptr_t *); -int cloudabi64_fixup(uintptr_t *, struct image_params *); - -int cloudabi64_thread_setregs(struct thread *, - const cloudabi64_threadattr_t *, uint64_t); - -#endif diff --git a/sys/compat/cloudabi64/syscalls.conf b/sys/compat/cloudabi64/syscalls.conf deleted file mode 100644 --- a/sys/compat/cloudabi64/syscalls.conf +++ /dev/null @@ -1,15 +0,0 @@ -# $FreeBSD$ -sysnames="cloudabi64_syscalls.c" -sysproto="cloudabi64_proto.h" -sysproto_h=_CLOUDABI64_SYSPROTO_H_ -syshdr="cloudabi64_syscall.h" -syssw="cloudabi64_sysent.c" -sysmk="/dev/null" -syscallprefix="CLOUDABI64_SYS_" -switchname="cloudabi64_sysent" -namesname="cloudabi64_syscallnames" -systrace="cloudabi64_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/conf/files b/sys/conf/files --- a/sys/conf/files +++ b/sys/conf/files @@ -375,31 +375,6 @@ cddl/dev/systrace/systrace.c optional dtrace_systrace | dtraceall compile-with "${CDDL_C}" cddl/dev/prototype.c optional dtrace_prototype | dtraceall compile-with "${CDDL_C}" fs/nfsclient/nfs_clkdtrace.c optional dtnfscl nfscl | dtraceall nfscl compile-with "${CDDL_C}" -compat/cloudabi/cloudabi_clock.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_errno.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_fd.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_file.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_futex.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_mem.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_proc.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_random.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_sock.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_thread.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi/cloudabi_vdso.c optional compat_cloudabi32 | compat_cloudabi64 -compat/cloudabi32/cloudabi32_fd.c optional compat_cloudabi32 -compat/cloudabi32/cloudabi32_module.c optional compat_cloudabi32 -compat/cloudabi32/cloudabi32_poll.c optional compat_cloudabi32 -compat/cloudabi32/cloudabi32_sock.c optional compat_cloudabi32 -compat/cloudabi32/cloudabi32_syscalls.c optional compat_cloudabi32 -compat/cloudabi32/cloudabi32_sysent.c optional compat_cloudabi32 -compat/cloudabi32/cloudabi32_thread.c optional compat_cloudabi32 -compat/cloudabi64/cloudabi64_fd.c optional compat_cloudabi64 -compat/cloudabi64/cloudabi64_module.c optional compat_cloudabi64 -compat/cloudabi64/cloudabi64_poll.c optional compat_cloudabi64 -compat/cloudabi64/cloudabi64_sock.c optional compat_cloudabi64 -compat/cloudabi64/cloudabi64_syscalls.c optional compat_cloudabi64 -compat/cloudabi64/cloudabi64_sysent.c optional compat_cloudabi64 -compat/cloudabi64/cloudabi64_thread.c optional compat_cloudabi64 compat/freebsd32/freebsd32_capability.c optional compat_freebsd32 compat/freebsd32/freebsd32_ioctl.c optional compat_freebsd32 compat/freebsd32/freebsd32_misc.c optional compat_freebsd32 diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -12,30 +12,6 @@ # dependency lines other than the first are silently ignored. # # -cloudabi32_vdso.o optional compat_cloudabi32 \ - dependency "$S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S" \ - compile-with "${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S -o ${.TARGET}" \ - no-obj no-implicit-rule \ - clean "cloudabi32_vdso.o" -# -cloudabi32_vdso_blob.o optional compat_cloudabi32 \ - dependency "cloudabi32_vdso.o" \ - compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ - no-implicit-rule \ - clean "cloudabi32_vdso_blob.o" -# -cloudabi64_vdso.o optional compat_cloudabi64 \ - dependency "$S/contrib/cloudabi/cloudabi_vdso_x86_64.S" \ - compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_x86_64.S -o ${.TARGET}" \ - no-obj no-implicit-rule \ - clean "cloudabi64_vdso.o" -# -cloudabi64_vdso_blob.o optional compat_cloudabi64 \ - dependency "cloudabi64_vdso.o" \ - compile-with "${OBJCOPY} --input-target binary --output-target elf64-x86-64-freebsd --binary-architecture i386 cloudabi64_vdso.o ${.TARGET}" \ - no-implicit-rule \ - clean "cloudabi64_vdso_blob.o" -# ia32_genassym.o standard \ dependency "$S/compat/ia32/ia32_genassym.c offset.inc" \ compile-with "${CC} ${CFLAGS:N-flto:N-fno-common} -fcommon -c ${.IMPSRC}" \ @@ -107,8 +83,6 @@ amd64/amd64/uio_machdep.c standard amd64/amd64/uma_machdep.c standard amd64/amd64/vm_machdep.c standard -amd64/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 -amd64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 amd64/pci/pci_cfgreg.c optional pci cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" diff --git a/sys/conf/files.arm b/sys/conf/files.arm --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -75,7 +75,6 @@ arm/arm/unwind.c optional ddb | kdtrace_hooks | stack arm/arm/vm_machdep.c standard arm/arm/vfp.c standard -arm/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 cddl/compat/opensolaris/kern/opensolaris_atomic.c optional !armv7 !armv6 zfs | !armv7 !armv6 dtrace compile-with "${CDDL_C}" cddl/dev/dtrace/arm/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/arm/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" @@ -130,20 +129,6 @@ libkern/udivdi3.c standard libkern/umoddi3.c standard -# CloudABI support -cloudabi32_vdso.o optional compat_cloudabi32 \ - dependency "$S/contrib/cloudabi/cloudabi_vdso_armv6.S" \ - compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_armv6.S -o ${.TARGET}" \ - no-obj no-implicit-rule \ - clean "cloudabi32_vdso.o" -# -cloudabi32_vdso_blob.o optional compat_cloudabi32 \ - dependency "cloudabi32_vdso.o" \ - compile-with "${OBJCOPY} --input-target binary --output-target elf32-littlearm --binary-architecture arm cloudabi32_vdso.o ${.TARGET}" \ - no-implicit-rule \ - clean "cloudabi32_vdso_blob.o" -# - # Annapurna support arm/annapurna/alpine/alpine_ccu.c optional al_ccu fdt arm/annapurna/alpine/alpine_nb_service.c optional al_nb_service fdt diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -558,28 +558,3 @@ # Xilinx arm/xilinx/uart_dev_cdnc.c optional uart soc_xilinx_zynq - -# Cloudabi -arm64/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 -arm64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 - -cloudabi32_vdso.o optional compat_cloudabi32 \ - dependency "$S/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S" \ - compile-with "${CC} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S -o ${.TARGET}" \ - no-obj no-implicit-rule \ - clean "cloudabi32_vdso.o" -cloudabi32_vdso_blob.o optional compat_cloudabi32 \ - dependency "cloudabi32_vdso.o" \ - compile-with "${OBJCOPY} --input-target binary --output-target elf64-littleaarch64 --binary-architecture aarch64 cloudabi32_vdso.o ${.TARGET}" \ - no-implicit-rule \ - clean "cloudabi32_vdso_blob.o" -cloudabi64_vdso.o optional compat_cloudabi64 \ - dependency "$S/contrib/cloudabi/cloudabi_vdso_aarch64.S" \ - compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_aarch64.S -o ${.TARGET}" \ - no-obj no-implicit-rule \ - clean "cloudabi64_vdso.o" -cloudabi64_vdso_blob.o optional compat_cloudabi64 \ - dependency "cloudabi64_vdso.o" \ - compile-with "${OBJCOPY} --input-target binary --output-target elf64-littleaarch64 --binary-architecture aarch64 cloudabi64_vdso.o ${.TARGET}" \ - no-implicit-rule \ - clean "cloudabi64_vdso_blob.o" diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -11,17 +11,6 @@ # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # -cloudabi32_vdso.o optional compat_cloudabi32 \ - dependency "$S/contrib/cloudabi/cloudabi_vdso_i686.S" \ - compile-with "${CC} -x assembler-with-cpp -shared -nostdinc -nostdlib -Wl,-T$S/compat/cloudabi/cloudabi_vdso.lds $S/contrib/cloudabi/cloudabi_vdso_i686.S -o ${.TARGET}" \ - no-obj no-implicit-rule \ - clean "cloudabi32_vdso.o" -# -cloudabi32_vdso_blob.o optional compat_cloudabi32 \ - dependency "cloudabi32_vdso.o" \ - compile-with "${OBJCOPY} --input-target binary --output-target elf32-i386-freebsd --binary-architecture i386 cloudabi32_vdso.o ${.TARGET}" \ - no-implicit-rule \ - clean "cloudabi32_vdso_blob.o" cddl/dev/dtrace/i386/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/i386/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" crypto/aesni/aeskeys_i386.S optional aesni @@ -107,7 +96,6 @@ # i386/bios/smapi.c optional smapi i386/bios/smapi_bios.S optional smapi -i386/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 #i386/i386/apic_vector.s optional apic i386/i386/bios.c standard i386/i386/bioscall.s standard diff --git a/sys/conf/options b/sys/conf/options --- a/sys/conf/options +++ b/sys/conf/options @@ -91,8 +91,6 @@ COMPAT_FREEBSD10 opt_global.h COMPAT_FREEBSD11 opt_global.h COMPAT_FREEBSD12 opt_global.h -COMPAT_CLOUDABI32 opt_dontuse.h -COMPAT_CLOUDABI64 opt_dontuse.h COMPAT_LINUXKPI opt_dontuse.h _COMPAT_LINUX32 opt_compat.h # XXX: make sure opt_compat.h exists COMPILING_LINT opt_global.h diff --git a/sys/contrib/cloudabi/cloudabi32_types.h b/sys/contrib/cloudabi/cloudabi32_types.h deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi32_types.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#ifndef CLOUDABI32_TYPES_H -#define CLOUDABI32_TYPES_H - -#include "cloudabi_types_common.h" - -typedef struct { - _Alignas(4) cloudabi_auxtype_t a_type; - union { - _Alignas(4) uint32_t a_val; - _Alignas(4) uint32_t a_ptr; - }; -} cloudabi32_auxv_t; -_Static_assert(offsetof(cloudabi32_auxv_t, a_type) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_auxv_t, a_val) == 4, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_auxv_t, a_ptr) == 4, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_auxv_t) == 8, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_auxv_t) == 4, "Incorrect layout"); - -typedef struct { - _Alignas(4) uint32_t buf; - _Alignas(4) uint32_t buf_len; -} cloudabi32_ciovec_t; -_Static_assert(offsetof(cloudabi32_ciovec_t, buf) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_ciovec_t, buf_len) == 4, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_ciovec_t) == 8, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_ciovec_t) == 4, "Incorrect layout"); - -typedef struct { - _Alignas(4) uint32_t buf; - _Alignas(4) uint32_t buf_len; -} cloudabi32_iovec_t; -_Static_assert(offsetof(cloudabi32_iovec_t, buf) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_iovec_t, buf_len) == 4, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_iovec_t) == 8, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_iovec_t) == 4, "Incorrect layout"); - -typedef void cloudabi32_processentry_t(uint32_t auxv); - -typedef struct { - _Alignas(4) uint32_t ri_data; - _Alignas(4) uint32_t ri_data_len; - _Alignas(4) uint32_t ri_fds; - _Alignas(4) uint32_t ri_fds_len; - _Alignas(2) cloudabi_riflags_t ri_flags; -} cloudabi32_recv_in_t; -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_data_len) == 4, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_fds) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_fds_len) == 12, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_flags) == 16, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_recv_in_t) == 20, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_recv_in_t) == 4, "Incorrect layout"); - -typedef struct { - _Alignas(4) uint32_t ro_datalen; - _Alignas(4) uint32_t ro_fdslen; - _Alignas(1) char ro_unused[40]; - _Alignas(2) cloudabi_roflags_t ro_flags; -} cloudabi32_recv_out_t; -_Static_assert(offsetof(cloudabi32_recv_out_t, ro_datalen) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_out_t, ro_fdslen) == 4, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_out_t, ro_unused) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_out_t, ro_flags) == 48, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_recv_out_t) == 52, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_recv_out_t) == 4, "Incorrect layout"); - -typedef struct { - _Alignas(4) uint32_t si_data; - _Alignas(4) uint32_t si_data_len; - _Alignas(4) uint32_t si_fds; - _Alignas(4) uint32_t si_fds_len; - _Alignas(2) cloudabi_siflags_t si_flags; -} cloudabi32_send_in_t; -_Static_assert(offsetof(cloudabi32_send_in_t, si_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_send_in_t, si_data_len) == 4, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_send_in_t, si_fds) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_send_in_t, si_fds_len) == 12, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_send_in_t, si_flags) == 16, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_send_in_t) == 20, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_send_in_t) == 4, "Incorrect layout"); - -typedef struct { - _Alignas(4) uint32_t so_datalen; -} cloudabi32_send_out_t; -_Static_assert(offsetof(cloudabi32_send_out_t, so_datalen) == 0, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_send_out_t) == 4, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_send_out_t) == 4, "Incorrect layout"); - -typedef struct { - _Alignas(8) cloudabi_userdata_t userdata; - _Alignas(2) uint16_t unused; - _Alignas(1) cloudabi_eventtype_t type; - union { - struct { - _Alignas(8) cloudabi_userdata_t identifier; - _Alignas(4) cloudabi_clockid_t clock_id; - _Alignas(8) cloudabi_timestamp_t timeout; - _Alignas(8) cloudabi_timestamp_t precision; - _Alignas(2) cloudabi_subclockflags_t flags; - } clock; - struct { - _Alignas(4) uint32_t condvar; - _Alignas(4) uint32_t lock; - _Alignas(1) cloudabi_scope_t condvar_scope; - _Alignas(1) cloudabi_scope_t lock_scope; - } condvar; - struct { - _Alignas(4) cloudabi_fd_t fd; - _Alignas(2) cloudabi_subrwflags_t flags; - } fd_readwrite; - struct { - _Alignas(4) uint32_t lock; - _Alignas(1) cloudabi_scope_t lock_scope; - } lock; - struct { - _Alignas(4) cloudabi_fd_t fd; - } proc_terminate; - }; -} cloudabi32_subscription_t; -_Static_assert(offsetof(cloudabi32_subscription_t, userdata) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, unused) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, type) == 10, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, clock.identifier) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, clock.clock_id) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, clock.timeout) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, clock.precision) == 40, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, clock.flags) == 48, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, condvar.condvar) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, condvar.lock) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, condvar.condvar_scope) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, condvar.lock_scope) == 25, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, fd_readwrite.fd) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, fd_readwrite.flags) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, lock.lock) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, lock.lock_scope) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_subscription_t, proc_terminate.fd) == 16, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_subscription_t) == 56, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_subscription_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(4) uint32_t parent; -} cloudabi32_tcb_t; -_Static_assert(offsetof(cloudabi32_tcb_t, parent) == 0, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_tcb_t) == 4, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_tcb_t) == 4, "Incorrect layout"); - -typedef void cloudabi32_threadentry_t(cloudabi_tid_t tid, uint32_t aux); - -typedef struct { - _Alignas(4) uint32_t entry_point; - _Alignas(4) uint32_t stack; - _Alignas(4) uint32_t stack_len; - _Alignas(4) uint32_t argument; -} cloudabi32_threadattr_t; -_Static_assert(offsetof(cloudabi32_threadattr_t, entry_point) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_threadattr_t, stack) == 4, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_threadattr_t, stack_len) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_threadattr_t, argument) == 12, "Incorrect layout"); -_Static_assert(sizeof(cloudabi32_threadattr_t) == 16, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi32_threadattr_t) == 4, "Incorrect layout"); - -#endif diff --git a/sys/contrib/cloudabi/cloudabi64_types.h b/sys/contrib/cloudabi/cloudabi64_types.h deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi64_types.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#ifndef CLOUDABI64_TYPES_H -#define CLOUDABI64_TYPES_H - -#include "cloudabi_types_common.h" - -typedef struct { - _Alignas(4) cloudabi_auxtype_t a_type; - union { - _Alignas(8) uint64_t a_val; - _Alignas(8) uint64_t a_ptr; - }; -} cloudabi64_auxv_t; -_Static_assert(offsetof(cloudabi64_auxv_t, a_type) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_auxv_t, a_val) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_auxv_t, a_ptr) == 8, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_auxv_t) == 16, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_auxv_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) uint64_t buf; - _Alignas(8) uint64_t buf_len; -} cloudabi64_ciovec_t; -_Static_assert(offsetof(cloudabi64_ciovec_t, buf) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_ciovec_t, buf_len) == 8, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_ciovec_t) == 16, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_ciovec_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) uint64_t buf; - _Alignas(8) uint64_t buf_len; -} cloudabi64_iovec_t; -_Static_assert(offsetof(cloudabi64_iovec_t, buf) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_iovec_t, buf_len) == 8, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_iovec_t) == 16, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_iovec_t) == 8, "Incorrect layout"); - -typedef void cloudabi64_processentry_t(uint64_t auxv); - -typedef struct { - _Alignas(8) uint64_t ri_data; - _Alignas(8) uint64_t ri_data_len; - _Alignas(8) uint64_t ri_fds; - _Alignas(8) uint64_t ri_fds_len; - _Alignas(2) cloudabi_riflags_t ri_flags; -} cloudabi64_recv_in_t; -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data_len) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds_len) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_flags) == 32, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_recv_in_t) == 40, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_recv_in_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) uint64_t ro_datalen; - _Alignas(8) uint64_t ro_fdslen; - _Alignas(1) char ro_unused[40]; - _Alignas(2) cloudabi_roflags_t ro_flags; -} cloudabi64_recv_out_t; -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_datalen) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_fdslen) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_unused) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_flags) == 56, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_recv_out_t) == 64, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_recv_out_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) uint64_t si_data; - _Alignas(8) uint64_t si_data_len; - _Alignas(8) uint64_t si_fds; - _Alignas(8) uint64_t si_fds_len; - _Alignas(2) cloudabi_siflags_t si_flags; -} cloudabi64_send_in_t; -_Static_assert(offsetof(cloudabi64_send_in_t, si_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_data_len) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_fds) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_fds_len) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_flags) == 32, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_send_in_t) == 40, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_send_in_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) uint64_t so_datalen; -} cloudabi64_send_out_t; -_Static_assert(offsetof(cloudabi64_send_out_t, so_datalen) == 0, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_send_out_t) == 8, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_send_out_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) cloudabi_userdata_t userdata; - _Alignas(2) uint16_t unused; - _Alignas(1) cloudabi_eventtype_t type; - union { - struct { - _Alignas(8) cloudabi_userdata_t identifier; - _Alignas(4) cloudabi_clockid_t clock_id; - _Alignas(8) cloudabi_timestamp_t timeout; - _Alignas(8) cloudabi_timestamp_t precision; - _Alignas(2) cloudabi_subclockflags_t flags; - } clock; - struct { - _Alignas(8) uint64_t condvar; - _Alignas(8) uint64_t lock; - _Alignas(1) cloudabi_scope_t condvar_scope; - _Alignas(1) cloudabi_scope_t lock_scope; - } condvar; - struct { - _Alignas(4) cloudabi_fd_t fd; - _Alignas(2) cloudabi_subrwflags_t flags; - } fd_readwrite; - struct { - _Alignas(8) uint64_t lock; - _Alignas(1) cloudabi_scope_t lock_scope; - } lock; - struct { - _Alignas(4) cloudabi_fd_t fd; - } proc_terminate; - }; -} cloudabi64_subscription_t; -_Static_assert(offsetof(cloudabi64_subscription_t, userdata) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, unused) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, type) == 10, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.identifier) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.clock_id) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.timeout) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.precision) == 40, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.flags) == 48, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar_scope) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock_scope) == 33, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.fd) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.flags) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock_scope) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, proc_terminate.fd) == 16, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_subscription_t) == 56, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_subscription_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) uint64_t parent; -} cloudabi64_tcb_t; -_Static_assert(offsetof(cloudabi64_tcb_t, parent) == 0, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_tcb_t) == 8, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_tcb_t) == 8, "Incorrect layout"); - -typedef void cloudabi64_threadentry_t(cloudabi_tid_t tid, uint64_t aux); - -typedef struct { - _Alignas(8) uint64_t entry_point; - _Alignas(8) uint64_t stack; - _Alignas(8) uint64_t stack_len; - _Alignas(8) uint64_t argument; -} cloudabi64_threadattr_t; -_Static_assert(offsetof(cloudabi64_threadattr_t, entry_point) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, stack) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, stack_len) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, argument) == 24, "Incorrect layout"); -_Static_assert(sizeof(cloudabi64_threadattr_t) == 32, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi64_threadattr_t) == 8, "Incorrect layout"); - -#endif diff --git a/sys/contrib/cloudabi/cloudabi_types_common.h b/sys/contrib/cloudabi/cloudabi_types_common.h deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_types_common.h +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#ifndef CLOUDABI_TYPES_COMMON_H -#define CLOUDABI_TYPES_COMMON_H - -#if defined(__FreeBSD__) && defined(_KERNEL) -#include -#elif defined(__linux__) && defined(__KERNEL__) -#include -#else -#include -#include -#endif - -typedef uint8_t cloudabi_advice_t; -#define CLOUDABI_ADVICE_DONTNEED 1 -#define CLOUDABI_ADVICE_NOREUSE 2 -#define CLOUDABI_ADVICE_NORMAL 3 -#define CLOUDABI_ADVICE_RANDOM 4 -#define CLOUDABI_ADVICE_SEQUENTIAL 5 -#define CLOUDABI_ADVICE_WILLNEED 6 - -typedef uint32_t cloudabi_auxtype_t; -#define CLOUDABI_AT_ARGDATA 256 -#define CLOUDABI_AT_ARGDATALEN 257 -#define CLOUDABI_AT_BASE 7 -#define CLOUDABI_AT_CANARY 258 -#define CLOUDABI_AT_CANARYLEN 259 -#define CLOUDABI_AT_NCPUS 260 -#define CLOUDABI_AT_NULL 0 -#define CLOUDABI_AT_PAGESZ 6 -#define CLOUDABI_AT_PHDR 3 -#define CLOUDABI_AT_PHNUM 4 -#define CLOUDABI_AT_PID 263 -#define CLOUDABI_AT_SYSINFO_EHDR 262 -#define CLOUDABI_AT_TID 261 - -typedef uint32_t cloudabi_clockid_t; -#define CLOUDABI_CLOCK_MONOTONIC 1 -#define CLOUDABI_CLOCK_PROCESS_CPUTIME_ID 2 -#define CLOUDABI_CLOCK_REALTIME 3 -#define CLOUDABI_CLOCK_THREAD_CPUTIME_ID 4 - -typedef uint32_t cloudabi_condvar_t; -#define CLOUDABI_CONDVAR_HAS_NO_WAITERS 0 - -typedef uint64_t cloudabi_device_t; - -typedef uint64_t cloudabi_dircookie_t; -#define CLOUDABI_DIRCOOKIE_START 0 - -typedef uint16_t cloudabi_errno_t; -#define CLOUDABI_E2BIG 1 -#define CLOUDABI_EACCES 2 -#define CLOUDABI_EADDRINUSE 3 -#define CLOUDABI_EADDRNOTAVAIL 4 -#define CLOUDABI_EAFNOSUPPORT 5 -#define CLOUDABI_EAGAIN 6 -#define CLOUDABI_EALREADY 7 -#define CLOUDABI_EBADF 8 -#define CLOUDABI_EBADMSG 9 -#define CLOUDABI_EBUSY 10 -#define CLOUDABI_ECANCELED 11 -#define CLOUDABI_ECHILD 12 -#define CLOUDABI_ECONNABORTED 13 -#define CLOUDABI_ECONNREFUSED 14 -#define CLOUDABI_ECONNRESET 15 -#define CLOUDABI_EDEADLK 16 -#define CLOUDABI_EDESTADDRREQ 17 -#define CLOUDABI_EDOM 18 -#define CLOUDABI_EDQUOT 19 -#define CLOUDABI_EEXIST 20 -#define CLOUDABI_EFAULT 21 -#define CLOUDABI_EFBIG 22 -#define CLOUDABI_EHOSTUNREACH 23 -#define CLOUDABI_EIDRM 24 -#define CLOUDABI_EILSEQ 25 -#define CLOUDABI_EINPROGRESS 26 -#define CLOUDABI_EINTR 27 -#define CLOUDABI_EINVAL 28 -#define CLOUDABI_EIO 29 -#define CLOUDABI_EISCONN 30 -#define CLOUDABI_EISDIR 31 -#define CLOUDABI_ELOOP 32 -#define CLOUDABI_EMFILE 33 -#define CLOUDABI_EMLINK 34 -#define CLOUDABI_EMSGSIZE 35 -#define CLOUDABI_EMULTIHOP 36 -#define CLOUDABI_ENAMETOOLONG 37 -#define CLOUDABI_ENETDOWN 38 -#define CLOUDABI_ENETRESET 39 -#define CLOUDABI_ENETUNREACH 40 -#define CLOUDABI_ENFILE 41 -#define CLOUDABI_ENOBUFS 42 -#define CLOUDABI_ENODEV 43 -#define CLOUDABI_ENOENT 44 -#define CLOUDABI_ENOEXEC 45 -#define CLOUDABI_ENOLCK 46 -#define CLOUDABI_ENOLINK 47 -#define CLOUDABI_ENOMEM 48 -#define CLOUDABI_ENOMSG 49 -#define CLOUDABI_ENOPROTOOPT 50 -#define CLOUDABI_ENOSPC 51 -#define CLOUDABI_ENOSYS 52 -#define CLOUDABI_ENOTCONN 53 -#define CLOUDABI_ENOTDIR 54 -#define CLOUDABI_ENOTEMPTY 55 -#define CLOUDABI_ENOTRECOVERABLE 56 -#define CLOUDABI_ENOTSOCK 57 -#define CLOUDABI_ENOTSUP 58 -#define CLOUDABI_ENOTTY 59 -#define CLOUDABI_ENXIO 60 -#define CLOUDABI_EOVERFLOW 61 -#define CLOUDABI_EOWNERDEAD 62 -#define CLOUDABI_EPERM 63 -#define CLOUDABI_EPIPE 64 -#define CLOUDABI_EPROTO 65 -#define CLOUDABI_EPROTONOSUPPORT 66 -#define CLOUDABI_EPROTOTYPE 67 -#define CLOUDABI_ERANGE 68 -#define CLOUDABI_EROFS 69 -#define CLOUDABI_ESPIPE 70 -#define CLOUDABI_ESRCH 71 -#define CLOUDABI_ESTALE 72 -#define CLOUDABI_ETIMEDOUT 73 -#define CLOUDABI_ETXTBSY 74 -#define CLOUDABI_EXDEV 75 -#define CLOUDABI_ENOTCAPABLE 76 - -typedef uint16_t cloudabi_eventrwflags_t; -#define CLOUDABI_EVENT_FD_READWRITE_HANGUP 0x0001 - -typedef uint8_t cloudabi_eventtype_t; -#define CLOUDABI_EVENTTYPE_CLOCK 1 -#define CLOUDABI_EVENTTYPE_CONDVAR 2 -#define CLOUDABI_EVENTTYPE_FD_READ 3 -#define CLOUDABI_EVENTTYPE_FD_WRITE 4 -#define CLOUDABI_EVENTTYPE_LOCK_RDLOCK 5 -#define CLOUDABI_EVENTTYPE_LOCK_WRLOCK 6 -#define CLOUDABI_EVENTTYPE_PROC_TERMINATE 7 - -typedef uint32_t cloudabi_exitcode_t; - -typedef uint32_t cloudabi_fd_t; -#define CLOUDABI_PROCESS_CHILD 0xffffffff -#define CLOUDABI_MAP_ANON_FD 0xffffffff - -typedef uint16_t cloudabi_fdflags_t; -#define CLOUDABI_FDFLAG_APPEND 0x0001 -#define CLOUDABI_FDFLAG_DSYNC 0x0002 -#define CLOUDABI_FDFLAG_NONBLOCK 0x0004 -#define CLOUDABI_FDFLAG_RSYNC 0x0008 -#define CLOUDABI_FDFLAG_SYNC 0x0010 - -typedef uint16_t cloudabi_fdsflags_t; -#define CLOUDABI_FDSTAT_FLAGS 0x0001 -#define CLOUDABI_FDSTAT_RIGHTS 0x0002 - -typedef int64_t cloudabi_filedelta_t; - -typedef uint64_t cloudabi_filesize_t; - -typedef uint8_t cloudabi_filetype_t; -#define CLOUDABI_FILETYPE_UNKNOWN 0 -#define CLOUDABI_FILETYPE_BLOCK_DEVICE 16 -#define CLOUDABI_FILETYPE_CHARACTER_DEVICE 17 -#define CLOUDABI_FILETYPE_DIRECTORY 32 -#define CLOUDABI_FILETYPE_PROCESS 80 -#define CLOUDABI_FILETYPE_REGULAR_FILE 96 -#define CLOUDABI_FILETYPE_SHARED_MEMORY 112 -#define CLOUDABI_FILETYPE_SOCKET_DGRAM 128 -#define CLOUDABI_FILETYPE_SOCKET_STREAM 130 -#define CLOUDABI_FILETYPE_SYMBOLIC_LINK 144 - -typedef uint16_t cloudabi_fsflags_t; -#define CLOUDABI_FILESTAT_ATIM 0x0001 -#define CLOUDABI_FILESTAT_ATIM_NOW 0x0002 -#define CLOUDABI_FILESTAT_MTIM 0x0004 -#define CLOUDABI_FILESTAT_MTIM_NOW 0x0008 -#define CLOUDABI_FILESTAT_SIZE 0x0010 - -typedef uint64_t cloudabi_inode_t; - -typedef uint32_t cloudabi_linkcount_t; - -typedef uint32_t cloudabi_lock_t; -#define CLOUDABI_LOCK_UNLOCKED 0x00000000 -#define CLOUDABI_LOCK_WRLOCKED 0x40000000 -#define CLOUDABI_LOCK_KERNEL_MANAGED 0x80000000 -#define CLOUDABI_LOCK_BOGUS 0x80000000 - -typedef uint32_t cloudabi_lookupflags_t; -#define CLOUDABI_LOOKUP_SYMLINK_FOLLOW 0x00000001 - -typedef uint8_t cloudabi_mflags_t; -#define CLOUDABI_MAP_ANON 0x01 -#define CLOUDABI_MAP_FIXED 0x02 -#define CLOUDABI_MAP_PRIVATE 0x04 -#define CLOUDABI_MAP_SHARED 0x08 - -typedef uint8_t cloudabi_mprot_t; -#define CLOUDABI_PROT_EXEC 0x01 -#define CLOUDABI_PROT_WRITE 0x02 -#define CLOUDABI_PROT_READ 0x04 - -typedef uint8_t cloudabi_msflags_t; -#define CLOUDABI_MS_ASYNC 0x01 -#define CLOUDABI_MS_INVALIDATE 0x02 -#define CLOUDABI_MS_SYNC 0x04 - -typedef uint32_t cloudabi_nthreads_t; - -typedef uint16_t cloudabi_oflags_t; -#define CLOUDABI_O_CREAT 0x0001 -#define CLOUDABI_O_DIRECTORY 0x0002 -#define CLOUDABI_O_EXCL 0x0004 -#define CLOUDABI_O_TRUNC 0x0008 - -typedef uint16_t cloudabi_riflags_t; -#define CLOUDABI_SOCK_RECV_PEEK 0x0004 -#define CLOUDABI_SOCK_RECV_WAITALL 0x0010 - -typedef uint64_t cloudabi_rights_t; -#define CLOUDABI_RIGHT_FD_DATASYNC 0x0000000000000001 -#define CLOUDABI_RIGHT_FD_READ 0x0000000000000002 -#define CLOUDABI_RIGHT_FD_SEEK 0x0000000000000004 -#define CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS 0x0000000000000008 -#define CLOUDABI_RIGHT_FD_SYNC 0x0000000000000010 -#define CLOUDABI_RIGHT_FD_TELL 0x0000000000000020 -#define CLOUDABI_RIGHT_FD_WRITE 0x0000000000000040 -#define CLOUDABI_RIGHT_FILE_ADVISE 0x0000000000000080 -#define CLOUDABI_RIGHT_FILE_ALLOCATE 0x0000000000000100 -#define CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY 0x0000000000000200 -#define CLOUDABI_RIGHT_FILE_CREATE_FILE 0x0000000000000400 -#define CLOUDABI_RIGHT_FILE_LINK_SOURCE 0x0000000000001000 -#define CLOUDABI_RIGHT_FILE_LINK_TARGET 0x0000000000002000 -#define CLOUDABI_RIGHT_FILE_OPEN 0x0000000000004000 -#define CLOUDABI_RIGHT_FILE_READDIR 0x0000000000008000 -#define CLOUDABI_RIGHT_FILE_READLINK 0x0000000000010000 -#define CLOUDABI_RIGHT_FILE_RENAME_SOURCE 0x0000000000020000 -#define CLOUDABI_RIGHT_FILE_RENAME_TARGET 0x0000000000040000 -#define CLOUDABI_RIGHT_FILE_STAT_FGET 0x0000000000080000 -#define CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE 0x0000000000100000 -#define CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES 0x0000000000200000 -#define CLOUDABI_RIGHT_FILE_STAT_GET 0x0000000000400000 -#define CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES 0x0000000000800000 -#define CLOUDABI_RIGHT_FILE_SYMLINK 0x0000000001000000 -#define CLOUDABI_RIGHT_FILE_UNLINK 0x0000000002000000 -#define CLOUDABI_RIGHT_MEM_MAP 0x0000000004000000 -#define CLOUDABI_RIGHT_MEM_MAP_EXEC 0x0000000008000000 -#define CLOUDABI_RIGHT_POLL_FD_READWRITE 0x0000000010000000 -#define CLOUDABI_RIGHT_POLL_PROC_TERMINATE 0x0000000040000000 -#define CLOUDABI_RIGHT_PROC_EXEC 0x0000000100000000 -#define CLOUDABI_RIGHT_SOCK_SHUTDOWN 0x0000008000000000 - -typedef uint16_t cloudabi_roflags_t; -#define CLOUDABI_SOCK_RECV_FDS_TRUNCATED 0x0001 -#define CLOUDABI_SOCK_RECV_DATA_TRUNCATED 0x0008 - -typedef uint8_t cloudabi_scope_t; -#define CLOUDABI_SCOPE_PRIVATE 4 -#define CLOUDABI_SCOPE_SHARED 8 - -typedef uint8_t cloudabi_sdflags_t; -#define CLOUDABI_SHUT_RD 0x01 -#define CLOUDABI_SHUT_WR 0x02 - -typedef uint16_t cloudabi_siflags_t; - -typedef uint8_t cloudabi_signal_t; -#define CLOUDABI_SIGABRT 1 -#define CLOUDABI_SIGALRM 2 -#define CLOUDABI_SIGBUS 3 -#define CLOUDABI_SIGCHLD 4 -#define CLOUDABI_SIGCONT 5 -#define CLOUDABI_SIGFPE 6 -#define CLOUDABI_SIGHUP 7 -#define CLOUDABI_SIGILL 8 -#define CLOUDABI_SIGINT 9 -#define CLOUDABI_SIGKILL 10 -#define CLOUDABI_SIGPIPE 11 -#define CLOUDABI_SIGQUIT 12 -#define CLOUDABI_SIGSEGV 13 -#define CLOUDABI_SIGSTOP 14 -#define CLOUDABI_SIGSYS 15 -#define CLOUDABI_SIGTERM 16 -#define CLOUDABI_SIGTRAP 17 -#define CLOUDABI_SIGTSTP 18 -#define CLOUDABI_SIGTTIN 19 -#define CLOUDABI_SIGTTOU 20 -#define CLOUDABI_SIGURG 21 -#define CLOUDABI_SIGUSR1 22 -#define CLOUDABI_SIGUSR2 23 -#define CLOUDABI_SIGVTALRM 24 -#define CLOUDABI_SIGXCPU 25 -#define CLOUDABI_SIGXFSZ 26 - -typedef uint16_t cloudabi_subclockflags_t; -#define CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME 0x0001 - -typedef uint16_t cloudabi_subrwflags_t; -#define CLOUDABI_SUBSCRIPTION_FD_READWRITE_POLL 0x0001 - -typedef uint32_t cloudabi_tid_t; - -typedef uint64_t cloudabi_timestamp_t; - -typedef uint8_t cloudabi_ulflags_t; -#define CLOUDABI_UNLINK_REMOVEDIR 0x01 - -typedef uint64_t cloudabi_userdata_t; - -typedef uint8_t cloudabi_whence_t; -#define CLOUDABI_WHENCE_CUR 1 -#define CLOUDABI_WHENCE_END 2 -#define CLOUDABI_WHENCE_SET 3 - -typedef struct { - _Alignas(8) cloudabi_dircookie_t d_next; - _Alignas(8) cloudabi_inode_t d_ino; - _Alignas(4) uint32_t d_namlen; - _Alignas(1) cloudabi_filetype_t d_type; -} cloudabi_dirent_t; -_Static_assert(offsetof(cloudabi_dirent_t, d_next) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_dirent_t, d_ino) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_dirent_t, d_namlen) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_dirent_t, d_type) == 20, "Incorrect layout"); -_Static_assert(sizeof(cloudabi_dirent_t) == 24, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi_dirent_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) cloudabi_userdata_t userdata; - _Alignas(2) cloudabi_errno_t error; - _Alignas(1) cloudabi_eventtype_t type; - union { - struct { - _Alignas(8) cloudabi_filesize_t nbytes; - _Alignas(1) char unused[4]; - _Alignas(2) cloudabi_eventrwflags_t flags; - } fd_readwrite; - struct { - _Alignas(1) char unused[4]; - _Alignas(1) cloudabi_signal_t signal; - _Alignas(4) cloudabi_exitcode_t exitcode; - } proc_terminate; - }; -} cloudabi_event_t; -_Static_assert(offsetof(cloudabi_event_t, userdata) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, error) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, type) == 10, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, fd_readwrite.nbytes) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, fd_readwrite.unused) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, fd_readwrite.flags) == 28, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, proc_terminate.unused) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, proc_terminate.signal) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_event_t, proc_terminate.exitcode) == 24, "Incorrect layout"); -_Static_assert(sizeof(cloudabi_event_t) == 32, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi_event_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(1) cloudabi_filetype_t fs_filetype; - _Alignas(2) cloudabi_fdflags_t fs_flags; - _Alignas(8) cloudabi_rights_t fs_rights_base; - _Alignas(8) cloudabi_rights_t fs_rights_inheriting; -} cloudabi_fdstat_t; -_Static_assert(offsetof(cloudabi_fdstat_t, fs_filetype) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_flags) == 2, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_base) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_inheriting) == 16, "Incorrect layout"); -_Static_assert(sizeof(cloudabi_fdstat_t) == 24, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi_fdstat_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(8) cloudabi_device_t st_dev; - _Alignas(8) cloudabi_inode_t st_ino; - _Alignas(1) cloudabi_filetype_t st_filetype; - _Alignas(4) cloudabi_linkcount_t st_nlink; - _Alignas(8) cloudabi_filesize_t st_size; - _Alignas(8) cloudabi_timestamp_t st_atim; - _Alignas(8) cloudabi_timestamp_t st_mtim; - _Alignas(8) cloudabi_timestamp_t st_ctim; -} cloudabi_filestat_t; -_Static_assert(offsetof(cloudabi_filestat_t, st_dev) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_ino) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_filetype) == 16, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_nlink) == 20, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_size) == 24, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_atim) == 32, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_mtim) == 40, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_ctim) == 48, "Incorrect layout"); -_Static_assert(sizeof(cloudabi_filestat_t) == 56, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi_filestat_t) == 8, "Incorrect layout"); - -typedef struct { - _Alignas(4) cloudabi_fd_t fd; - _Alignas(4) cloudabi_lookupflags_t flags; -} cloudabi_lookup_t; -_Static_assert(offsetof(cloudabi_lookup_t, fd) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_lookup_t, flags) == 4, "Incorrect layout"); -_Static_assert(sizeof(cloudabi_lookup_t) == 8, "Incorrect layout"); -_Static_assert(_Alignof(cloudabi_lookup_t) == 4, "Incorrect layout"); - -#endif diff --git a/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S b/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_vdso_aarch64.S +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#define ENTRY(name) \ - .text; \ - .p2align 2; \ - .global name; \ - .type name, @function; \ -name: - -#define END(name) .size name, . - name - -ENTRY(cloudabi_sys_clock_res_get) - str x1, [sp, #-8] - mov w8, #0 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_clock_res_get) - -ENTRY(cloudabi_sys_clock_time_get) - str x2, [sp, #-8] - mov w8, #1 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_clock_time_get) - -ENTRY(cloudabi_sys_condvar_signal) - mov w8, #2 - svc #0 - ret -END(cloudabi_sys_condvar_signal) - -ENTRY(cloudabi_sys_fd_close) - mov w8, #3 - svc #0 - ret -END(cloudabi_sys_fd_close) - -ENTRY(cloudabi_sys_fd_create1) - str x1, [sp, #-8] - mov w8, #4 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str w0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_create1) - -ENTRY(cloudabi_sys_fd_create2) - stp x1, x2, [sp, #-16] - mov w8, #5 - svc #0 - ldp x2, x3, [sp, #-16] - b.cs 1f - str w0, [x2] - str w1, [x3] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_create2) - -ENTRY(cloudabi_sys_fd_datasync) - mov w8, #6 - svc #0 - ret -END(cloudabi_sys_fd_datasync) - -ENTRY(cloudabi_sys_fd_dup) - str x1, [sp, #-8] - mov w8, #7 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str w0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_dup) - -ENTRY(cloudabi_sys_fd_pread) - str x4, [sp, #-8] - mov w8, #8 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_pread) - -ENTRY(cloudabi_sys_fd_pwrite) - str x4, [sp, #-8] - mov w8, #9 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_pwrite) - -ENTRY(cloudabi_sys_fd_read) - str x3, [sp, #-8] - mov w8, #10 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_read) - -ENTRY(cloudabi_sys_fd_replace) - mov w8, #11 - svc #0 - ret -END(cloudabi_sys_fd_replace) - -ENTRY(cloudabi_sys_fd_seek) - str x3, [sp, #-8] - mov w8, #12 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_seek) - -ENTRY(cloudabi_sys_fd_stat_get) - mov w8, #13 - svc #0 - ret -END(cloudabi_sys_fd_stat_get) - -ENTRY(cloudabi_sys_fd_stat_put) - mov w8, #14 - svc #0 - ret -END(cloudabi_sys_fd_stat_put) - -ENTRY(cloudabi_sys_fd_sync) - mov w8, #15 - svc #0 - ret -END(cloudabi_sys_fd_sync) - -ENTRY(cloudabi_sys_fd_write) - str x3, [sp, #-8] - mov w8, #16 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_fd_write) - -ENTRY(cloudabi_sys_file_advise) - mov w8, #17 - svc #0 - ret -END(cloudabi_sys_file_advise) - -ENTRY(cloudabi_sys_file_allocate) - mov w8, #18 - svc #0 - ret -END(cloudabi_sys_file_allocate) - -ENTRY(cloudabi_sys_file_create) - mov w8, #19 - svc #0 - ret -END(cloudabi_sys_file_create) - -ENTRY(cloudabi_sys_file_link) - mov w8, #20 - svc #0 - ret -END(cloudabi_sys_file_link) - -ENTRY(cloudabi_sys_file_open) - str x5, [sp, #-8] - mov w8, #21 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str w0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_file_open) - -ENTRY(cloudabi_sys_file_readdir) - str x4, [sp, #-8] - mov w8, #22 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_file_readdir) - -ENTRY(cloudabi_sys_file_readlink) - str x5, [sp, #-8] - mov w8, #23 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_file_readlink) - -ENTRY(cloudabi_sys_file_rename) - mov w8, #24 - svc #0 - ret -END(cloudabi_sys_file_rename) - -ENTRY(cloudabi_sys_file_stat_fget) - mov w8, #25 - svc #0 - ret -END(cloudabi_sys_file_stat_fget) - -ENTRY(cloudabi_sys_file_stat_fput) - mov w8, #26 - svc #0 - ret -END(cloudabi_sys_file_stat_fput) - -ENTRY(cloudabi_sys_file_stat_get) - mov w8, #27 - svc #0 - ret -END(cloudabi_sys_file_stat_get) - -ENTRY(cloudabi_sys_file_stat_put) - mov w8, #28 - svc #0 - ret -END(cloudabi_sys_file_stat_put) - -ENTRY(cloudabi_sys_file_symlink) - mov w8, #29 - svc #0 - ret -END(cloudabi_sys_file_symlink) - -ENTRY(cloudabi_sys_file_unlink) - mov w8, #30 - svc #0 - ret -END(cloudabi_sys_file_unlink) - -ENTRY(cloudabi_sys_lock_unlock) - mov w8, #31 - svc #0 - ret -END(cloudabi_sys_lock_unlock) - -ENTRY(cloudabi_sys_mem_advise) - mov w8, #32 - svc #0 - ret -END(cloudabi_sys_mem_advise) - -ENTRY(cloudabi_sys_mem_map) - str x6, [sp, #-8] - mov w8, #33 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_mem_map) - -ENTRY(cloudabi_sys_mem_protect) - mov w8, #34 - svc #0 - ret -END(cloudabi_sys_mem_protect) - -ENTRY(cloudabi_sys_mem_sync) - mov w8, #35 - svc #0 - ret -END(cloudabi_sys_mem_sync) - -ENTRY(cloudabi_sys_mem_unmap) - mov w8, #36 - svc #0 - ret -END(cloudabi_sys_mem_unmap) - -ENTRY(cloudabi_sys_poll) - str x3, [sp, #-8] - mov w8, #37 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str x0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_poll) - -ENTRY(cloudabi_sys_proc_exec) - mov w8, #38 - svc #0 - ret -END(cloudabi_sys_proc_exec) - -ENTRY(cloudabi_sys_proc_exit) - mov w8, #39 - svc #0 -END(cloudabi_sys_proc_exit) - -ENTRY(cloudabi_sys_proc_fork) - stp x0, x1, [sp, #-16] - mov w8, #40 - svc #0 - ldp x2, x3, [sp, #-16] - b.cs 1f - str w0, [x2] - str w1, [x3] - mov w0, wzr -1: - ret -END(cloudabi_sys_proc_fork) - -ENTRY(cloudabi_sys_proc_raise) - mov w8, #41 - svc #0 - ret -END(cloudabi_sys_proc_raise) - -ENTRY(cloudabi_sys_random_get) - mov w8, #42 - svc #0 - ret -END(cloudabi_sys_random_get) - -ENTRY(cloudabi_sys_sock_recv) - mov w8, #43 - svc #0 - ret -END(cloudabi_sys_sock_recv) - -ENTRY(cloudabi_sys_sock_send) - mov w8, #44 - svc #0 - ret -END(cloudabi_sys_sock_send) - -ENTRY(cloudabi_sys_sock_shutdown) - mov w8, #45 - svc #0 - ret -END(cloudabi_sys_sock_shutdown) - -ENTRY(cloudabi_sys_thread_create) - str x1, [sp, #-8] - mov w8, #46 - svc #0 - ldr x2, [sp, #-8] - b.cs 1f - str w0, [x2] - mov w0, wzr -1: - ret -END(cloudabi_sys_thread_create) - -ENTRY(cloudabi_sys_thread_exit) - mov w8, #47 - svc #0 -END(cloudabi_sys_thread_exit) - -ENTRY(cloudabi_sys_thread_yield) - mov w8, #48 - svc #0 - ret -END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_armv6.S b/sys/contrib/cloudabi/cloudabi_vdso_armv6.S deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_vdso_armv6.S +++ /dev/null @@ -1,396 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#define ENTRY(name) \ - .text; \ - .p2align 2; \ - .global name; \ - .type name, %function; \ -name: - -#define END(name) .size name, . - name - -ENTRY(cloudabi_sys_clock_res_get) - str r1, [sp, #-4] - mov ip, #0 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2, #0] - strcc r1, [r2, #4] - movcc r0, #0 - bx lr -END(cloudabi_sys_clock_res_get) - -ENTRY(cloudabi_sys_clock_time_get) - mov ip, #1 - swi 0 - ldrcc r2, [sp, #0] - strcc r0, [r2, #0] - strcc r1, [r2, #4] - movcc r0, #0 - bx lr -END(cloudabi_sys_clock_time_get) - -ENTRY(cloudabi_sys_condvar_signal) - mov ip, #2 - swi 0 - bx lr -END(cloudabi_sys_condvar_signal) - -ENTRY(cloudabi_sys_fd_close) - mov ip, #3 - swi 0 - bx lr -END(cloudabi_sys_fd_close) - -ENTRY(cloudabi_sys_fd_create1) - str r1, [sp, #-4] - mov ip, #4 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_create1) - -ENTRY(cloudabi_sys_fd_create2) - str r1, [sp, #-4] - str r2, [sp, #-8] - mov ip, #5 - swi 0 - ldrcc r2, [sp, #-4] - ldrcc r3, [sp, #-8] - strcc r0, [r2] - strcc r1, [r3] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_create2) - -ENTRY(cloudabi_sys_fd_datasync) - mov ip, #6 - swi 0 - bx lr -END(cloudabi_sys_fd_datasync) - -ENTRY(cloudabi_sys_fd_dup) - str r1, [sp, #-4] - mov ip, #7 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_dup) - -ENTRY(cloudabi_sys_fd_pread) - mov ip, #8 - swi 0 - ldrcc r2, [sp, #8] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_pread) - -ENTRY(cloudabi_sys_fd_pwrite) - mov ip, #9 - swi 0 - ldrcc r2, [sp, #8] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_pwrite) - -ENTRY(cloudabi_sys_fd_read) - str r3, [sp, #-4] - mov ip, #10 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_read) - -ENTRY(cloudabi_sys_fd_replace) - mov ip, #11 - swi 0 - bx lr -END(cloudabi_sys_fd_replace) - -ENTRY(cloudabi_sys_fd_seek) - mov ip, #12 - swi 0 - ldrcc r2, [sp, #4] - strcc r0, [r2, #0] - strcc r1, [r2, #4] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_seek) - -ENTRY(cloudabi_sys_fd_stat_get) - mov ip, #13 - swi 0 - bx lr -END(cloudabi_sys_fd_stat_get) - -ENTRY(cloudabi_sys_fd_stat_put) - mov ip, #14 - swi 0 - bx lr -END(cloudabi_sys_fd_stat_put) - -ENTRY(cloudabi_sys_fd_sync) - mov ip, #15 - swi 0 - bx lr -END(cloudabi_sys_fd_sync) - -ENTRY(cloudabi_sys_fd_write) - str r3, [sp, #-4] - mov ip, #16 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_fd_write) - -ENTRY(cloudabi_sys_file_advise) - mov ip, #17 - swi 0 - bx lr -END(cloudabi_sys_file_advise) - -ENTRY(cloudabi_sys_file_allocate) - mov ip, #18 - swi 0 - bx lr -END(cloudabi_sys_file_allocate) - -ENTRY(cloudabi_sys_file_create) - mov ip, #19 - swi 0 - bx lr -END(cloudabi_sys_file_create) - -ENTRY(cloudabi_sys_file_link) - mov ip, #20 - swi 0 - bx lr -END(cloudabi_sys_file_link) - -ENTRY(cloudabi_sys_file_open) - mov ip, #21 - swi 0 - ldrcc r2, [sp, #8] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_file_open) - -ENTRY(cloudabi_sys_file_readdir) - mov ip, #22 - swi 0 - ldrcc r2, [sp, #8] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_file_readdir) - -ENTRY(cloudabi_sys_file_readlink) - mov ip, #23 - swi 0 - ldrcc r2, [sp, #4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_file_readlink) - -ENTRY(cloudabi_sys_file_rename) - mov ip, #24 - swi 0 - bx lr -END(cloudabi_sys_file_rename) - -ENTRY(cloudabi_sys_file_stat_fget) - mov ip, #25 - swi 0 - bx lr -END(cloudabi_sys_file_stat_fget) - -ENTRY(cloudabi_sys_file_stat_fput) - mov ip, #26 - swi 0 - bx lr -END(cloudabi_sys_file_stat_fput) - -ENTRY(cloudabi_sys_file_stat_get) - mov ip, #27 - swi 0 - bx lr -END(cloudabi_sys_file_stat_get) - -ENTRY(cloudabi_sys_file_stat_put) - mov ip, #28 - swi 0 - bx lr -END(cloudabi_sys_file_stat_put) - -ENTRY(cloudabi_sys_file_symlink) - mov ip, #29 - swi 0 - bx lr -END(cloudabi_sys_file_symlink) - -ENTRY(cloudabi_sys_file_unlink) - mov ip, #30 - swi 0 - bx lr -END(cloudabi_sys_file_unlink) - -ENTRY(cloudabi_sys_lock_unlock) - mov ip, #31 - swi 0 - bx lr -END(cloudabi_sys_lock_unlock) - -ENTRY(cloudabi_sys_mem_advise) - mov ip, #32 - swi 0 - bx lr -END(cloudabi_sys_mem_advise) - -ENTRY(cloudabi_sys_mem_map) - mov ip, #33 - swi 0 - ldrcc r2, [sp, #16] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_mem_map) - -ENTRY(cloudabi_sys_mem_protect) - mov ip, #34 - swi 0 - bx lr -END(cloudabi_sys_mem_protect) - -ENTRY(cloudabi_sys_mem_sync) - mov ip, #35 - swi 0 - bx lr -END(cloudabi_sys_mem_sync) - -ENTRY(cloudabi_sys_mem_unmap) - mov ip, #36 - swi 0 - bx lr -END(cloudabi_sys_mem_unmap) - -ENTRY(cloudabi_sys_poll) - str r3, [sp, #-4] - mov ip, #37 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_poll) - -ENTRY(cloudabi_sys_proc_exec) - mov ip, #38 - swi 0 - bx lr -END(cloudabi_sys_proc_exec) - -ENTRY(cloudabi_sys_proc_exit) - mov ip, #39 - swi 0 -END(cloudabi_sys_proc_exit) - -ENTRY(cloudabi_sys_proc_fork) - str r0, [sp, #-4] - str r1, [sp, #-8] - mov ip, #40 - swi 0 - ldrcc r2, [sp, #-4] - ldrcc r3, [sp, #-8] - strcc r0, [r2] - strcc r1, [r3] - movcc r0, #0 - bx lr -END(cloudabi_sys_proc_fork) - -ENTRY(cloudabi_sys_proc_raise) - mov ip, #41 - swi 0 - bx lr -END(cloudabi_sys_proc_raise) - -ENTRY(cloudabi_sys_random_get) - mov ip, #42 - swi 0 - bx lr -END(cloudabi_sys_random_get) - -ENTRY(cloudabi_sys_sock_recv) - mov ip, #43 - swi 0 - bx lr -END(cloudabi_sys_sock_recv) - -ENTRY(cloudabi_sys_sock_send) - mov ip, #44 - swi 0 - bx lr -END(cloudabi_sys_sock_send) - -ENTRY(cloudabi_sys_sock_shutdown) - mov ip, #45 - swi 0 - bx lr -END(cloudabi_sys_sock_shutdown) - -ENTRY(cloudabi_sys_thread_create) - str r1, [sp, #-4] - mov ip, #46 - swi 0 - ldrcc r2, [sp, #-4] - strcc r0, [r2] - movcc r0, #0 - bx lr -END(cloudabi_sys_thread_create) - -ENTRY(cloudabi_sys_thread_exit) - mov ip, #47 - swi 0 -END(cloudabi_sys_thread_exit) - -ENTRY(cloudabi_sys_thread_yield) - mov ip, #48 - swi 0 - bx lr -END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S b/sys/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S +++ /dev/null @@ -1,732 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#define ENTRY(name) \ - .text; \ - .p2align 2; \ - .global name; \ - .type name, %function; \ -name: - -#define END(name) .size name, . - name - -ENTRY(cloudabi_sys_clock_res_get) - str r0, [sp, #-16] - str r1, [sp, #-20] - mov r0, #0 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #-20] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - ldrcc r2, [sp, #-12] - strcc r2, [r1, #4] - bx lr -END(cloudabi_sys_clock_res_get) - -ENTRY(cloudabi_sys_clock_time_get) - str r0, [sp, #-16] - str r2, [sp, #-8] - str r3, [sp, #-4] - mov r0, #1 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #0] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - ldrcc r2, [sp, #-12] - strcc r2, [r1, #4] - bx lr -END(cloudabi_sys_clock_time_get) - -ENTRY(cloudabi_sys_condvar_signal) - str r0, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r1, [sp, #-16] - str r2, [sp, #-8] - mov r0, #2 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_condvar_signal) - -ENTRY(cloudabi_sys_fd_close) - str r0, [sp, #-16] - mov r0, #3 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_fd_close) - -ENTRY(cloudabi_sys_fd_create1) - str r0, [sp, #-16] - str r1, [sp, #-20] - mov r0, #4 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #-20] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_create1) - -ENTRY(cloudabi_sys_fd_create2) - str r0, [sp, #-16] - str r1, [sp, #-20] - str r2, [sp, #-24] - mov r0, #5 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #-20] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - ldrcc r1, [sp, #-24] - ldrcc r2, [sp, #-8] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_create2) - -ENTRY(cloudabi_sys_fd_datasync) - str r0, [sp, #-16] - mov r0, #6 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_fd_datasync) - -ENTRY(cloudabi_sys_fd_dup) - str r0, [sp, #-16] - str r1, [sp, #-20] - mov r0, #7 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #-20] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_dup) - -ENTRY(cloudabi_sys_fd_pread) - str r0, [sp, #-32] - str r1, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r2, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - ldr r1, [sp, #4] - str r1, [sp, #-4] - mov r0, #8 - sub r2, sp, #32 - swi 0 - ldrcc r1, [sp, #8] - ldrcc r2, [sp, #-32] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_pread) - -ENTRY(cloudabi_sys_fd_pwrite) - str r0, [sp, #-32] - str r1, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r2, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - ldr r1, [sp, #4] - str r1, [sp, #-4] - mov r0, #9 - sub r2, sp, #32 - swi 0 - ldrcc r1, [sp, #8] - ldrcc r2, [sp, #-32] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_pwrite) - -ENTRY(cloudabi_sys_fd_read) - str r0, [sp, #-24] - str r1, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r2, [sp, #-8] - str r0, [sp, #-4] - str r3, [sp, #-28] - mov r0, #10 - sub r2, sp, #24 - swi 0 - ldrcc r1, [sp, #-28] - ldrcc r2, [sp, #-24] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_read) - -ENTRY(cloudabi_sys_fd_replace) - str r0, [sp, #-16] - str r1, [sp, #-8] - mov r0, #11 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_fd_replace) - -ENTRY(cloudabi_sys_fd_seek) - str r0, [sp, #-24] - str r2, [sp, #-16] - str r3, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - mov r0, #12 - sub r2, sp, #24 - swi 0 - ldrcc r1, [sp, #4] - ldrcc r2, [sp, #-24] - strcc r2, [r1, #0] - ldrcc r2, [sp, #-20] - strcc r2, [r1, #4] - bx lr -END(cloudabi_sys_fd_seek) - -ENTRY(cloudabi_sys_fd_stat_get) - str r0, [sp, #-16] - str r1, [sp, #-8] - mov r0, #0 - str r0, [sp, #-4] - mov r0, #13 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_fd_stat_get) - -ENTRY(cloudabi_sys_fd_stat_put) - str r0, [sp, #-24] - str r1, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r2, [sp, #-8] - mov r0, #14 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_fd_stat_put) - -ENTRY(cloudabi_sys_fd_sync) - str r0, [sp, #-16] - mov r0, #15 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_fd_sync) - -ENTRY(cloudabi_sys_fd_write) - str r0, [sp, #-24] - str r1, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r2, [sp, #-8] - str r0, [sp, #-4] - str r3, [sp, #-28] - mov r0, #16 - sub r2, sp, #24 - swi 0 - ldrcc r1, [sp, #-28] - ldrcc r2, [sp, #-24] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_fd_write) - -ENTRY(cloudabi_sys_file_advise) - str r0, [sp, #-32] - str r2, [sp, #-24] - str r3, [sp, #-20] - ldr r1, [sp, #0] - str r1, [sp, #-16] - ldr r1, [sp, #4] - str r1, [sp, #-12] - ldr r1, [sp, #8] - str r1, [sp, #-8] - mov r0, #17 - sub r2, sp, #32 - swi 0 - bx lr -END(cloudabi_sys_file_advise) - -ENTRY(cloudabi_sys_file_allocate) - str r0, [sp, #-24] - str r2, [sp, #-16] - str r3, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - ldr r1, [sp, #4] - str r1, [sp, #-4] - mov r0, #18 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_file_allocate) - -ENTRY(cloudabi_sys_file_create) - str r0, [sp, #-32] - str r1, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r2, [sp, #-16] - str r0, [sp, #-12] - str r3, [sp, #-8] - mov r0, #19 - sub r2, sp, #32 - swi 0 - bx lr -END(cloudabi_sys_file_create) - -ENTRY(cloudabi_sys_file_link) - str r0, [sp, #-48] - str r1, [sp, #-44] - str r2, [sp, #-40] - mov r0, #0 - str r0, [sp, #-36] - str r3, [sp, #-32] - str r0, [sp, #-28] - ldr r1, [sp, #0] - str r1, [sp, #-24] - ldr r1, [sp, #4] - str r1, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #8] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #20 - sub r2, sp, #48 - swi 0 - bx lr -END(cloudabi_sys_file_link) - -ENTRY(cloudabi_sys_file_open) - str r0, [sp, #-40] - str r1, [sp, #-36] - str r2, [sp, #-32] - mov r0, #0 - str r0, [sp, #-28] - str r3, [sp, #-24] - str r0, [sp, #-20] - ldr r1, [sp, #0] - str r1, [sp, #-16] - ldr r1, [sp, #4] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #21 - sub r2, sp, #40 - swi 0 - ldrcc r1, [sp, #8] - ldrcc r2, [sp, #-40] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_file_open) - -ENTRY(cloudabi_sys_file_readdir) - str r0, [sp, #-32] - str r1, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r2, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - ldr r1, [sp, #4] - str r1, [sp, #-4] - mov r0, #22 - sub r2, sp, #32 - swi 0 - ldrcc r1, [sp, #8] - ldrcc r2, [sp, #-32] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_file_readdir) - -ENTRY(cloudabi_sys_file_readlink) - str r0, [sp, #-40] - str r1, [sp, #-32] - mov r0, #0 - str r0, [sp, #-28] - str r2, [sp, #-24] - str r0, [sp, #-20] - str r3, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #23 - sub r2, sp, #40 - swi 0 - ldrcc r1, [sp, #4] - ldrcc r2, [sp, #-40] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_file_readlink) - -ENTRY(cloudabi_sys_file_rename) - str r0, [sp, #-48] - str r1, [sp, #-40] - mov r0, #0 - str r0, [sp, #-36] - str r2, [sp, #-32] - str r0, [sp, #-28] - str r3, [sp, #-24] - ldr r1, [sp, #0] - str r1, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #4] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #24 - sub r2, sp, #48 - swi 0 - bx lr -END(cloudabi_sys_file_rename) - -ENTRY(cloudabi_sys_file_stat_fget) - str r0, [sp, #-16] - str r1, [sp, #-8] - mov r0, #0 - str r0, [sp, #-4] - mov r0, #25 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_file_stat_fget) - -ENTRY(cloudabi_sys_file_stat_fput) - str r0, [sp, #-24] - str r1, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r2, [sp, #-8] - mov r0, #26 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_file_stat_fput) - -ENTRY(cloudabi_sys_file_stat_get) - str r0, [sp, #-32] - str r1, [sp, #-28] - str r2, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r3, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #27 - sub r2, sp, #32 - swi 0 - bx lr -END(cloudabi_sys_file_stat_get) - -ENTRY(cloudabi_sys_file_stat_put) - str r0, [sp, #-40] - str r1, [sp, #-36] - str r2, [sp, #-32] - mov r0, #0 - str r0, [sp, #-28] - str r3, [sp, #-24] - str r0, [sp, #-20] - ldr r1, [sp, #0] - str r1, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #4] - str r1, [sp, #-8] - mov r0, #28 - sub r2, sp, #40 - swi 0 - bx lr -END(cloudabi_sys_file_stat_put) - -ENTRY(cloudabi_sys_file_symlink) - str r0, [sp, #-40] - mov r0, #0 - str r0, [sp, #-36] - str r1, [sp, #-32] - str r0, [sp, #-28] - str r2, [sp, #-24] - str r3, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #29 - sub r2, sp, #40 - swi 0 - bx lr -END(cloudabi_sys_file_symlink) - -ENTRY(cloudabi_sys_file_unlink) - str r0, [sp, #-32] - str r1, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r2, [sp, #-16] - str r0, [sp, #-12] - str r3, [sp, #-8] - mov r0, #30 - sub r2, sp, #32 - swi 0 - bx lr -END(cloudabi_sys_file_unlink) - -ENTRY(cloudabi_sys_lock_unlock) - str r0, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r1, [sp, #-8] - mov r0, #31 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_lock_unlock) - -ENTRY(cloudabi_sys_mem_advise) - str r0, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r1, [sp, #-16] - str r0, [sp, #-12] - str r2, [sp, #-8] - mov r0, #32 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_mem_advise) - -ENTRY(cloudabi_sys_mem_map) - str r0, [sp, #-48] - mov r0, #0 - str r0, [sp, #-44] - str r1, [sp, #-40] - str r0, [sp, #-36] - str r2, [sp, #-32] - str r3, [sp, #-24] - ldr r1, [sp, #0] - str r1, [sp, #-16] - ldr r1, [sp, #8] - str r1, [sp, #-8] - ldr r1, [sp, #12] - str r1, [sp, #-4] - mov r0, #33 - sub r2, sp, #48 - swi 0 - ldrcc r1, [sp, #16] - ldrcc r2, [sp, #-48] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_mem_map) - -ENTRY(cloudabi_sys_mem_protect) - str r0, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r1, [sp, #-16] - str r0, [sp, #-12] - str r2, [sp, #-8] - mov r0, #34 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_mem_protect) - -ENTRY(cloudabi_sys_mem_sync) - str r0, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r1, [sp, #-16] - str r0, [sp, #-12] - str r2, [sp, #-8] - mov r0, #35 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_mem_sync) - -ENTRY(cloudabi_sys_mem_unmap) - str r0, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #36 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_mem_unmap) - -ENTRY(cloudabi_sys_poll) - str r0, [sp, #-24] - mov r0, #0 - str r0, [sp, #-20] - str r1, [sp, #-16] - str r0, [sp, #-12] - str r2, [sp, #-8] - str r0, [sp, #-4] - str r3, [sp, #-28] - mov r0, #37 - sub r2, sp, #24 - swi 0 - ldrcc r1, [sp, #-28] - ldrcc r2, [sp, #-24] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_poll) - -ENTRY(cloudabi_sys_proc_exec) - str r0, [sp, #-40] - str r1, [sp, #-32] - mov r0, #0 - str r0, [sp, #-28] - str r2, [sp, #-24] - str r0, [sp, #-20] - str r3, [sp, #-16] - str r0, [sp, #-12] - ldr r1, [sp, #0] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #38 - sub r2, sp, #40 - swi 0 - bx lr -END(cloudabi_sys_proc_exec) - -ENTRY(cloudabi_sys_proc_exit) - str r0, [sp, #-16] - mov r0, #39 - sub r2, sp, #16 - swi 0 -END(cloudabi_sys_proc_exit) - -ENTRY(cloudabi_sys_proc_fork) - str r0, [sp, #-20] - str r1, [sp, #-24] - mov r0, #40 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #-20] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - ldrcc r1, [sp, #-24] - ldrcc r2, [sp, #-8] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_proc_fork) - -ENTRY(cloudabi_sys_proc_raise) - str r0, [sp, #-16] - mov r0, #41 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_proc_raise) - -ENTRY(cloudabi_sys_random_get) - str r0, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r1, [sp, #-8] - str r0, [sp, #-4] - mov r0, #42 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_random_get) - -ENTRY(cloudabi_sys_sock_recv) - str r0, [sp, #-24] - str r1, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r2, [sp, #-8] - str r0, [sp, #-4] - mov r0, #43 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_sock_recv) - -ENTRY(cloudabi_sys_sock_send) - str r0, [sp, #-24] - str r1, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r2, [sp, #-8] - str r0, [sp, #-4] - mov r0, #44 - sub r2, sp, #24 - swi 0 - bx lr -END(cloudabi_sys_sock_send) - -ENTRY(cloudabi_sys_sock_shutdown) - str r0, [sp, #-16] - str r1, [sp, #-8] - mov r0, #45 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_sock_shutdown) - -ENTRY(cloudabi_sys_thread_create) - str r0, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r1, [sp, #-20] - mov r0, #46 - sub r2, sp, #16 - swi 0 - ldrcc r1, [sp, #-20] - ldrcc r2, [sp, #-16] - strcc r2, [r1, #0] - bx lr -END(cloudabi_sys_thread_create) - -ENTRY(cloudabi_sys_thread_exit) - str r0, [sp, #-16] - mov r0, #0 - str r0, [sp, #-12] - str r1, [sp, #-8] - mov r0, #47 - sub r2, sp, #16 - swi 0 -END(cloudabi_sys_thread_exit) - -ENTRY(cloudabi_sys_thread_yield) - mov r0, #48 - sub r2, sp, #16 - swi 0 - bx lr -END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_i686.S b/sys/contrib/cloudabi/cloudabi_vdso_i686.S deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_vdso_i686.S +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#define ENTRY(name) \ - .text; \ - .p2align 2, 0x90; \ - .global name; \ - .type name, @function; \ -name: - -#define END(name) .size name, . - name - -ENTRY(cloudabi_sys_clock_res_get) - mov $0, %eax - int $0x80 - jc 1f - mov 8(%esp), %ecx - mov %eax, 0(%ecx) - mov %edx, 4(%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_clock_res_get) - -ENTRY(cloudabi_sys_clock_time_get) - mov $1, %eax - int $0x80 - jc 1f - mov 16(%esp), %ecx - mov %eax, 0(%ecx) - mov %edx, 4(%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_clock_time_get) - -ENTRY(cloudabi_sys_condvar_signal) - mov $2, %eax - int $0x80 - ret -END(cloudabi_sys_condvar_signal) - -ENTRY(cloudabi_sys_fd_close) - mov $3, %eax - int $0x80 - ret -END(cloudabi_sys_fd_close) - -ENTRY(cloudabi_sys_fd_create1) - mov $4, %eax - int $0x80 - jc 1f - mov 8(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_create1) - -ENTRY(cloudabi_sys_fd_create2) - mov $5, %eax - int $0x80 - jc 1f - mov 8(%esp), %ecx - mov %eax, (%ecx) - mov 12(%esp), %ecx - mov %edx, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_create2) - -ENTRY(cloudabi_sys_fd_datasync) - mov $6, %eax - int $0x80 - ret -END(cloudabi_sys_fd_datasync) - -ENTRY(cloudabi_sys_fd_dup) - mov $7, %eax - int $0x80 - jc 1f - mov 8(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_dup) - -ENTRY(cloudabi_sys_fd_pread) - mov $8, %eax - int $0x80 - jc 1f - mov 24(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_pread) - -ENTRY(cloudabi_sys_fd_pwrite) - mov $9, %eax - int $0x80 - jc 1f - mov 24(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_pwrite) - -ENTRY(cloudabi_sys_fd_read) - mov $10, %eax - int $0x80 - jc 1f - mov 16(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_read) - -ENTRY(cloudabi_sys_fd_replace) - mov $11, %eax - int $0x80 - ret -END(cloudabi_sys_fd_replace) - -ENTRY(cloudabi_sys_fd_seek) - mov $12, %eax - int $0x80 - jc 1f - mov 20(%esp), %ecx - mov %eax, 0(%ecx) - mov %edx, 4(%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_seek) - -ENTRY(cloudabi_sys_fd_stat_get) - mov $13, %eax - int $0x80 - ret -END(cloudabi_sys_fd_stat_get) - -ENTRY(cloudabi_sys_fd_stat_put) - mov $14, %eax - int $0x80 - ret -END(cloudabi_sys_fd_stat_put) - -ENTRY(cloudabi_sys_fd_sync) - mov $15, %eax - int $0x80 - ret -END(cloudabi_sys_fd_sync) - -ENTRY(cloudabi_sys_fd_write) - mov $16, %eax - int $0x80 - jc 1f - mov 16(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_write) - -ENTRY(cloudabi_sys_file_advise) - mov $17, %eax - int $0x80 - ret -END(cloudabi_sys_file_advise) - -ENTRY(cloudabi_sys_file_allocate) - mov $18, %eax - int $0x80 - ret -END(cloudabi_sys_file_allocate) - -ENTRY(cloudabi_sys_file_create) - mov $19, %eax - int $0x80 - ret -END(cloudabi_sys_file_create) - -ENTRY(cloudabi_sys_file_link) - mov $20, %eax - int $0x80 - ret -END(cloudabi_sys_file_link) - -ENTRY(cloudabi_sys_file_open) - mov $21, %eax - int $0x80 - jc 1f - mov 28(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_file_open) - -ENTRY(cloudabi_sys_file_readdir) - mov $22, %eax - int $0x80 - jc 1f - mov 24(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_file_readdir) - -ENTRY(cloudabi_sys_file_readlink) - mov $23, %eax - int $0x80 - jc 1f - mov 24(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_file_readlink) - -ENTRY(cloudabi_sys_file_rename) - mov $24, %eax - int $0x80 - ret -END(cloudabi_sys_file_rename) - -ENTRY(cloudabi_sys_file_stat_fget) - mov $25, %eax - int $0x80 - ret -END(cloudabi_sys_file_stat_fget) - -ENTRY(cloudabi_sys_file_stat_fput) - mov $26, %eax - int $0x80 - ret -END(cloudabi_sys_file_stat_fput) - -ENTRY(cloudabi_sys_file_stat_get) - mov $27, %eax - int $0x80 - ret -END(cloudabi_sys_file_stat_get) - -ENTRY(cloudabi_sys_file_stat_put) - mov $28, %eax - int $0x80 - ret -END(cloudabi_sys_file_stat_put) - -ENTRY(cloudabi_sys_file_symlink) - mov $29, %eax - int $0x80 - ret -END(cloudabi_sys_file_symlink) - -ENTRY(cloudabi_sys_file_unlink) - mov $30, %eax - int $0x80 - ret -END(cloudabi_sys_file_unlink) - -ENTRY(cloudabi_sys_lock_unlock) - mov $31, %eax - int $0x80 - ret -END(cloudabi_sys_lock_unlock) - -ENTRY(cloudabi_sys_mem_advise) - mov $32, %eax - int $0x80 - ret -END(cloudabi_sys_mem_advise) - -ENTRY(cloudabi_sys_mem_map) - mov $33, %eax - int $0x80 - jc 1f - mov 32(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_mem_map) - -ENTRY(cloudabi_sys_mem_protect) - mov $34, %eax - int $0x80 - ret -END(cloudabi_sys_mem_protect) - -ENTRY(cloudabi_sys_mem_sync) - mov $35, %eax - int $0x80 - ret -END(cloudabi_sys_mem_sync) - -ENTRY(cloudabi_sys_mem_unmap) - mov $36, %eax - int $0x80 - ret -END(cloudabi_sys_mem_unmap) - -ENTRY(cloudabi_sys_poll) - mov $37, %eax - int $0x80 - jc 1f - mov 16(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_poll) - -ENTRY(cloudabi_sys_proc_exec) - mov $38, %eax - int $0x80 - ret -END(cloudabi_sys_proc_exec) - -ENTRY(cloudabi_sys_proc_exit) - mov $39, %eax - int $0x80 -END(cloudabi_sys_proc_exit) - -ENTRY(cloudabi_sys_proc_fork) - mov $40, %eax - int $0x80 - jc 1f - mov 4(%esp), %ecx - mov %eax, (%ecx) - mov 8(%esp), %ecx - mov %edx, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_proc_fork) - -ENTRY(cloudabi_sys_proc_raise) - mov $41, %eax - int $0x80 - ret -END(cloudabi_sys_proc_raise) - -ENTRY(cloudabi_sys_random_get) - mov $42, %eax - int $0x80 - ret -END(cloudabi_sys_random_get) - -ENTRY(cloudabi_sys_sock_recv) - mov $43, %eax - int $0x80 - ret -END(cloudabi_sys_sock_recv) - -ENTRY(cloudabi_sys_sock_send) - mov $44, %eax - int $0x80 - ret -END(cloudabi_sys_sock_send) - -ENTRY(cloudabi_sys_sock_shutdown) - mov $45, %eax - int $0x80 - ret -END(cloudabi_sys_sock_shutdown) - -ENTRY(cloudabi_sys_thread_create) - mov $46, %eax - int $0x80 - jc 1f - mov 8(%esp), %ecx - mov %eax, (%ecx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_thread_create) - -ENTRY(cloudabi_sys_thread_exit) - mov $47, %eax - int $0x80 -END(cloudabi_sys_thread_exit) - -ENTRY(cloudabi_sys_thread_yield) - mov $48, %eax - int $0x80 - ret -END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S b/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S +++ /dev/null @@ -1,1058 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#define ENTRY(name) \ - .text; \ - .p2align 2, 0x90; \ - .global name; \ - .type name, @function; \ -name: - -#define END(name) .size name, . - name - -ENTRY(cloudabi_sys_clock_res_get) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $0, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 12(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) - mov -12(%ebp), %edx - mov %edx, 4(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_clock_res_get) - -ENTRY(cloudabi_sys_clock_time_get) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -4(%ebp) - mov $1, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 20(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) - mov -12(%ebp), %edx - mov %edx, 4(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_clock_time_get) - -ENTRY(cloudabi_sys_condvar_signal) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $2, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_condvar_signal) - -ENTRY(cloudabi_sys_fd_close) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $3, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_fd_close) - -ENTRY(cloudabi_sys_fd_create1) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $4, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 12(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_create1) - -ENTRY(cloudabi_sys_fd_create2) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $5, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 12(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) - mov 16(%ebp), %ecx - mov -8(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_create2) - -ENTRY(cloudabi_sys_fd_datasync) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $6, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_fd_datasync) - -ENTRY(cloudabi_sys_fd_dup) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $7, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 12(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_dup) - -ENTRY(cloudabi_sys_fd_pread) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -4(%ebp) - mov $8, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 28(%ebp), %ecx - mov -32(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_pread) - -ENTRY(cloudabi_sys_fd_pwrite) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -4(%ebp) - mov $9, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 28(%ebp), %ecx - mov -32(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_pwrite) - -ENTRY(cloudabi_sys_fd_read) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $10, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 20(%ebp), %ecx - mov -24(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_read) - -ENTRY(cloudabi_sys_fd_replace) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $11, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_fd_replace) - -ENTRY(cloudabi_sys_fd_seek) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $12, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 24(%ebp), %ecx - mov -24(%ebp), %edx - mov %edx, 0(%ecx) - mov -20(%ebp), %edx - mov %edx, 4(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_seek) - -ENTRY(cloudabi_sys_fd_stat_get) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $13, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_fd_stat_get) - -ENTRY(cloudabi_sys_fd_stat_put) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $14, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_fd_stat_put) - -ENTRY(cloudabi_sys_fd_sync) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $15, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_fd_sync) - -ENTRY(cloudabi_sys_fd_write) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $16, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 20(%ebp), %ecx - mov -24(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_fd_write) - -ENTRY(cloudabi_sys_file_advise) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -20(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -12(%ebp) - mov 28(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $17, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_advise) - -ENTRY(cloudabi_sys_file_allocate) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -4(%ebp) - mov $18, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_allocate) - -ENTRY(cloudabi_sys_file_create) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $19, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_create) - -ENTRY(cloudabi_sys_file_link) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -48(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -44(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -40(%ebp) - movl $0, -36(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 28(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 32(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $20, %eax - mov %ebp, %ecx - sub $48, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_link) - -ENTRY(cloudabi_sys_file_open) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -40(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -36(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 28(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $21, %eax - mov %ebp, %ecx - sub $40, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 32(%ebp), %ecx - mov -40(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_file_open) - -ENTRY(cloudabi_sys_file_readdir) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -4(%ebp) - mov $22, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 28(%ebp), %ecx - mov -32(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_file_readdir) - -ENTRY(cloudabi_sys_file_readlink) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -40(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $23, %eax - mov %ebp, %ecx - sub $40, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 28(%ebp), %ecx - mov -40(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_file_readlink) - -ENTRY(cloudabi_sys_file_rename) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -48(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -40(%ebp) - movl $0, -36(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 28(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $24, %eax - mov %ebp, %ecx - sub $48, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_rename) - -ENTRY(cloudabi_sys_file_stat_fget) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $25, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_stat_fget) - -ENTRY(cloudabi_sys_file_stat_fput) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $26, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_stat_fput) - -ENTRY(cloudabi_sys_file_stat_get) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -28(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $27, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_stat_get) - -ENTRY(cloudabi_sys_file_stat_put) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -40(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -36(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 28(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $28, %eax - mov %ebp, %ecx - sub $40, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_stat_put) - -ENTRY(cloudabi_sys_file_symlink) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -40(%ebp) - movl $0, -36(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $29, %eax - mov %ebp, %ecx - sub $40, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_symlink) - -ENTRY(cloudabi_sys_file_unlink) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $30, %eax - mov %ebp, %ecx - sub $32, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_file_unlink) - -ENTRY(cloudabi_sys_lock_unlock) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $31, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_lock_unlock) - -ENTRY(cloudabi_sys_mem_advise) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $32, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_mem_advise) - -ENTRY(cloudabi_sys_mem_map) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -48(%ebp) - movl $0, -44(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -40(%ebp) - movl $0, -36(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -32(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 28(%ebp), %ecx - mov %ecx, -8(%ebp) - mov 32(%ebp), %ecx - mov %ecx, -4(%ebp) - mov $33, %eax - mov %ebp, %ecx - sub $48, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 36(%ebp), %ecx - mov -48(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_mem_map) - -ENTRY(cloudabi_sys_mem_protect) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $34, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_mem_protect) - -ENTRY(cloudabi_sys_mem_sync) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $35, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_mem_sync) - -ENTRY(cloudabi_sys_mem_unmap) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $36, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_mem_unmap) - -ENTRY(cloudabi_sys_poll) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $37, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 20(%ebp), %ecx - mov -24(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_poll) - -ENTRY(cloudabi_sys_proc_exec) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -40(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -32(%ebp) - movl $0, -28(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -24(%ebp) - movl $0, -20(%ebp) - mov 20(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 24(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $38, %eax - mov %ebp, %ecx - sub $40, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_proc_exec) - -ENTRY(cloudabi_sys_proc_exit) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $39, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 -END(cloudabi_sys_proc_exit) - -ENTRY(cloudabi_sys_proc_fork) - push %ebp - mov %esp, %ebp - mov $40, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 8(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) - mov 12(%ebp), %ecx - mov -8(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_proc_fork) - -ENTRY(cloudabi_sys_proc_raise) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov $41, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_proc_raise) - -ENTRY(cloudabi_sys_random_get) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $42, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_random_get) - -ENTRY(cloudabi_sys_sock_recv) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $43, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_sock_recv) - -ENTRY(cloudabi_sys_sock_send) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -24(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 16(%ebp), %ecx - mov %ecx, -8(%ebp) - movl $0, -4(%ebp) - mov $44, %eax - mov %ebp, %ecx - sub $24, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_sock_send) - -ENTRY(cloudabi_sys_sock_shutdown) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $45, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_sock_shutdown) - -ENTRY(cloudabi_sys_thread_create) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov $46, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - test %eax, %eax - jnz 1f - mov 12(%ebp), %ecx - mov -16(%ebp), %edx - mov %edx, 0(%ecx) -1: - pop %ebp - ret -END(cloudabi_sys_thread_create) - -ENTRY(cloudabi_sys_thread_exit) - push %ebp - mov %esp, %ebp - mov 8(%ebp), %ecx - mov %ecx, -16(%ebp) - movl $0, -12(%ebp) - mov 12(%ebp), %ecx - mov %ecx, -8(%ebp) - mov $47, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 -END(cloudabi_sys_thread_exit) - -ENTRY(cloudabi_sys_thread_yield) - push %ebp - mov %esp, %ebp - mov $48, %eax - mov %ebp, %ecx - sub $16, %ecx - int $0x80 - pop %ebp - ret -END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S b/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S deleted file mode 100644 --- a/sys/contrib/cloudabi/cloudabi_vdso_x86_64.S +++ /dev/null @@ -1,449 +0,0 @@ -// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -#define ENTRY(name) \ - .text; \ - .p2align 4, 0x90; \ - .global name; \ - .type name, @function; \ -name: - -#define END(name) .size name, . - name - -ENTRY(cloudabi_sys_clock_res_get) - push %rsi - mov $0, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_clock_res_get) - -ENTRY(cloudabi_sys_clock_time_get) - push %rdx - mov $1, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_clock_time_get) - -ENTRY(cloudabi_sys_condvar_signal) - mov $2, %eax - syscall - ret -END(cloudabi_sys_condvar_signal) - -ENTRY(cloudabi_sys_fd_close) - mov $3, %eax - syscall - ret -END(cloudabi_sys_fd_close) - -ENTRY(cloudabi_sys_fd_create1) - push %rsi - mov $4, %eax - syscall - pop %rcx - jc 1f - mov %eax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_create1) - -ENTRY(cloudabi_sys_fd_create2) - push %rsi - push %rdx - mov $5, %eax - syscall - pop %rsi - pop %rcx - jc 1f - mov %eax, (%rcx) - mov %edx, (%rsi) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_create2) - -ENTRY(cloudabi_sys_fd_datasync) - mov $6, %eax - syscall - ret -END(cloudabi_sys_fd_datasync) - -ENTRY(cloudabi_sys_fd_dup) - push %rsi - mov $7, %eax - syscall - pop %rcx - jc 1f - mov %eax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_dup) - -ENTRY(cloudabi_sys_fd_pread) - mov %rcx, %r10 - push %r8 - mov $8, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_pread) - -ENTRY(cloudabi_sys_fd_pwrite) - mov %rcx, %r10 - push %r8 - mov $9, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_pwrite) - -ENTRY(cloudabi_sys_fd_read) - push %rcx - mov $10, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_read) - -ENTRY(cloudabi_sys_fd_replace) - mov $11, %eax - syscall - ret -END(cloudabi_sys_fd_replace) - -ENTRY(cloudabi_sys_fd_seek) - push %rcx - mov $12, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_seek) - -ENTRY(cloudabi_sys_fd_stat_get) - mov $13, %eax - syscall - ret -END(cloudabi_sys_fd_stat_get) - -ENTRY(cloudabi_sys_fd_stat_put) - mov $14, %eax - syscall - ret -END(cloudabi_sys_fd_stat_put) - -ENTRY(cloudabi_sys_fd_sync) - mov $15, %eax - syscall - ret -END(cloudabi_sys_fd_sync) - -ENTRY(cloudabi_sys_fd_write) - push %rcx - mov $16, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_fd_write) - -ENTRY(cloudabi_sys_file_advise) - mov %rcx, %r10 - mov $17, %eax - syscall - ret -END(cloudabi_sys_file_advise) - -ENTRY(cloudabi_sys_file_allocate) - mov $18, %eax - syscall - ret -END(cloudabi_sys_file_allocate) - -ENTRY(cloudabi_sys_file_create) - mov %rcx, %r10 - mov $19, %eax - syscall - ret -END(cloudabi_sys_file_create) - -ENTRY(cloudabi_sys_file_link) - mov %rcx, %r10 - mov $20, %eax - syscall - ret -END(cloudabi_sys_file_link) - -ENTRY(cloudabi_sys_file_open) - mov %rcx, %r10 - push %r9 - mov $21, %eax - syscall - pop %rcx - jc 1f - mov %eax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_file_open) - -ENTRY(cloudabi_sys_file_readdir) - mov %rcx, %r10 - push %r8 - mov $22, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_file_readdir) - -ENTRY(cloudabi_sys_file_readlink) - mov %rcx, %r10 - push %r9 - mov $23, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_file_readlink) - -ENTRY(cloudabi_sys_file_rename) - mov %rcx, %r10 - mov $24, %eax - syscall - ret -END(cloudabi_sys_file_rename) - -ENTRY(cloudabi_sys_file_stat_fget) - mov $25, %eax - syscall - ret -END(cloudabi_sys_file_stat_fget) - -ENTRY(cloudabi_sys_file_stat_fput) - mov $26, %eax - syscall - ret -END(cloudabi_sys_file_stat_fput) - -ENTRY(cloudabi_sys_file_stat_get) - mov %rcx, %r10 - mov $27, %eax - syscall - ret -END(cloudabi_sys_file_stat_get) - -ENTRY(cloudabi_sys_file_stat_put) - mov %rcx, %r10 - mov $28, %eax - syscall - ret -END(cloudabi_sys_file_stat_put) - -ENTRY(cloudabi_sys_file_symlink) - mov %rcx, %r10 - mov $29, %eax - syscall - ret -END(cloudabi_sys_file_symlink) - -ENTRY(cloudabi_sys_file_unlink) - mov %rcx, %r10 - mov $30, %eax - syscall - ret -END(cloudabi_sys_file_unlink) - -ENTRY(cloudabi_sys_lock_unlock) - mov $31, %eax - syscall - ret -END(cloudabi_sys_lock_unlock) - -ENTRY(cloudabi_sys_mem_advise) - mov $32, %eax - syscall - ret -END(cloudabi_sys_mem_advise) - -ENTRY(cloudabi_sys_mem_map) - mov %rcx, %r10 - mov $33, %eax - syscall - jc 1f - mov 8(%rsp), %rcx - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_mem_map) - -ENTRY(cloudabi_sys_mem_protect) - mov $34, %eax - syscall - ret -END(cloudabi_sys_mem_protect) - -ENTRY(cloudabi_sys_mem_sync) - mov $35, %eax - syscall - ret -END(cloudabi_sys_mem_sync) - -ENTRY(cloudabi_sys_mem_unmap) - mov $36, %eax - syscall - ret -END(cloudabi_sys_mem_unmap) - -ENTRY(cloudabi_sys_poll) - push %rcx - mov $37, %eax - syscall - pop %rcx - jc 1f - mov %rax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_poll) - -ENTRY(cloudabi_sys_proc_exec) - mov %rcx, %r10 - mov $38, %eax - syscall - ret -END(cloudabi_sys_proc_exec) - -ENTRY(cloudabi_sys_proc_exit) - mov $39, %eax - syscall -END(cloudabi_sys_proc_exit) - -ENTRY(cloudabi_sys_proc_fork) - push %rdi - push %rsi - mov $40, %eax - syscall - pop %rsi - pop %rcx - jc 1f - mov %eax, (%rcx) - mov %edx, (%rsi) - xor %eax, %eax -1: - ret -END(cloudabi_sys_proc_fork) - -ENTRY(cloudabi_sys_proc_raise) - mov $41, %eax - syscall - ret -END(cloudabi_sys_proc_raise) - -ENTRY(cloudabi_sys_random_get) - mov $42, %eax - syscall - ret -END(cloudabi_sys_random_get) - -ENTRY(cloudabi_sys_sock_recv) - mov $43, %eax - syscall - ret -END(cloudabi_sys_sock_recv) - -ENTRY(cloudabi_sys_sock_send) - mov $44, %eax - syscall - ret -END(cloudabi_sys_sock_send) - -ENTRY(cloudabi_sys_sock_shutdown) - mov $45, %eax - syscall - ret -END(cloudabi_sys_sock_shutdown) - -ENTRY(cloudabi_sys_thread_create) - push %rsi - mov $46, %eax - syscall - pop %rcx - jc 1f - mov %eax, (%rcx) - xor %eax, %eax -1: - ret -END(cloudabi_sys_thread_create) - -ENTRY(cloudabi_sys_thread_exit) - mov $47, %eax - syscall -END(cloudabi_sys_thread_exit) - -ENTRY(cloudabi_sys_thread_yield) - mov $48, %eax - syscall - ret -END(cloudabi_sys_thread_yield) diff --git a/sys/contrib/cloudabi/syscalls32.master b/sys/contrib/cloudabi/syscalls32.master deleted file mode 100644 --- a/sys/contrib/cloudabi/syscalls32.master +++ /dev/null @@ -1,274 +0,0 @@ - $FreeBSD$ - -; Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions -; are met: -; 1. Redistributions of source code must retain the above copyright -; notice, this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright -; notice, this list of conditions and the following disclaimer in the -; documentation and/or other materials provided with the distribution. -; -; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -; SUCH DAMAGE. -; -; This file is automatically generated. Do not edit. -; -; Source: https://github.com/NuxiNL/cloudabi - -#include -#include - -#include - -#include - -0 AUE_NULL STD { cloudabi_timestamp_t \ - cloudabi_sys_clock_res_get( \ - cloudabi_clockid_t clock_id); } - -1 AUE_NULL STD { cloudabi_timestamp_t \ - cloudabi_sys_clock_time_get( \ - cloudabi_clockid_t clock_id, \ - cloudabi_timestamp_t precision); } - -2 AUE_NULL STD { void cloudabi_sys_condvar_signal( \ - cloudabi_condvar_t *condvar, \ - cloudabi_scope_t scope, \ - cloudabi_nthreads_t nwaiters); } - -3 AUE_NULL STD { void cloudabi_sys_fd_close( \ - cloudabi_fd_t fd); } - -4 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_create1( \ - cloudabi_filetype_t type); } - -5 AUE_NULL STD { void cloudabi_sys_fd_create2( \ - cloudabi_filetype_t type); } - -6 AUE_NULL STD { void cloudabi_sys_fd_datasync( \ - cloudabi_fd_t fd); } - -7 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_dup( \ - cloudabi_fd_t from); } - -8 AUE_NULL STD { size_t cloudabi32_sys_fd_pread( \ - cloudabi_fd_t fd, \ - const cloudabi32_iovec_t *iovs, \ - size_t iovs_len, \ - cloudabi_filesize_t offset); } - -9 AUE_NULL STD { size_t cloudabi32_sys_fd_pwrite( \ - cloudabi_fd_t fd, \ - const cloudabi32_ciovec_t *iovs, \ - size_t iovs_len, \ - cloudabi_filesize_t offset); } - -10 AUE_NULL STD { size_t cloudabi32_sys_fd_read( \ - cloudabi_fd_t fd, \ - const cloudabi32_iovec_t *iovs, \ - size_t iovs_len); } - -11 AUE_NULL STD { void cloudabi_sys_fd_replace( \ - cloudabi_fd_t from, \ - cloudabi_fd_t to); } - -12 AUE_NULL STD { cloudabi_filesize_t \ - cloudabi_sys_fd_seek( \ - cloudabi_fd_t fd, \ - cloudabi_filedelta_t offset, \ - cloudabi_whence_t whence); } - -13 AUE_NULL STD { void cloudabi_sys_fd_stat_get( \ - cloudabi_fd_t fd, \ - cloudabi_fdstat_t *buf); } - -14 AUE_NULL STD { void cloudabi_sys_fd_stat_put( \ - cloudabi_fd_t fd, \ - const cloudabi_fdstat_t *buf, \ - cloudabi_fdsflags_t flags); } - -15 AUE_NULL STD { void cloudabi_sys_fd_sync( \ - cloudabi_fd_t fd); } - -16 AUE_NULL STD { size_t cloudabi32_sys_fd_write( \ - cloudabi_fd_t fd, \ - const cloudabi32_ciovec_t *iovs, \ - size_t iovs_len); } - -17 AUE_NULL STD { void cloudabi_sys_file_advise( \ - cloudabi_fd_t fd, \ - cloudabi_filesize_t offset, \ - cloudabi_filesize_t len, \ - cloudabi_advice_t advice); } - -18 AUE_NULL STD { void cloudabi_sys_file_allocate( \ - cloudabi_fd_t fd, \ - cloudabi_filesize_t offset, \ - cloudabi_filesize_t len); } - -19 AUE_NULL STD { void cloudabi_sys_file_create( \ - cloudabi_fd_t fd, \ - const char *path, \ - size_t path_len, \ - cloudabi_filetype_t type); } - -20 AUE_NULL STD { void cloudabi_sys_file_link( \ - cloudabi_lookup_t fd1, \ - const char *path1, \ - size_t path1_len, \ - cloudabi_fd_t fd2, \ - const char *path2, \ - size_t path2_len); } - -21 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_file_open( \ - cloudabi_lookup_t dirfd, \ - const char *path, \ - size_t path_len, \ - cloudabi_oflags_t oflags, \ - const cloudabi_fdstat_t *fds); } - -22 AUE_NULL STD { size_t cloudabi_sys_file_readdir( \ - cloudabi_fd_t fd, \ - void *buf, \ - size_t buf_len, \ - cloudabi_dircookie_t cookie); } - -23 AUE_NULL STD { size_t cloudabi_sys_file_readlink( \ - cloudabi_fd_t fd, \ - const char *path, \ - size_t path_len, \ - char *buf, \ - size_t buf_len); } - -24 AUE_NULL STD { void cloudabi_sys_file_rename( \ - cloudabi_fd_t fd1, \ - const char *path1, \ - size_t path1_len, \ - cloudabi_fd_t fd2, \ - const char *path2, \ - size_t path2_len); } - -25 AUE_NULL STD { void cloudabi_sys_file_stat_fget( \ - cloudabi_fd_t fd, \ - cloudabi_filestat_t *buf); } - -26 AUE_NULL STD { void cloudabi_sys_file_stat_fput( \ - cloudabi_fd_t fd, \ - const cloudabi_filestat_t *buf, \ - cloudabi_fsflags_t flags); } - -27 AUE_NULL STD { void cloudabi_sys_file_stat_get( \ - cloudabi_lookup_t fd, \ - const char *path, \ - size_t path_len, \ - cloudabi_filestat_t *buf); } - -28 AUE_NULL STD { void cloudabi_sys_file_stat_put( \ - cloudabi_lookup_t fd, \ - const char *path, \ - size_t path_len, \ - const cloudabi_filestat_t *buf, \ - cloudabi_fsflags_t flags); } - -29 AUE_NULL STD { void cloudabi_sys_file_symlink( \ - const char *path1, \ - size_t path1_len, \ - cloudabi_fd_t fd, \ - const char *path2, \ - size_t path2_len); } - -30 AUE_NULL STD { void cloudabi_sys_file_unlink( \ - cloudabi_fd_t fd, \ - const char *path, \ - size_t path_len, \ - cloudabi_ulflags_t flags); } - -31 AUE_NULL STD { void cloudabi_sys_lock_unlock( \ - cloudabi_lock_t *lock, \ - cloudabi_scope_t scope); } - -32 AUE_NULL STD { void cloudabi_sys_mem_advise( \ - void *mapping, \ - size_t mapping_len, \ - cloudabi_advice_t advice); } - -33 AUE_NULL STD { void cloudabi_sys_mem_map( \ - void *addr, \ - size_t len, \ - cloudabi_mprot_t prot, \ - cloudabi_mflags_t flags, \ - cloudabi_fd_t fd, \ - cloudabi_filesize_t off); } - -34 AUE_NULL STD { void cloudabi_sys_mem_protect( \ - void *mapping, \ - size_t mapping_len, \ - cloudabi_mprot_t prot); } - -35 AUE_NULL STD { void cloudabi_sys_mem_sync( \ - void *mapping, \ - size_t mapping_len, \ - cloudabi_msflags_t flags); } - -36 AUE_NULL STD { void cloudabi_sys_mem_unmap( \ - void *mapping, \ - size_t mapping_len); } - -37 AUE_NULL STD { size_t cloudabi32_sys_poll( \ - const cloudabi32_subscription_t *in, \ - cloudabi_event_t *out, \ - size_t nsubscriptions); } - -38 AUE_NULL STD { void cloudabi_sys_proc_exec( \ - cloudabi_fd_t fd, \ - const void *data, \ - size_t data_len, \ - const cloudabi_fd_t *fds, \ - size_t fds_len); } - -39 AUE_NULL STD { void cloudabi_sys_proc_exit( \ - cloudabi_exitcode_t rval); } - -40 AUE_NULL STD { void cloudabi_sys_proc_fork(); } - -41 AUE_NULL STD { void cloudabi_sys_proc_raise( \ - cloudabi_signal_t sig); } - -42 AUE_NULL STD { void cloudabi_sys_random_get( \ - void *buf, \ - size_t buf_len); } - -43 AUE_NULL STD { void cloudabi32_sys_sock_recv( \ - cloudabi_fd_t sock, \ - const cloudabi32_recv_in_t *in, \ - cloudabi32_recv_out_t *out); } - -44 AUE_NULL STD { void cloudabi32_sys_sock_send( \ - cloudabi_fd_t sock, \ - const cloudabi32_send_in_t *in, \ - cloudabi32_send_out_t *out); } - -45 AUE_NULL STD { void cloudabi_sys_sock_shutdown( \ - cloudabi_fd_t sock, \ - cloudabi_sdflags_t how); } - -46 AUE_NULL STD { cloudabi_tid_t cloudabi32_sys_thread_create( \ - cloudabi32_threadattr_t *attr); } - -47 AUE_NULL STD { void cloudabi_sys_thread_exit( \ - cloudabi_lock_t *lock, \ - cloudabi_scope_t scope); } - -48 AUE_NULL STD { void cloudabi_sys_thread_yield(); } diff --git a/sys/contrib/cloudabi/syscalls64.master b/sys/contrib/cloudabi/syscalls64.master deleted file mode 100644 --- a/sys/contrib/cloudabi/syscalls64.master +++ /dev/null @@ -1,274 +0,0 @@ - $FreeBSD$ - -; Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. -; -; Redistribution and use in source and binary forms, with or without -; modification, are permitted provided that the following conditions -; are met: -; 1. Redistributions of source code must retain the above copyright -; notice, this list of conditions and the following disclaimer. -; 2. Redistributions in binary form must reproduce the above copyright -; notice, this list of conditions and the following disclaimer in the -; documentation and/or other materials provided with the distribution. -; -; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -; SUCH DAMAGE. -; -; This file is automatically generated. Do not edit. -; -; Source: https://github.com/NuxiNL/cloudabi - -#include -#include - -#include - -#include - -0 AUE_NULL STD { cloudabi_timestamp_t \ - cloudabi_sys_clock_res_get( \ - cloudabi_clockid_t clock_id); } - -1 AUE_NULL STD { cloudabi_timestamp_t \ - cloudabi_sys_clock_time_get( \ - cloudabi_clockid_t clock_id, \ - cloudabi_timestamp_t precision); } - -2 AUE_NULL STD { void cloudabi_sys_condvar_signal( \ - cloudabi_condvar_t *condvar, \ - cloudabi_scope_t scope, \ - cloudabi_nthreads_t nwaiters); } - -3 AUE_NULL STD { void cloudabi_sys_fd_close( \ - cloudabi_fd_t fd); } - -4 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_create1( \ - cloudabi_filetype_t type); } - -5 AUE_NULL STD { void cloudabi_sys_fd_create2( \ - cloudabi_filetype_t type); } - -6 AUE_NULL STD { void cloudabi_sys_fd_datasync( \ - cloudabi_fd_t fd); } - -7 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_dup( \ - cloudabi_fd_t from); } - -8 AUE_NULL STD { size_t cloudabi64_sys_fd_pread( \ - cloudabi_fd_t fd, \ - const cloudabi64_iovec_t *iovs, \ - size_t iovs_len, \ - cloudabi_filesize_t offset); } - -9 AUE_NULL STD { size_t cloudabi64_sys_fd_pwrite( \ - cloudabi_fd_t fd, \ - const cloudabi64_ciovec_t *iovs, \ - size_t iovs_len, \ - cloudabi_filesize_t offset); } - -10 AUE_NULL STD { size_t cloudabi64_sys_fd_read( \ - cloudabi_fd_t fd, \ - const cloudabi64_iovec_t *iovs, \ - size_t iovs_len); } - -11 AUE_NULL STD { void cloudabi_sys_fd_replace( \ - cloudabi_fd_t from, \ - cloudabi_fd_t to); } - -12 AUE_NULL STD { cloudabi_filesize_t \ - cloudabi_sys_fd_seek( \ - cloudabi_fd_t fd, \ - cloudabi_filedelta_t offset, \ - cloudabi_whence_t whence); } - -13 AUE_NULL STD { void cloudabi_sys_fd_stat_get( \ - cloudabi_fd_t fd, \ - cloudabi_fdstat_t *buf); } - -14 AUE_NULL STD { void cloudabi_sys_fd_stat_put( \ - cloudabi_fd_t fd, \ - const cloudabi_fdstat_t *buf, \ - cloudabi_fdsflags_t flags); } - -15 AUE_NULL STD { void cloudabi_sys_fd_sync( \ - cloudabi_fd_t fd); } - -16 AUE_NULL STD { size_t cloudabi64_sys_fd_write( \ - cloudabi_fd_t fd, \ - const cloudabi64_ciovec_t *iovs, \ - size_t iovs_len); } - -17 AUE_NULL STD { void cloudabi_sys_file_advise( \ - cloudabi_fd_t fd, \ - cloudabi_filesize_t offset, \ - cloudabi_filesize_t len, \ - cloudabi_advice_t advice); } - -18 AUE_NULL STD { void cloudabi_sys_file_allocate( \ - cloudabi_fd_t fd, \ - cloudabi_filesize_t offset, \ - cloudabi_filesize_t len); } - -19 AUE_NULL STD { void cloudabi_sys_file_create( \ - cloudabi_fd_t fd, \ - const char *path, \ - size_t path_len, \ - cloudabi_filetype_t type); } - -20 AUE_NULL STD { void cloudabi_sys_file_link( \ - cloudabi_lookup_t fd1, \ - const char *path1, \ - size_t path1_len, \ - cloudabi_fd_t fd2, \ - const char *path2, \ - size_t path2_len); } - -21 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_file_open( \ - cloudabi_lookup_t dirfd, \ - const char *path, \ - size_t path_len, \ - cloudabi_oflags_t oflags, \ - const cloudabi_fdstat_t *fds); } - -22 AUE_NULL STD { size_t cloudabi_sys_file_readdir( \ - cloudabi_fd_t fd, \ - void *buf, \ - size_t buf_len, \ - cloudabi_dircookie_t cookie); } - -23 AUE_NULL STD { size_t cloudabi_sys_file_readlink( \ - cloudabi_fd_t fd, \ - const char *path, \ - size_t path_len, \ - char *buf, \ - size_t buf_len); } - -24 AUE_NULL STD { void cloudabi_sys_file_rename( \ - cloudabi_fd_t fd1, \ - const char *path1, \ - size_t path1_len, \ - cloudabi_fd_t fd2, \ - const char *path2, \ - size_t path2_len); } - -25 AUE_NULL STD { void cloudabi_sys_file_stat_fget( \ - cloudabi_fd_t fd, \ - cloudabi_filestat_t *buf); } - -26 AUE_NULL STD { void cloudabi_sys_file_stat_fput( \ - cloudabi_fd_t fd, \ - const cloudabi_filestat_t *buf, \ - cloudabi_fsflags_t flags); } - -27 AUE_NULL STD { void cloudabi_sys_file_stat_get( \ - cloudabi_lookup_t fd, \ - const char *path, \ - size_t path_len, \ - cloudabi_filestat_t *buf); } - -28 AUE_NULL STD { void cloudabi_sys_file_stat_put( \ - cloudabi_lookup_t fd, \ - const char *path, \ - size_t path_len, \ - const cloudabi_filestat_t *buf, \ - cloudabi_fsflags_t flags); } - -29 AUE_NULL STD { void cloudabi_sys_file_symlink( \ - const char *path1, \ - size_t path1_len, \ - cloudabi_fd_t fd, \ - const char *path2, \ - size_t path2_len); } - -30 AUE_NULL STD { void cloudabi_sys_file_unlink( \ - cloudabi_fd_t fd, \ - const char *path, \ - size_t path_len, \ - cloudabi_ulflags_t flags); } - -31 AUE_NULL STD { void cloudabi_sys_lock_unlock( \ - cloudabi_lock_t *lock, \ - cloudabi_scope_t scope); } - -32 AUE_NULL STD { void cloudabi_sys_mem_advise( \ - void *mapping, \ - size_t mapping_len, \ - cloudabi_advice_t advice); } - -33 AUE_NULL STD { void cloudabi_sys_mem_map( \ - void *addr, \ - size_t len, \ - cloudabi_mprot_t prot, \ - cloudabi_mflags_t flags, \ - cloudabi_fd_t fd, \ - cloudabi_filesize_t off); } - -34 AUE_NULL STD { void cloudabi_sys_mem_protect( \ - void *mapping, \ - size_t mapping_len, \ - cloudabi_mprot_t prot); } - -35 AUE_NULL STD { void cloudabi_sys_mem_sync( \ - void *mapping, \ - size_t mapping_len, \ - cloudabi_msflags_t flags); } - -36 AUE_NULL STD { void cloudabi_sys_mem_unmap( \ - void *mapping, \ - size_t mapping_len); } - -37 AUE_NULL STD { size_t cloudabi64_sys_poll( \ - const cloudabi64_subscription_t *in, \ - cloudabi_event_t *out, \ - size_t nsubscriptions); } - -38 AUE_NULL STD { void cloudabi_sys_proc_exec( \ - cloudabi_fd_t fd, \ - const void *data, \ - size_t data_len, \ - const cloudabi_fd_t *fds, \ - size_t fds_len); } - -39 AUE_NULL STD { void cloudabi_sys_proc_exit( \ - cloudabi_exitcode_t rval); } - -40 AUE_NULL STD { void cloudabi_sys_proc_fork(); } - -41 AUE_NULL STD { void cloudabi_sys_proc_raise( \ - cloudabi_signal_t sig); } - -42 AUE_NULL STD { void cloudabi_sys_random_get( \ - void *buf, \ - size_t buf_len); } - -43 AUE_NULL STD { void cloudabi64_sys_sock_recv( \ - cloudabi_fd_t sock, \ - const cloudabi64_recv_in_t *in, \ - cloudabi64_recv_out_t *out); } - -44 AUE_NULL STD { void cloudabi64_sys_sock_send( \ - cloudabi_fd_t sock, \ - const cloudabi64_send_in_t *in, \ - cloudabi64_send_out_t *out); } - -45 AUE_NULL STD { void cloudabi_sys_sock_shutdown( \ - cloudabi_fd_t sock, \ - cloudabi_sdflags_t how); } - -46 AUE_NULL STD { cloudabi_tid_t cloudabi64_sys_thread_create( \ - cloudabi64_threadattr_t *attr); } - -47 AUE_NULL STD { void cloudabi_sys_thread_exit( \ - cloudabi_lock_t *lock, \ - cloudabi_scope_t scope); } - -48 AUE_NULL STD { void cloudabi_sys_thread_yield(); } diff --git a/sys/i386/cloudabi32/cloudabi32_sysvec.c b/sys/i386/cloudabi32/cloudabi32_sysvec.c deleted file mode 100644 --- a/sys/i386/cloudabi32/cloudabi32_sysvec.c +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * Copyright (c) 2015-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 -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -extern const char *cloudabi32_syscallnames[]; -extern struct sysent cloudabi32_sysent[]; - -static int -cloudabi32_fixup_tcb(uintptr_t *stack_base, struct image_params *imgp) -{ - int error; - uint32_t args[2]; - - /* Place auxiliary vector and TCB on the stack. */ - error = cloudabi32_fixup(stack_base, imgp); - if (error != 0) - return (error); - - /* - * On i386, the TCB is referred to by %gs:0. Reuse the empty - * space normally used by the return address (args[0]) to store - * a single element array, containing a pointer to the TCB. %gs - * base will point to this. - * - * Also let the first argument of the entry point (args[1]) - * refer to the auxiliary vector, which is stored right after - * the TCB. - */ - args[0] = *stack_base; - args[1] = *stack_base + - roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t)); - *stack_base -= roundup(sizeof(args), sizeof(register_t)); - return (copyout(args, (void *)*stack_base, sizeof(args))); -} - -static void -cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp, - uintptr_t stack) -{ - - exec_setregs(td, imgp, stack); - (void)cpu_set_user_tls(td, TO_PTR(stack)); -} - -static int -cloudabi32_fetch_syscall_args(struct thread *td) -{ - struct trapframe *frame; - struct syscall_args *sa; - int error; - - frame = td->td_frame; - sa = &td->td_sa; - - /* Obtain system call number. */ - sa->code = frame->tf_eax; - sa->original_code = sa->code; - if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL) - return (ENOSYS); - sa->callp = &cloudabi32_sysent[sa->code]; - - /* Fetch system call arguments from the stack. */ - error = copyin((void *)(frame->tf_esp + 4), sa->args, - sa->callp->sy_narg * sizeof(sa->args[0])); - if (error != 0) - return (error); - - /* Default system call return values. */ - td->td_retval[0] = 0; - td->td_retval[1] = frame->tf_edx; - return (0); -} - -static void -cloudabi32_set_syscall_retval(struct thread *td, int error) -{ - struct trapframe *frame = td->td_frame; - - switch (error) { - case 0: - /* System call succeeded. */ - frame->tf_eax = td->td_retval[0]; - frame->tf_edx = td->td_retval[1]; - frame->tf_eflags &= ~PSL_C; - break; - case ERESTART: - /* Restart system call. */ - frame->tf_eip -= frame->tf_err; - break; - case EJUSTRETURN: - break; - default: - /* System call returned an error. */ - frame->tf_eax = cloudabi_convert_errno(error); - frame->tf_eflags |= PSL_C; - break; - } -} - -static void -cloudabi32_schedtail(struct thread *td) -{ - struct trapframe *frame = td->td_frame; - - /* Initial register values for processes returning from fork. */ - frame->tf_eax = CLOUDABI_PROCESS_CHILD; - frame->tf_edx = td->td_tid; -} - -int -cloudabi32_thread_setregs(struct thread *td, - const cloudabi32_threadattr_t *attr, uint32_t tcb) -{ - stack_t stack; - uint32_t args[3]; - void *frameptr; - int error; - - /* Perform standard register initialization. */ - stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_len - sizeof(args); - cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); - - /* - * Copy the arguments for the thread entry point onto the stack - * (args[1] and args[2]). Similar to process startup, use the - * otherwise unused return address (args[0]) for TLS. - */ - args[0] = tcb; - args[1] = td->td_tid; - args[2] = attr->argument; - frameptr = (void *)td->td_frame->tf_esp; - error = copyout(args, frameptr, sizeof(args)); - if (error != 0) - return (error); - - return (cpu_set_user_tls(td, frameptr)); -} - -static struct sysentvec cloudabi32_elf_sysvec = { - .sv_size = CLOUDABI32_SYS_MAXSYSCALL, - .sv_table = cloudabi32_sysent, - .sv_fixup = cloudabi32_fixup_tcb, - .sv_name = "CloudABI ELF32", - .sv_coredump = elf32_coredump, - .sv_minuser = VM_MIN_ADDRESS, - .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_stackprot = VM_PROT_READ | VM_PROT_WRITE, - .sv_copyout_strings = cloudabi32_copyout_strings, - .sv_setregs = cloudabi32_proc_setregs, - .sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_IA32 | SV_ILP32, - .sv_set_syscall_retval = cloudabi32_set_syscall_retval, - .sv_fetch_syscall_args = cloudabi32_fetch_syscall_args, - .sv_syscallnames = cloudabi32_syscallnames, - .sv_schedtail = cloudabi32_schedtail, - .sv_set_fork_retval = x86_set_fork_retval, -}; - -INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec); - -Elf32_Brandinfo cloudabi32_brand = { - .brand = ELFOSABI_CLOUDABI, - .machine = EM_386, - .sysvec = &cloudabi32_elf_sysvec, - .flags = BI_BRAND_ONLY_STATIC, -}; diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -877,9 +877,6 @@ # Enable (32-bit) a.out binary support options COMPAT_AOUT -# Enable 32-bit runtime support for CloudABI binaries. -options COMPAT_CLOUDABI32 - ##################################################################### # VM OPTIONS diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -681,10 +681,6 @@ goto exec_fail_dealloc; } - /* ABI enforces the use of Capsicum. Switch into capabilities mode. */ - if (SV_PROC_FLAG(p, SV_CAPSICUM)) - sys_cap_enter(td, NULL); - /* * Copy out strings (args and env) and initialize stack base. */ diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -987,9 +987,7 @@ void execsigs(struct proc *p) { - sigset_t osigignore; struct sigacts *ps; - int sig; struct thread *td; /* @@ -1002,23 +1000,6 @@ mtx_lock(&ps->ps_mtx); sig_drop_caught(p); - /* - * As CloudABI processes cannot modify signal handlers, fully - * reset all signals to their default behavior. Do ignore - * SIGPIPE, as it would otherwise be impossible to recover from - * writes to broken pipes and sockets. - */ - if (SV_PROC_ABI(p) == SV_ABI_CLOUDABI) { - osigignore = ps->ps_sigignore; - while (SIGNOTEMPTY(osigignore)) { - sig = sig_ffs(&osigignore); - SIGDELSET(osigignore, sig); - if (sig != SIGPIPE) - sigdflt(ps, sig); - } - SIGADDSET(ps->ps_sigignore, SIGPIPE); - } - /* * Reset stack state to the user stack. * Clear set of signals caught on the signal stack. diff --git a/sys/modules/Makefile b/sys/modules/Makefile --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -87,9 +87,6 @@ ${_cfi} \ ${_chromebook_platform} \ ${_ciss} \ - cloudabi \ - ${_cloudabi32} \ - ${_cloudabi64} \ ${_coretemp} \ ${_cp} \ ${_cpsw} \ @@ -817,14 +814,6 @@ _nvram+= powermac_nvram .endif -.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ - ${MACHINE_ARCH:Marmv[67]*} != "" || ${MACHINE_CPUARCH} == "i386") -_cloudabi32= cloudabi32 -.endif -.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" -_cloudabi64= cloudabi64 -.endif - .endif .if ${MACHINE_ARCH:Marmv[67]*} != "" || ${MACHINE_CPUARCH} == "aarch64" diff --git a/sys/modules/cloudabi/Makefile b/sys/modules/cloudabi/Makefile deleted file mode 100644 --- a/sys/modules/cloudabi/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $FreeBSD$ - -.PATH: ${SRCTOP}/sys/compat/cloudabi - -KMOD= cloudabi -SRCS= cloudabi_clock.c cloudabi_errno.c cloudabi_fd.c cloudabi_file.c \ - cloudabi_futex.c cloudabi_mem.c cloudabi_proc.c cloudabi_random.c \ - cloudabi_sock.c cloudabi_thread.c cloudabi_vdso.c vnode_if.h - -.include diff --git a/sys/modules/cloudabi32/Makefile b/sys/modules/cloudabi32/Makefile deleted file mode 100644 --- a/sys/modules/cloudabi32/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# $FreeBSD$ - -SYSDIR?=${SRCTOP}/sys - -.PATH: ${SYSDIR}/compat/cloudabi32 -.PATH: ${SYSDIR}/${MACHINE_CPUARCH}/cloudabi32 -.PATH: ${SYSDIR}/${MACHINE}/cloudabi32 - -KMOD= cloudabi32 -SRCS= cloudabi32_fd.c cloudabi32_module.c cloudabi32_poll.c \ - cloudabi32_sock.c cloudabi32_syscalls.c cloudabi32_sysent.c \ - cloudabi32_sysvec.c cloudabi32_thread.c - -OBJS= cloudabi32_vdso_blob.o -CLEANFILES=cloudabi32_vdso.o - -.if ${MACHINE_CPUARCH} == "aarch64" -VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_armv6_on_64bit.S -OUTPUT_TARGET=elf64-littleaarch64 -BINARY_ARCHITECTURE=aarch64 -.elif ${MACHINE_CPUARCH} == "amd64" -VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686_on_64bit.S -OUTPUT_TARGET=elf64-x86-64-freebsd -BINARY_ARCHITECTURE=i386 -.elif ${MACHINE_ARCH:Marmv[67]*} != "" -VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_armv6.S -OUTPUT_TARGET=elf32-littlearm -BINARY_ARCHITECTURE=arm -.elif ${MACHINE_CPUARCH} == "i386" -VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_i686.S -OUTPUT_TARGET=elf32-i386-freebsd -BINARY_ARCHITECTURE=i386 -.endif - -cloudabi32_vdso.o: ${VDSO_SRCS} - ${CC} ${CCLDFLAGS} -x assembler-with-cpp -m32 -shared -nostdinc -nostdlib \ - -Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \ - ${VDSO_SRCS} -o ${.TARGET} - -cloudabi32_vdso_blob.o: cloudabi32_vdso.o - ${OBJCOPY} --input-target binary \ - --output-target ${OUTPUT_TARGET} \ - --binary-architecture ${BINARY_ARCHITECTURE} \ - cloudabi32_vdso.o ${.TARGET} - -.include diff --git a/sys/modules/cloudabi64/Makefile b/sys/modules/cloudabi64/Makefile deleted file mode 100644 --- a/sys/modules/cloudabi64/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# $FreeBSD$ - -SYSDIR?=${SRCTOP}/sys - -.PATH: ${SYSDIR}/compat/cloudabi64 -.PATH: ${SYSDIR}/${MACHINE_CPUARCH}/cloudabi64 -.PATH: ${SYSDIR}/${MACHINE}/cloudabi64 - -KMOD= cloudabi64 -SRCS= cloudabi64_fd.c cloudabi64_module.c cloudabi64_poll.c \ - cloudabi64_sock.c cloudabi64_syscalls.c cloudabi64_sysent.c \ - cloudabi64_sysvec.c cloudabi64_thread.c - -OBJS= cloudabi64_vdso_blob.o -CLEANFILES=cloudabi64_vdso.o - -.if ${MACHINE_CPUARCH} == "aarch64" -VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_aarch64.S -OUTPUT_TARGET=elf64-littleaarch64 -BINARY_ARCHITECTURE=aarch64 -.elif ${MACHINE_CPUARCH} == "amd64" -VDSO_SRCS=${SYSDIR}/contrib/cloudabi/cloudabi_vdso_x86_64.S -OUTPUT_TARGET=elf64-x86-64-freebsd -BINARY_ARCHITECTURE=i386 -.endif - -cloudabi64_vdso.o: ${VDSO_SRCS} - ${CC} ${CCLDFLAGS} -x assembler-with-cpp -shared -nostdinc -nostdlib \ - -Wl,-T${SYSDIR}/compat/cloudabi/cloudabi_vdso.lds \ - ${VDSO_SRCS} -o ${.TARGET} - -cloudabi64_vdso_blob.o: cloudabi64_vdso.o - ${OBJCOPY} --input-target binary \ - --output-target ${OUTPUT_TARGET} \ - --binary-architecture ${BINARY_ARCHITECTURE} \ - cloudabi64_vdso.o ${.TARGET} - -.include diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -165,7 +165,7 @@ #define SV_IA32 0x004000 /* Intel 32-bit executable. */ #define SV_AOUT 0x008000 /* a.out executable. */ #define SV_SHP 0x010000 /* Shared page. */ -#define SV_CAPSICUM 0x020000 /* Force cap_enter() on startup. */ +#define SV_AVAIL1 0x020000 /* Unused */ #define SV_TIMEKEEP 0x040000 /* Shared page timehands. */ #define SV_ASLR 0x080000 /* ASLR allowed. */ #define SV_RNG_SEED_VER 0x100000 /* random(4) reseed generation. */ @@ -180,7 +180,6 @@ /* same as ELFOSABI_XXX, to prevent header pollution */ #define SV_ABI_LINUX 3 #define SV_ABI_FREEBSD 9 -#define SV_ABI_CLOUDABI 17 #define SV_ABI_UNDEF 255 /* sv_coredump flags */ diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -727,8 +727,7 @@ if flags & protoflags == 0 then if funcname == "nosys" or funcname == "lkmnosys" or funcname == "sysarch" or funcname:find("^freebsd") or - funcname:find("^linux") or - funcname:find("^cloudabi") then + funcname:find("^linux") then write_line("sysdcl", string.format( "%s\t%s(struct thread *, struct %s *)", rettype, funcname, argalias)) @@ -755,8 +754,7 @@ else if funcname == "nosys" or funcname == "lkmnosys" or funcname == "sysarch" or funcname:find("^freebsd") or - funcname:find("^linux") or - funcname:find("^cloudabi") then + funcname:find("^linux") then write_line("sysent", string.format( "%s, .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },", funcname, auditev, sysflags, thr_flag)) diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -711,9 +711,6 @@ case SV_ABI_FREEBSD: abi = "F"; break; - case SV_ABI_CLOUDABI: - abi = "C"; - break; default: abi = "U"; break; @@ -761,8 +758,6 @@ return (SYSDECODE_ABI_LINUX32); #endif return (SYSDECODE_ABI_LINUX); - case SV_ABI_CLOUDABI: - return (SYSDECODE_ABI_CLOUDABI64); default: return (SYSDECODE_ABI_UNKNOWN); } diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -73,22 +73,6 @@ static void new_proc(struct trussinfo *, pid_t, lwpid_t); -static struct procabi cloudabi32 = { - .type = "CloudABI32", - .abi = SYSDECODE_ABI_CLOUDABI32, - .pointer_size = sizeof(uint32_t), - .extra_syscalls = STAILQ_HEAD_INITIALIZER(cloudabi32.extra_syscalls), - .syscalls = { NULL } -}; - -static struct procabi cloudabi64 = { - .type = "CloudABI64", - .abi = SYSDECODE_ABI_CLOUDABI64, - .pointer_size = sizeof(uint64_t), - .extra_syscalls = STAILQ_HEAD_INITIALIZER(cloudabi64.extra_syscalls), - .syscalls = { NULL } -}; - static struct procabi freebsd = { .type = "FreeBSD", .abi = SYSDECODE_ABI_FREEBSD, @@ -131,8 +115,6 @@ #endif static struct procabi_table abis[] = { - { "CloudABI ELF32", &cloudabi32 }, - { "CloudABI ELF64", &cloudabi64 }, #if __SIZEOF_POINTER__ == 4 { "FreeBSD ELF32", &freebsd }, #elif __SIZEOF_POINTER__ == 8 diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h --- a/usr.bin/truss/syscall.h +++ b/usr.bin/truss/syscall.h @@ -188,26 +188,6 @@ Timeval2, Utrace, - CloudABIAdvice, - CloudABIClockID, - CloudABIFDSFlags, - CloudABIFDStat, - CloudABIFileStat, - CloudABIFileType, - CloudABIFSFlags, - CloudABILookup, - CloudABIMFlags, - CloudABIMProt, - CloudABIMSFlags, - CloudABIOFlags, - CloudABISDFlags, - CloudABISignal, - CloudABISockStat, - CloudABISSFlags, - CloudABITimestamp, - CloudABIULFlags, - CloudABIWhence, - MAX_ARG_TYPE, }; diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -78,8 +79,6 @@ #include #include -#include - #include "truss.h" #include "extern.h" #include "syscall.h" @@ -619,103 +618,6 @@ .args = { { Int, 0 }, { LinuxSockArgs, 1 } } }, { .name = "linux_stat64", .ret_type = 1, .nargs = 2, .args = { { Name | IN, 0 }, { Ptr | OUT, 1 } } }, - - /* CloudABI system calls. */ - { .name = "cloudabi_sys_clock_res_get", .ret_type = 1, .nargs = 1, - .args = { { CloudABIClockID, 0 } } }, - { .name = "cloudabi_sys_clock_time_get", .ret_type = 1, .nargs = 2, - .args = { { CloudABIClockID, 0 }, { CloudABITimestamp, 1 } } }, - { .name = "cloudabi_sys_condvar_signal", .ret_type = 1, .nargs = 3, - .args = { { Ptr, 0 }, { CloudABIMFlags, 1 }, { UInt, 2 } } }, - { .name = "cloudabi_sys_fd_close", .ret_type = 1, .nargs = 1, - .args = { { Int, 0 } } }, - { .name = "cloudabi_sys_fd_create1", .ret_type = 1, .nargs = 1, - .args = { { CloudABIFileType, 0 } } }, - { .name = "cloudabi_sys_fd_create2", .ret_type = 1, .nargs = 2, - .args = { { CloudABIFileType, 0 }, { PipeFds | OUT, 0 } } }, - { .name = "cloudabi_sys_fd_datasync", .ret_type = 1, .nargs = 1, - .args = { { Int, 0 } } }, - { .name = "cloudabi_sys_fd_dup", .ret_type = 1, .nargs = 1, - .args = { { Int, 0 } } }, - { .name = "cloudabi_sys_fd_replace", .ret_type = 1, .nargs = 2, - .args = { { Int, 0 }, { Int, 1 } } }, - { .name = "cloudabi_sys_fd_seek", .ret_type = 1, .nargs = 3, - .args = { { Int, 0 }, { Int, 1 }, { CloudABIWhence, 2 } } }, - { .name = "cloudabi_sys_fd_stat_get", .ret_type = 1, .nargs = 2, - .args = { { Int, 0 }, { CloudABIFDStat | OUT, 1 } } }, - { .name = "cloudabi_sys_fd_stat_put", .ret_type = 1, .nargs = 3, - .args = { { Int, 0 }, { CloudABIFDStat | IN, 1 }, - { CloudABIFDSFlags, 2 } } }, - { .name = "cloudabi_sys_fd_sync", .ret_type = 1, .nargs = 1, - .args = { { Int, 0 } } }, - { .name = "cloudabi_sys_file_advise", .ret_type = 1, .nargs = 4, - .args = { { Int, 0 }, { Int, 1 }, { Int, 2 }, - { CloudABIAdvice, 3 } } }, - { .name = "cloudabi_sys_file_allocate", .ret_type = 1, .nargs = 3, - .args = { { Int, 0 }, { Int, 1 }, { Int, 2 } } }, - { .name = "cloudabi_sys_file_create", .ret_type = 1, .nargs = 3, - .args = { { Int, 0 }, { BinString | IN, 1 }, - { CloudABIFileType, 3 } } }, - { .name = "cloudabi_sys_file_link", .ret_type = 1, .nargs = 4, - .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, - { Int, 3 }, { BinString | IN, 4 } } }, - { .name = "cloudabi_sys_file_open", .ret_type = 1, .nargs = 4, - .args = { { Int, 0 }, { BinString | IN, 1 }, - { CloudABIOFlags, 3 }, { CloudABIFDStat | IN, 4 } } }, - { .name = "cloudabi_sys_file_readdir", .ret_type = 1, .nargs = 4, - .args = { { Int, 0 }, { BinString | OUT, 1 }, { Int, 2 }, - { Int, 3 } } }, - { .name = "cloudabi_sys_file_readlink", .ret_type = 1, .nargs = 4, - .args = { { Int, 0 }, { BinString | IN, 1 }, - { BinString | OUT, 3 }, { Int, 4 } } }, - { .name = "cloudabi_sys_file_rename", .ret_type = 1, .nargs = 4, - .args = { { Int, 0 }, { BinString | IN, 1 }, - { Int, 3 }, { BinString | IN, 4 } } }, - { .name = "cloudabi_sys_file_stat_fget", .ret_type = 1, .nargs = 2, - .args = { { Int, 0 }, { CloudABIFileStat | OUT, 1 } } }, - { .name = "cloudabi_sys_file_stat_fput", .ret_type = 1, .nargs = 3, - .args = { { Int, 0 }, { CloudABIFileStat | IN, 1 }, - { CloudABIFSFlags, 2 } } }, - { .name = "cloudabi_sys_file_stat_get", .ret_type = 1, .nargs = 3, - .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, - { CloudABIFileStat | OUT, 3 } } }, - { .name = "cloudabi_sys_file_stat_put", .ret_type = 1, .nargs = 4, - .args = { { CloudABILookup, 0 }, { BinString | IN, 1 }, - { CloudABIFileStat | IN, 3 }, { CloudABIFSFlags, 4 } } }, - { .name = "cloudabi_sys_file_symlink", .ret_type = 1, .nargs = 3, - .args = { { BinString | IN, 0 }, - { Int, 2 }, { BinString | IN, 3 } } }, - { .name = "cloudabi_sys_file_unlink", .ret_type = 1, .nargs = 3, - .args = { { Int, 0 }, { BinString | IN, 1 }, - { CloudABIULFlags, 3 } } }, - { .name = "cloudabi_sys_lock_unlock", .ret_type = 1, .nargs = 2, - .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, - { .name = "cloudabi_sys_mem_advise", .ret_type = 1, .nargs = 3, - .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIAdvice, 2 } } }, - { .name = "cloudabi_sys_mem_map", .ret_type = 1, .nargs = 6, - .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMProt, 2 }, - { CloudABIMFlags, 3 }, { Int, 4 }, { Int, 5 } } }, - { .name = "cloudabi_sys_mem_protect", .ret_type = 1, .nargs = 3, - .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMProt, 2 } } }, - { .name = "cloudabi_sys_mem_sync", .ret_type = 1, .nargs = 3, - .args = { { Ptr, 0 }, { Int, 1 }, { CloudABIMSFlags, 2 } } }, - { .name = "cloudabi_sys_mem_unmap", .ret_type = 1, .nargs = 2, - .args = { { Ptr, 0 }, { Int, 1 } } }, - { .name = "cloudabi_sys_proc_exec", .ret_type = 1, .nargs = 5, - .args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, - { IntArray, 3 }, { Int, 4 } } }, - { .name = "cloudabi_sys_proc_exit", .ret_type = 1, .nargs = 1, - .args = { { Int, 0 } } }, - { .name = "cloudabi_sys_proc_fork", .ret_type = 1, .nargs = 0 }, - { .name = "cloudabi_sys_proc_raise", .ret_type = 1, .nargs = 1, - .args = { { CloudABISignal, 0 } } }, - { .name = "cloudabi_sys_random_get", .ret_type = 1, .nargs = 2, - .args = { { BinString | OUT, 0 }, { Int, 1 } } }, - { .name = "cloudabi_sys_sock_shutdown", .ret_type = 1, .nargs = 2, - .args = { { Int, 0 }, { CloudABISDFlags, 1 } } }, - { .name = "cloudabi_sys_thread_exit", .ret_type = 1, .nargs = 2, - .args = { { Ptr, 0 }, { CloudABIMFlags, 1 } } }, - { .name = "cloudabi_sys_thread_yield", .ret_type = 1, .nargs = 0 }, }; static STAILQ_HEAD(, syscall) seen_syscalls; @@ -763,91 +665,6 @@ XEND }; -#undef X -#define X(a) { CLOUDABI_##a, #a }, - -static struct xlat cloudabi_advice[] = { - X(ADVICE_DONTNEED) X(ADVICE_NOREUSE) X(ADVICE_NORMAL) - X(ADVICE_RANDOM) X(ADVICE_SEQUENTIAL) X(ADVICE_WILLNEED) - XEND -}; - -static struct xlat cloudabi_clockid[] = { - X(CLOCK_MONOTONIC) X(CLOCK_PROCESS_CPUTIME_ID) - X(CLOCK_REALTIME) X(CLOCK_THREAD_CPUTIME_ID) - XEND -}; - -static struct xlat cloudabi_fdflags[] = { - X(FDFLAG_APPEND) X(FDFLAG_DSYNC) X(FDFLAG_NONBLOCK) - X(FDFLAG_RSYNC) X(FDFLAG_SYNC) - XEND -}; - -static struct xlat cloudabi_fdsflags[] = { - X(FDSTAT_FLAGS) X(FDSTAT_RIGHTS) - XEND -}; - -static struct xlat cloudabi_filetype[] = { - X(FILETYPE_UNKNOWN) X(FILETYPE_BLOCK_DEVICE) - X(FILETYPE_CHARACTER_DEVICE) X(FILETYPE_DIRECTORY) - X(FILETYPE_PROCESS) X(FILETYPE_REGULAR_FILE) - X(FILETYPE_SHARED_MEMORY) X(FILETYPE_SOCKET_DGRAM) - X(FILETYPE_SOCKET_STREAM) X(FILETYPE_SYMBOLIC_LINK) - XEND -}; - -static struct xlat cloudabi_fsflags[] = { - X(FILESTAT_ATIM) X(FILESTAT_ATIM_NOW) X(FILESTAT_MTIM) - X(FILESTAT_MTIM_NOW) X(FILESTAT_SIZE) - XEND -}; - -static struct xlat cloudabi_mflags[] = { - X(MAP_ANON) X(MAP_FIXED) X(MAP_PRIVATE) X(MAP_SHARED) - XEND -}; - -static struct xlat cloudabi_mprot[] = { - X(PROT_EXEC) X(PROT_WRITE) X(PROT_READ) - XEND -}; - -static struct xlat cloudabi_msflags[] = { - X(MS_ASYNC) X(MS_INVALIDATE) X(MS_SYNC) - XEND -}; - -static struct xlat cloudabi_oflags[] = { - X(O_CREAT) X(O_DIRECTORY) X(O_EXCL) X(O_TRUNC) - XEND -}; - -static struct xlat cloudabi_sdflags[] = { - X(SHUT_RD) X(SHUT_WR) - XEND -}; - -static struct xlat cloudabi_signal[] = { - X(SIGABRT) X(SIGALRM) X(SIGBUS) X(SIGCHLD) X(SIGCONT) X(SIGFPE) - X(SIGHUP) X(SIGILL) X(SIGINT) X(SIGKILL) X(SIGPIPE) X(SIGQUIT) - X(SIGSEGV) X(SIGSTOP) X(SIGSYS) X(SIGTERM) X(SIGTRAP) X(SIGTSTP) - X(SIGTTIN) X(SIGTTOU) X(SIGURG) X(SIGUSR1) X(SIGUSR2) - X(SIGVTALRM) X(SIGXCPU) X(SIGXFSZ) - XEND -}; - -static struct xlat cloudabi_ulflags[] = { - X(UNLINK_REMOVEDIR) - XEND -}; - -static struct xlat cloudabi_whence[] = { - X(WHENCE_CUR) X(WHENCE_END) X(WHENCE_SET) - XEND -}; - #undef X #undef XEND @@ -2872,80 +2689,6 @@ break; } - case CloudABIAdvice: - fputs(xlookup(cloudabi_advice, args[sc->offset]), fp); - break; - case CloudABIClockID: - fputs(xlookup(cloudabi_clockid, args[sc->offset]), fp); - break; - case CloudABIFDSFlags: - fputs(xlookup_bits(cloudabi_fdsflags, args[sc->offset]), fp); - break; - case CloudABIFDStat: { - cloudabi_fdstat_t fds; - if (get_struct(pid, args[sc->offset], &fds, sizeof(fds)) - != -1) { - fprintf(fp, "{ %s, ", - xlookup(cloudabi_filetype, fds.fs_filetype)); - fprintf(fp, "%s, ... }", - xlookup_bits(cloudabi_fdflags, fds.fs_flags)); - } else - print_pointer(fp, args[sc->offset]); - break; - } - case CloudABIFileStat: { - cloudabi_filestat_t fsb; - if (get_struct(pid, args[sc->offset], &fsb, sizeof(fsb)) - != -1) - fprintf(fp, "{ %s, %ju }", - xlookup(cloudabi_filetype, fsb.st_filetype), - (uintmax_t)fsb.st_size); - else - print_pointer(fp, args[sc->offset]); - break; - } - case CloudABIFileType: - fputs(xlookup(cloudabi_filetype, args[sc->offset]), fp); - break; - case CloudABIFSFlags: - fputs(xlookup_bits(cloudabi_fsflags, args[sc->offset]), fp); - break; - case CloudABILookup: - if ((args[sc->offset] & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) != 0) - fprintf(fp, "%d|LOOKUP_SYMLINK_FOLLOW", - (int)args[sc->offset]); - else - fprintf(fp, "%d", (int)args[sc->offset]); - break; - case CloudABIMFlags: - fputs(xlookup_bits(cloudabi_mflags, args[sc->offset]), fp); - break; - case CloudABIMProt: - fputs(xlookup_bits(cloudabi_mprot, args[sc->offset]), fp); - break; - case CloudABIMSFlags: - fputs(xlookup_bits(cloudabi_msflags, args[sc->offset]), fp); - break; - case CloudABIOFlags: - fputs(xlookup_bits(cloudabi_oflags, args[sc->offset]), fp); - break; - case CloudABISDFlags: - fputs(xlookup_bits(cloudabi_sdflags, args[sc->offset]), fp); - break; - case CloudABISignal: - fputs(xlookup(cloudabi_signal, args[sc->offset]), fp); - break; - case CloudABITimestamp: - fprintf(fp, "%lu.%09lus", args[sc->offset] / 1000000000, - args[sc->offset] % 1000000000); - break; - case CloudABIULFlags: - fputs(xlookup_bits(cloudabi_ulflags, args[sc->offset]), fp); - break; - case CloudABIWhence: - fputs(xlookup(cloudabi_whence, args[sc->offset]), fp); - break; - default: errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK); }