aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2021-09-12 22:50:39 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2021-09-21 21:18:44 +0000
commitcf0ee8738e31aa9e6fbf4dca4dac56d89226a71a (patch)
tree80dd53449d2afcd809cac8a4518480da87a468b5 /sys/compat
parentc2ee4dfd04970f1597eea58bb30eb93e1ed5a491 (diff)
downloadsrc-cf0ee8738e31aa9e6fbf4dca4dac56d89226a71a.tar.gz
src-cf0ee8738e31aa9e6fbf4dca4dac56d89226a71a.zip
Drop cloudabi
According to https://github.com/NuxiNL/cloudlibc: CloudABI is no longer being maintained. It was an awesome experiment, but it never got enough traction to be sustainable. There is no reason to keep it in FreeBSD. Approved by: ed (private mail) Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D31923
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/cloudabi/cloudabi_clock.c135
-rw-r--r--sys/compat/cloudabi/cloudabi_errno.c123
-rw-r--r--sys/compat/cloudabi/cloudabi_fd.c475
-rw-r--r--sys/compat/cloudabi/cloudabi_file.c763
-rw-r--r--sys/compat/cloudabi/cloudabi_futex.c1165
-rw-r--r--sys/compat/cloudabi/cloudabi_mem.c167
-rw-r--r--sys/compat/cloudabi/cloudabi_proc.c148
-rw-r--r--sys/compat/cloudabi/cloudabi_proto.h36
-rw-r--r--sys/compat/cloudabi/cloudabi_random.c53
-rw-r--r--sys/compat/cloudabi/cloudabi_sock.c186
-rw-r--r--sys/compat/cloudabi/cloudabi_thread.c66
-rw-r--r--sys/compat/cloudabi/cloudabi_util.h87
-rw-r--r--sys/compat/cloudabi/cloudabi_vdso.c90
-rw-r--r--sys/compat/cloudabi/cloudabi_vdso.lds51
-rw-r--r--sys/compat/cloudabi32/Makefile6
-rw-r--r--sys/compat/cloudabi32/cloudabi32_fd.c145
-rw-r--r--sys/compat/cloudabi32/cloudabi32_module.c184
-rw-r--r--sys/compat/cloudabi32/cloudabi32_poll.c340
-rw-r--r--sys/compat/cloudabi32/cloudabi32_proto.h420
-rw-r--r--sys/compat/cloudabi32/cloudabi32_sock.c128
-rw-r--r--sys/compat/cloudabi32/cloudabi32_syscall.h57
-rw-r--r--sys/compat/cloudabi32/cloudabi32_syscalls.c58
-rw-r--r--sys/compat/cloudabi32/cloudabi32_sysent.c66
-rw-r--r--sys/compat/cloudabi32/cloudabi32_systrace_args.c1458
-rw-r--r--sys/compat/cloudabi32/cloudabi32_thread.c77
-rw-r--r--sys/compat/cloudabi32/cloudabi32_util.h51
-rw-r--r--sys/compat/cloudabi32/syscalls.conf15
-rw-r--r--sys/compat/cloudabi64/Makefile6
-rw-r--r--sys/compat/cloudabi64/cloudabi64_fd.c145
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c184
-rw-r--r--sys/compat/cloudabi64/cloudabi64_poll.c340
-rw-r--r--sys/compat/cloudabi64/cloudabi64_proto.h420
-rw-r--r--sys/compat/cloudabi64/cloudabi64_sock.c128
-rw-r--r--sys/compat/cloudabi64/cloudabi64_syscall.h57
-rw-r--r--sys/compat/cloudabi64/cloudabi64_syscalls.c58
-rw-r--r--sys/compat/cloudabi64/cloudabi64_sysent.c66
-rw-r--r--sys/compat/cloudabi64/cloudabi64_systrace_args.c1458
-rw-r--r--sys/compat/cloudabi64/cloudabi64_thread.c77
-rw-r--r--sys/compat/cloudabi64/cloudabi64_util.h51
-rw-r--r--sys/compat/cloudabi64/syscalls.conf15
40 files changed, 0 insertions, 9555 deletions
diff --git a/sys/compat/cloudabi/cloudabi_clock.c b/sys/compat/cloudabi/cloudabi_clock.c
deleted file mode 100644
index 508640f950e5..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/stdint.h>
-#include <sys/systm.h>
-#include <sys/syscallsubr.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-#include <compat/cloudabi/cloudabi_util.h>
-
-/* 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
index 10304bad4af5..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-/* 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
index ba93db3c0bfd..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/capsicum.h>
-#include <sys/fcntl.h>
-#include <sys/filedesc.h>
-#include <sys/proc.h>
-#include <sys/mman.h>
-#include <sys/socketvar.h>
-#include <sys/syscallsubr.h>
-#include <sys/sysproto.h>
-#include <sys/systm.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-#include <compat/cloudabi/cloudabi_util.h>
-
-/* 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
index 83987b79aa0c..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/capsicum.h>
-#include <sys/dirent.h>
-#include <sys/fcntl.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/stat.h>
-#include <sys/syscallsubr.h>
-#include <sys/uio.h>
-#include <sys/vnode.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <security/mac/mac_framework.h>
-
-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
index fd2a1d515483..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/limits.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/sx.h>
-#include <sys/systm.h>
-#include <sys/umtxvar.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-#include <compat/cloudabi/cloudabi_util.h>
-
-/*
- * 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
index 426adb6ff43f..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/proc.h>
-#include <sys/syscallsubr.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-
-/* 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
index 378409edaeff..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/capsicum.h>
-#include <sys/filedesc.h>
-#include <sys/imgact.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-#include <sys/syscallsubr.h>
-#include <sys/unistd.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-
-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
index 95271fd3a575..000000000000
--- 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 <contrib/cloudabi/cloudabi64_types.h>
-
-#include <compat/cloudabi64/cloudabi64_proto.h>
diff --git a/sys/compat/cloudabi/cloudabi_random.c b/sys/compat/cloudabi/cloudabi_random.c
deleted file mode 100644
index 02a3252a1b54..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <sys/random.h>
-#include <sys/uio.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-
-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
index f9f9f0510f2a..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/capsicum.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/syscallsubr.h>
-#include <sys/systm.h>
-
-#include <net/vnet.h>
-
-#include <netinet/in.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-#include <compat/cloudabi/cloudabi_util.h>
-
-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
index f920b8b41ee8..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/sched.h>
-#include <sys/syscallsubr.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-#include <compat/cloudabi/cloudabi_proto.h>
-
-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
index 0f07dc53fa29..000000000000
--- 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 <sys/socket.h>
-
-#include <contrib/cloudabi/cloudabi_types_common.h>
-
-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
index ab621b3c18b0..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/lock.h>
-#include <sys/sysent.h>
-#include <sys/rwlock.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
-#include <vm/vm_pager.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-void
-cloudabi_vdso_init(struct sysentvec *sv, char *begin, char *end)
-{
- vm_page_t m;
- vm_object_t obj;
- vm_offset_t addr;
- size_t i, pages, pages_length, vdso_length;
-
- /* Determine the number of pages needed to store the vDSO. */
- vdso_length = end - begin;
- pages = howmany(vdso_length, PAGE_SIZE);
- pages_length = pages * PAGE_SIZE;
-
- /* Allocate a VM object and fill it with the vDSO. */
- obj = vm_pager_allocate(OBJT_PHYS, 0, pages_length,
- VM_PROT_DEFAULT, 0, NULL);
- addr = kva_alloc(PAGE_SIZE);
- for (i = 0; i < pages; ++i) {
- VM_OBJECT_WLOCK(obj);
- m = vm_page_grab(obj, i, VM_ALLOC_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
index 807c48859bf2..000000000000
--- 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
index 9b059738c45d..000000000000
--- 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
index 19907a95b07e..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/limits.h>
-#include <sys/malloc.h>
-#include <sys/syscallsubr.h>
-#include <sys/systm.h>
-#include <sys/uio.h>
-
-#include <contrib/cloudabi/cloudabi32_types.h>
-
-#include <compat/cloudabi32/cloudabi32_proto.h>
-#include <compat/cloudabi32/cloudabi32_util.h>
-
-/* Copies in 32-bit iovec structures from userspace. */
-static int
-cloudabi32_copyinuio(const cloudabi32_iovec_t *iovp, size_t iovcnt,
- struct uio **uiop)
-{
- cloudabi32_iovec_t iovobj;
- struct uio *uio;
- struct iovec *iov;
- size_t i;
- int error;
-
- /* Allocate uio and iovecs. */
- if (iovcnt > UIO_MAXIOV)
- return (EINVAL);
- uio = malloc(sizeof(struct uio) + iovcnt * sizeof(struct iovec),
- M_IOV, M_WAITOK);
- iov = (struct iovec *)(uio + 1);
-
- /* Initialize uio. */
- uio->uio_iov = iov;
- uio->uio_iovcnt = iovcnt;
- uio->uio_segflg = UIO_USERSPACE;
- uio->uio_offset = -1;
- uio->uio_resid = 0;
-
- /* Copy in iovecs. */
- for (i = 0; i < iovcnt; i++) {
- error = copyin(&iovp[i], &iovobj, sizeof(iovobj));
- if (error != 0) {
- free(uio, M_IOV);
- return (error);
- }
- iov[i].iov_base = TO_PTR(iovobj.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
index 3463101193a5..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/imgact.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/proc.h>
-#include <sys/smp.h>
-#include <sys/sysctl.h>
-#include <sys/sysent.h>
-#include <sys/systm.h>
-
-#include <contrib/cloudabi/cloudabi32_types.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <compat/cloudabi32/cloudabi32_util.h>
-
-extern char _binary_cloudabi32_vdso_o_start[];
-extern char _binary_cloudabi32_vdso_o_end[];
-
-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
index 2fda78f8adf9..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/syscallsubr.h>
-
-#include <contrib/cloudabi/cloudabi32_types.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <compat/cloudabi32/cloudabi32_proto.h>
-#include <compat/cloudabi32/cloudabi32_util.h>
-
-/* Converts a FreeBSD signal number to a CloudABI signal number. */
-static cloudabi_signal_t
-convert_signal(int sig)
-{
- static const cloudabi_signal_t signals[] = {
- [SIGABRT] = CLOUDABI_SIGABRT,
- [SIGALRM] = CLOUDABI_SIGALRM,
- [SIGBUS] = CLOUDABI_SIGBUS,
- [SIGCHLD] = CLOUDABI_SIGCHLD,
- [SIGCONT] = CLOUDABI_SIGCONT,
- [SIGFPE] = CLOUDABI_SIGFPE,
- [SIGHUP] = CLOUDABI_SIGHUP,
- [SIGILL] = CLOUDABI_SIGILL,
- [SIGINT] = CLOUDABI_SIGINT,
- [SIGKILL] = CLOUDABI_SIGKILL,
- [SIGPIPE] = CLOUDABI_SIGPIPE,
- [SIGQUIT] = CLOUDABI_SIGQUIT,
- [SIGSEGV] = CLOUDABI_SIGSEGV,
- [SIGSTOP] = CLOUDABI_SIGSTOP,
- [SIGSYS] = CLOUDABI_SIGSYS,
- [SIGTERM] = CLOUDABI_SIGTERM,
- [SIGTRAP] = CLOUDABI_SIGTRAP,
- [SIGTSTP] = CLOUDABI_SIGTSTP,
- [SIGTTIN] = CLOUDABI_SIGTTIN,
- [SIGTTOU] = CLOUDABI_SIGTTOU,
- [SIGURG] = CLOUDABI_SIGURG,
- [SIGUSR1] = CLOUDABI_SIGUSR1,
- [SIGUSR2] = CLOUDABI_SIGUSR2,
- [SIGVTALRM] = CLOUDABI_SIGVTALRM,
- [SIGXCPU] = CLOUDABI_SIGXCPU,
- [SIGXFSZ] = CLOUDABI_SIGXFSZ,
- };
-
- /* Convert unknown signals to SIGABRT. */
- if (sig < 0 || sig >= nitems(signals) || signals[sig] == 0)
- return (SIGABRT);
- return (signals[sig]);
-}
-
-struct cloudabi32_kevent_args {
- const cloudabi32_subscription_t *in;
- 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, &copyops));
-}
diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h
deleted file mode 100644
index 453c6db1fd8b..000000000000
--- 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 <sys/signal.h>
-#include <sys/acl.h>
-#include <sys/cpuset.h>
-#include <sys/domainset.h>
-#include <sys/_ffcounter.h>
-#include <sys/_semaphore.h>
-#include <sys/ucontext.h>
-#include <sys/wait.h>
-
-#include <bsm/audit_kevents.h>
-
-struct proc;
-
-struct thread;
-
-#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
- 0 : sizeof(register_t) - sizeof(t))
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define PADL_(t) 0
-#define PADR_(t) PAD_(t)
-#else
-#define PADL_(t) PAD_(t)
-#define PADR_(t) 0
-#endif
-
-struct cloudabi_sys_clock_res_get_args {
- char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)];
-};
-struct cloudabi_sys_clock_time_get_args {
- char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)];
- char precision_l_[PADL_(cloudabi_timestamp_t)]; cloudabi_timestamp_t precision; char precision_r_[PADR_(cloudabi_timestamp_t)];
-};
-struct cloudabi_sys_condvar_signal_args {
- char condvar_l_[PADL_(cloudabi_condvar_t *)]; cloudabi_condvar_t * condvar; char condvar_r_[PADR_(cloudabi_condvar_t *)];
- char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)];
- char nwaiters_l_[PADL_(cloudabi_nthreads_t)]; cloudabi_nthreads_t nwaiters; char nwaiters_r_[PADR_(cloudabi_nthreads_t)];
-};
-struct cloudabi_sys_fd_close_args {
- char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
-};
-struct cloudabi_sys_fd_create1_args {
- char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
-};
-struct cloudabi_sys_fd_create2_args {
- char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
-};
-struct cloudabi_sys_fd_datasync_args {
- char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
-};
-struct cloudabi_sys_fd_dup_args {
- char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)];
-};
-struct cloudabi32_sys_fd_pread_args {
- char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
- char 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
index 97cb4478cf57..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-#include <sys/uio.h>
-
-#include <contrib/cloudabi/cloudabi32_types.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <compat/cloudabi32/cloudabi32_proto.h>
-#include <compat/cloudabi32/cloudabi32_util.h>
-
-static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket");
-
-int
-cloudabi32_sys_sock_recv(struct thread *td,
- struct cloudabi32_sys_sock_recv_args *uap)
-{
- 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
index b7496fa011a9..000000000000
--- 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
index 3ee4a286b001..000000000000
--- 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
index 7f07ed8e9236..000000000000
--- 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 <sys/sysent.h>
-#include <sys/sysproto.h>
-#include <contrib/cloudabi/cloudabi32_types.h>
-#include <compat/cloudabi32/cloudabi32_proto.h>
-
-#define AS(name) (sizeof(struct name) / sizeof(register_t))
-
-/* The casts are bogus but will do for now. */
-struct sysent cloudabi32_sysent[] = {
- { .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
index d52ddd6e0d9c..000000000000
--- 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
index 233700b40f1f..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-
-#include <contrib/cloudabi/cloudabi32_types.h>
-
-#include <compat/cloudabi32/cloudabi32_proto.h>
-#include <compat/cloudabi32/cloudabi32_util.h>
-
-struct thread_create_args {
- cloudabi32_threadattr_t attr;
- uint32_t tcb;
- lwpid_t tid;
-};
-
-static int
-initialize_thread(struct thread *td, void *thunk)
-{
- struct thread_create_args *args = thunk;
-
- /* Save the thread ID, so it can be returned. */
- args->tid = td->td_tid;
-
- /* Set up initial register contents. */
- return (cloudabi32_thread_setregs(td, &args->attr, args->tcb));
-}
-
-int
-cloudabi32_sys_thread_create(struct thread *td,
- struct cloudabi32_sys_thread_create_args *uap)
-{
- struct thread_create_args args;
- int error;
-
- error = copyin(uap->attr, &args.attr, sizeof(args.attr));
- if (error != 0)
- return (error);
-
- /* Remove some space on the top of the stack for the TCB. */
- args.tcb = rounddown(args.attr.stack + args.attr.stack_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
index 917356468311..000000000000
--- 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 <sys/types.h>
-#define __ELF_WORD_SIZE 32
-#include <sys/imgact_elf.h>
-
-#include <contrib/cloudabi/cloudabi32_types.h>
-
-struct image_params;
-struct thread;
-
-extern Elf32_Brandinfo cloudabi32_brand;
-
-#define TO_PTR(x) ((void *)(uintptr_t)(x))
-
-/* Stack initialization during process execution. */
-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
index 8e6522a63cef..000000000000
--- 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
index e3379384942c..000000000000
--- 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
index ea403cf3559f..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/limits.h>
-#include <sys/malloc.h>
-#include <sys/syscallsubr.h>
-#include <sys/systm.h>
-#include <sys/uio.h>
-
-#include <contrib/cloudabi/cloudabi64_types.h>
-
-#include <compat/cloudabi64/cloudabi64_proto.h>
-#include <compat/cloudabi64/cloudabi64_util.h>
-
-/* Copies in 64-bit iovec structures from userspace. */
-static int
-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
index ed0c85b4aba5..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/imgact.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/proc.h>
-#include <sys/smp.h>
-#include <sys/sysctl.h>
-#include <sys/sysent.h>
-#include <sys/systm.h>
-
-#include <contrib/cloudabi/cloudabi64_types.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <compat/cloudabi64/cloudabi64_util.h>
-
-extern char _binary_cloudabi64_vdso_o_start[];
-extern char _binary_cloudabi64_vdso_o_end[];
-
-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
index 2d3d87f3ac7f..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/syscallsubr.h>
-
-#include <contrib/cloudabi/cloudabi64_types.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <compat/cloudabi64/cloudabi64_proto.h>
-#include <compat/cloudabi64/cloudabi64_util.h>
-
-/* Converts a FreeBSD signal number to a CloudABI signal number. */
-static cloudabi_signal_t
-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, &copyops));
-}
diff --git a/sys/compat/cloudabi64/cloudabi64_proto.h b/sys/compat/cloudabi64/cloudabi64_proto.h
deleted file mode 100644
index 54bf9965a793..000000000000
--- 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 <sys/signal.h>
-#include <sys/acl.h>
-#include <sys/cpuset.h>
-#include <sys/domainset.h>
-#include <sys/_ffcounter.h>
-#include <sys/_semaphore.h>
-#include <sys/ucontext.h>
-#include <sys/wait.h>
-
-#include <bsm/audit_kevents.h>
-
-struct proc;
-
-struct thread;
-
-#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
- 0 : sizeof(register_t) - sizeof(t))
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define PADL_(t) 0
-#define PADR_(t) PAD_(t)
-#else
-#define PADL_(t) PAD_(t)
-#define PADR_(t) 0
-#endif
-
-struct cloudabi_sys_clock_res_get_args {
- char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)];
-};
-struct cloudabi_sys_clock_time_get_args {
- char clock_id_l_[PADL_(cloudabi_clockid_t)]; cloudabi_clockid_t clock_id; char clock_id_r_[PADR_(cloudabi_clockid_t)];
- char precision_l_[PADL_(cloudabi_timestamp_t)]; cloudabi_timestamp_t precision; char precision_r_[PADR_(cloudabi_timestamp_t)];
-};
-struct cloudabi_sys_condvar_signal_args {
- char condvar_l_[PADL_(cloudabi_condvar_t *)]; cloudabi_condvar_t * condvar; char condvar_r_[PADR_(cloudabi_condvar_t *)];
- char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)];
- char nwaiters_l_[PADL_(cloudabi_nthreads_t)]; cloudabi_nthreads_t nwaiters; char nwaiters_r_[PADR_(cloudabi_nthreads_t)];
-};
-struct cloudabi_sys_fd_close_args {
- char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
-};
-struct cloudabi_sys_fd_create1_args {
- char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
-};
-struct cloudabi_sys_fd_create2_args {
- char type_l_[PADL_(cloudabi_filetype_t)]; cloudabi_filetype_t type; char type_r_[PADR_(cloudabi_filetype_t)];
-};
-struct cloudabi_sys_fd_datasync_args {
- char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)];
-};
-struct cloudabi_sys_fd_dup_args {
- char from_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t from; char from_r_[PADR_(cloudabi_fd_t)];
-};
-struct 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
index 001adada384a..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-#include <sys/uio.h>
-
-#include <contrib/cloudabi/cloudabi64_types.h>
-
-#include <compat/cloudabi/cloudabi_util.h>
-
-#include <compat/cloudabi64/cloudabi64_proto.h>
-#include <compat/cloudabi64/cloudabi64_util.h>
-
-static MALLOC_DEFINE(M_SOCKET, "socket", "CloudABI socket");
-
-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
index 9a3ba53797c6..000000000000
--- 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
index 5019ad930d52..000000000000
--- 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
index 1edae8bb8281..000000000000
--- 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 <sys/sysent.h>
-#include <sys/sysproto.h>
-#include <contrib/cloudabi/cloudabi64_types.h>
-#include <compat/cloudabi64/cloudabi64_proto.h>
-
-#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
index 75ea221e879d..000000000000
--- 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
index 4cb980b1530d..000000000000
--- 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 <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-
-#include <contrib/cloudabi/cloudabi64_types.h>
-
-#include <compat/cloudabi64/cloudabi64_proto.h>
-#include <compat/cloudabi64/cloudabi64_util.h>
-
-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
index 27088392c75a..000000000000
--- 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 <sys/types.h>
-#define __ELF_WORD_SIZE 64
-#include <sys/imgact_elf.h>
-
-#include <contrib/cloudabi/cloudabi64_types.h>
-
-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
index 6b75dbb85d40..000000000000
--- 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' ','`