diff options
Diffstat (limited to 'sys')
34 files changed, 843 insertions, 816 deletions
diff --git a/sys/amd64/cloudabi32/cloudabi32_sysvec.c b/sys/amd64/cloudabi32/cloudabi32_sysvec.c index 08481bc..fa2f9ae 100644 --- a/sys/amd64/cloudabi32/cloudabi32_sysvec.c +++ b/sys/amd64/cloudabi32/cloudabi32_sysvec.c @@ -181,7 +181,7 @@ cloudabi32_thread_setregs(struct thread *td, /* Perform standard register initialization. */ stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_size - sizeof(args); + stack.ss_size = attr->stack_len - sizeof(args); cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* diff --git a/sys/amd64/cloudabi64/cloudabi64_sysvec.c b/sys/amd64/cloudabi64/cloudabi64_sysvec.c index 6e4b95e..3a21ff3 100644 --- a/sys/amd64/cloudabi64/cloudabi64_sysvec.c +++ b/sys/amd64/cloudabi64/cloudabi64_sysvec.c @@ -164,7 +164,7 @@ cloudabi64_thread_setregs(struct thread *td, * from the top of the stack to store a single element array, * containing a pointer to the TCB. %fs base will point to this. */ - tcbptr = rounddown(attr->stack + attr->stack_size - sizeof(tcbptr), + tcbptr = rounddown(attr->stack + attr->stack_len - sizeof(tcbptr), _Alignof(tcbptr)); error = copyout(&tcb, (void *)tcbptr, sizeof(tcb)); if (error != 0) diff --git a/sys/arm/cloudabi32/cloudabi32_sysvec.c b/sys/arm/cloudabi32/cloudabi32_sysvec.c index 6eb8035..f4e231b 100644 --- a/sys/arm/cloudabi32/cloudabi32_sysvec.c +++ b/sys/arm/cloudabi32/cloudabi32_sysvec.c @@ -148,7 +148,7 @@ cloudabi32_thread_setregs(struct thread *td, /* Perform standard register initialization. */ stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_size; + stack.ss_size = attr->stack_len; cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* diff --git a/sys/arm64/cloudabi64/cloudabi64_sysvec.c b/sys/arm64/cloudabi64/cloudabi64_sysvec.c index 6f97f3a..fc786de 100644 --- a/sys/arm64/cloudabi64/cloudabi64_sysvec.c +++ b/sys/arm64/cloudabi64/cloudabi64_sysvec.c @@ -140,7 +140,7 @@ cloudabi64_thread_setregs(struct thread *td, /* Perform standard register initialization. */ stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_size; + stack.ss_size = attr->stack_len; cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* diff --git a/sys/compat/cloudabi/cloudabi_file.c b/sys/compat/cloudabi/cloudabi_file.c index f48b754..f5417e0 100644 --- a/sys/compat/cloudabi/cloudabi_file.c +++ b/sys/compat/cloudabi/cloudabi_file.c @@ -146,7 +146,7 @@ cloudabi_sys_file_create(struct thread *td, char *path; int error; - error = copyin_path(uap->path, uap->pathlen, &path); + error = copyin_path(uap->path, uap->path_len, &path); if (error != 0) return (error); @@ -177,10 +177,10 @@ cloudabi_sys_file_link(struct thread *td, char *path1, *path2; int error; - error = copyin_path(uap->path1, uap->path1len, &path1); + error = copyin_path(uap->path1, uap->path1_len, &path1); if (error != 0) return (error); - error = copyin_path(uap->path2, uap->path2len, &path2); + error = copyin_path(uap->path2, uap->path2_len, &path2); if (error != 0) { cloudabi_freestr(path1); return (error); @@ -261,7 +261,7 @@ cloudabi_sys_file_open(struct thread *td, fp->f_flag = fflags & FMASK; /* Open path. */ - error = copyin_path(uap->path, uap->pathlen, &path); + error = copyin_path(uap->path, uap->path_len, &path); if (error != 0) { fdrop(fp, td); return (error); @@ -380,7 +380,7 @@ cloudabi_sys_file_readdir(struct thread *td, { struct iovec iov = { .iov_base = uap->buf, - .iov_len = uap->nbyte + .iov_len = uap->buf_len }; struct uio uio = { .uio_iov = &iov, @@ -494,7 +494,7 @@ done: return (error); /* Return number of bytes copied to userspace. */ - td->td_retval[0] = uap->nbyte - uio.uio_resid; + td->td_retval[0] = uap->buf_len - uio.uio_resid; return (0); } @@ -505,12 +505,12 @@ cloudabi_sys_file_readlink(struct thread *td, char *path; int error; - error = copyin_path(uap->path, uap->pathlen, &path); + 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->bufsize); + uap->buf, UIO_USERSPACE, uap->buf_len); cloudabi_freestr(path); return (error); } @@ -522,16 +522,16 @@ cloudabi_sys_file_rename(struct thread *td, char *old, *new; int error; - error = copyin_path(uap->old, uap->oldlen, &old); + error = copyin_path(uap->path1, uap->path1_len, &old); if (error != 0) return (error); - error = copyin_path(uap->new, uap->newlen, &new); + error = copyin_path(uap->path2, uap->path2_len, &new); if (error != 0) { cloudabi_freestr(old); return (error); } - error = kern_renameat(td, uap->oldfd, old, uap->newfd, new, + error = kern_renameat(td, uap->fd1, old, uap->fd2, new, UIO_SYSSPACE); cloudabi_freestr(old); cloudabi_freestr(new); @@ -653,7 +653,7 @@ cloudabi_sys_file_stat_get(struct thread *td, char *path; int error; - error = copyin_path(uap->path, uap->pathlen, &path); + error = copyin_path(uap->path, uap->path_len, &path); if (error != 0) return (error); @@ -707,7 +707,7 @@ cloudabi_sys_file_stat_put(struct thread *td, error = copyin(uap->buf, &fs, sizeof(fs)); if (error != 0) return (error); - error = copyin_path(uap->path, uap->pathlen, &path); + error = copyin_path(uap->path, uap->path_len, &path); if (error != 0) return (error); @@ -726,10 +726,10 @@ cloudabi_sys_file_symlink(struct thread *td, char *path1, *path2; int error; - error = copyin_path(uap->path1, uap->path1len, &path1); + error = copyin_path(uap->path1, uap->path1_len, &path1); if (error != 0) return (error); - error = copyin_path(uap->path2, uap->path2len, &path2); + error = copyin_path(uap->path2, uap->path2_len, &path2); if (error != 0) { cloudabi_freestr(path1); return (error); @@ -748,7 +748,7 @@ cloudabi_sys_file_unlink(struct thread *td, char *path; int error; - error = copyin_path(uap->path, uap->pathlen, &path); + error = copyin_path(uap->path, uap->path_len, &path); if (error != 0) return (error); diff --git a/sys/compat/cloudabi/cloudabi_mem.c b/sys/compat/cloudabi/cloudabi_mem.c index 7c0abe6..30d9a6f 100644 --- a/sys/compat/cloudabi/cloudabi_mem.c +++ b/sys/compat/cloudabi/cloudabi_mem.c @@ -85,7 +85,7 @@ cloudabi_sys_mem_advise(struct thread *td, return (EINVAL); } - return (kern_madvise(td, (uintptr_t)uap->addr, uap->len, + return (kern_madvise(td, (uintptr_t)uap->mapping, uap->mapping_len, behav)); } @@ -94,7 +94,7 @@ cloudabi_sys_mem_lock(struct thread *td, struct cloudabi_sys_mem_lock_args *uap) { return (kern_mlock(td->td_proc, td->td_ucred, - __DECONST(uintptr_t, uap->addr), uap->len)); + __DECONST(uintptr_t, uap->mapping), uap->mapping_len)); } int @@ -133,7 +133,7 @@ cloudabi_sys_mem_protect(struct thread *td, if (error != 0) return (error); - return (kern_mprotect(td, (uintptr_t)uap->addr, uap->len, + return (kern_mprotect(td, (uintptr_t)uap->mapping, uap->mapping_len, prot)); } @@ -156,7 +156,7 @@ cloudabi_sys_mem_sync(struct thread *td, struct cloudabi_sys_mem_sync_args *uap) if ((uap->flags & CLOUDABI_MS_INVALIDATE) != 0) flags |= MS_INVALIDATE; - return (kern_msync(td, (uintptr_t)uap->addr, uap->len, + return (kern_msync(td, (uintptr_t)uap->mapping, uap->mapping_len, flags)); } @@ -165,8 +165,8 @@ cloudabi_sys_mem_unlock(struct thread *td, struct cloudabi_sys_mem_unlock_args *uap) { - return (kern_munlock(td, __DECONST(uintptr_t, uap->addr), - uap->len)); + return (kern_munlock(td, __DECONST(uintptr_t, uap->mapping), + uap->mapping_len)); } int @@ -174,5 +174,5 @@ cloudabi_sys_mem_unmap(struct thread *td, struct cloudabi_sys_mem_unmap_args *uap) { - return (kern_munmap(td, (uintptr_t)uap->addr, uap->len)); + 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 index 139af2c..2433331 100644 --- a/sys/compat/cloudabi/cloudabi_proc.c +++ b/sys/compat/cloudabi/cloudabi_proc.c @@ -53,8 +53,8 @@ cloudabi_sys_proc_exec(struct thread *td, error = pre_execve(td, &oldvmspace); if (error != 0) return (error); - error = exec_copyin_data_fds(td, &args, uap->data, uap->datalen, - uap->fds, uap->fdslen); + 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); diff --git a/sys/compat/cloudabi/cloudabi_random.c b/sys/compat/cloudabi/cloudabi_random.c index 76a9360..02a3252 100644 --- a/sys/compat/cloudabi/cloudabi_random.c +++ b/sys/compat/cloudabi/cloudabi_random.c @@ -38,7 +38,7 @@ cloudabi_sys_random_get(struct thread *td, { struct iovec iov = { .iov_base = uap->buf, - .iov_len = uap->nbyte + .iov_len = uap->buf_len }; struct uio uio = { .uio_iov = &iov, diff --git a/sys/compat/cloudabi/cloudabi_sock.c b/sys/compat/cloudabi/cloudabi_sock.c index bbecc49..9d0e036 100644 --- a/sys/compat/cloudabi/cloudabi_sock.c +++ b/sys/compat/cloudabi/cloudabi_sock.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * 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 @@ -30,7 +30,9 @@ __FBSDID("$FreeBSD$"); #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> @@ -48,7 +50,7 @@ __FBSDID("$FreeBSD$"); #include <compat/cloudabi/cloudabi_util.h> /* Converts FreeBSD's struct sockaddr to CloudABI's cloudabi_sockaddr_t. */ -void +static void cloudabi_convert_sockaddr(const struct sockaddr *sa, socklen_t sal, cloudabi_sockaddr_t *rsa) { @@ -140,7 +142,7 @@ cloudabi_sys_sock_bind(struct thread *td, struct sockaddr_un sun; int error; - error = copyin_sockaddr_un(uap->path, uap->pathlen, &sun); + error = copyin_sockaddr_un(uap->path, uap->path_len, &sun); if (error != 0) return (error); return (kern_bindat(td, uap->fd, uap->sock, (struct sockaddr *)&sun)); @@ -153,7 +155,7 @@ cloudabi_sys_sock_connect(struct thread *td, struct sockaddr_un sun; int error; - error = copyin_sockaddr_un(uap->path, uap->pathlen, &sun); + error = copyin_sockaddr_un(uap->path, uap->path_len, &sun); if (error != 0) return (error); return (kern_connectat(td, uap->fd, uap->sock, @@ -243,3 +245,126 @@ cloudabi_sys_sock_stat_get(struct thread *td, fdrop(fp, td); return (copyout(&ss, uap->buf, sizeof(ss))); } + +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_msgflags_t flags, size_t *rdatalen, size_t *rfdslen, + cloudabi_sockaddr_t *peername, cloudabi_msgflags_t *rflags) +{ + struct sockaddr_storage ss; + struct msghdr hdr = { + .msg_name = &ss, + .msg_namelen = sizeof(ss), + .msg_iov = data, + .msg_iovlen = datalen, + }; + struct mbuf *control; + int error; + + /* Convert flags. */ + if (flags & CLOUDABI_MSG_PEEK) + hdr.msg_flags |= MSG_PEEK; + if (flags & CLOUDABI_MSG_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; + cloudabi_convert_sockaddr((struct sockaddr *)&ss, + MIN(hdr.msg_namelen, sizeof(ss)), peername); + *rflags = 0; + if (hdr.msg_flags & MSG_EOR) + *rflags |= CLOUDABI_MSG_EOR; + if (hdr.msg_flags & MSG_TRUNC) + *rflags |= CLOUDABI_MSG_TRUNC; + + /* 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. */ + nfds = fdslen; + *rflags |= CLOUDABI_MSG_CTRUNC; + } + error = copyout(CMSG_DATA(chdr), fds, + nfds * sizeof(int)); + if (error != 0) { + m_free(control); + return (error); + } + fds += nfds; + fdslen -= nfds; + *rfdslen += nfds; + } + } + m_free(control); + } + return (0); +} + +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, + cloudabi_msgflags_t flags, size_t *rdatalen) +{ + struct msghdr hdr = { + .msg_iov = data, + .msg_iovlen = datalen, + }; + struct mbuf *control; + int error, mflags; + + /* Convert flags. */ + mflags = MSG_NOSIGNAL; + if (flags & CLOUDABI_MSG_EOR) + mflags |= MSG_EOR; + + /* 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, mflags, 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_util.h b/sys/compat/cloudabi/cloudabi_util.h index 6eb65aa..e263d55 100644 --- a/sys/compat/cloudabi/cloudabi_util.h +++ b/sys/compat/cloudabi/cloudabi_util.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * 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 @@ -44,10 +44,6 @@ int cloudabi_clock_time_get(struct thread *, cloudabi_clockid_t, /* Converts a FreeBSD errno to a CloudABI errno. */ cloudabi_errno_t cloudabi_convert_errno(int); -/* Converts FreeBSD's struct sockaddr to CloudABI's cloudabi_sockaddr_t. */ -void cloudabi_convert_sockaddr(const struct sockaddr *, socklen_t, - cloudabi_sockaddr_t *); - /* Converts a file descriptor to a CloudABI file descriptor type. */ cloudabi_filetype_t cloudabi_convert_filetype(const struct file *); @@ -77,6 +73,13 @@ int cloudabi_futex_lock_wrlock(struct thread *, cloudabi_lock_t *, cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); +/* Socket operations. */ +int cloudabi_sock_recv(struct thread *, cloudabi_fd_t, struct iovec *, size_t, + cloudabi_fd_t *, size_t, cloudabi_msgflags_t, size_t *, size_t *, + cloudabi_sockaddr_t *, cloudabi_msgflags_t *); +int cloudabi_sock_send(struct thread *, cloudabi_fd_t, struct iovec *, size_t, + const cloudabi_fd_t *, size_t, cloudabi_msgflags_t, size_t *); + /* vDSO setup and teardown. */ void cloudabi_vdso_init(struct sysentvec *, char *, char *); void cloudabi_vdso_destroy(struct sysentvec *); diff --git a/sys/compat/cloudabi32/cloudabi32_fd.c b/sys/compat/cloudabi32/cloudabi32_fd.c index 1754c48..19907a9 100644 --- a/sys/compat/cloudabi32/cloudabi32_fd.c +++ b/sys/compat/cloudabi32/cloudabi32_fd.c @@ -71,8 +71,8 @@ cloudabi32_copyinuio(const cloudabi32_iovec_t *iovp, size_t iovcnt, free(uio, M_IOV); return (error); } - iov[i].iov_base = TO_PTR(iovobj.iov_base); - iov[i].iov_len = iovobj.iov_len; + 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); @@ -91,7 +91,7 @@ cloudabi32_sys_fd_pread(struct thread *td, struct uio *uio; int error; - error = cloudabi32_copyinuio(uap->iov, uap->iovcnt, &uio); + error = cloudabi32_copyinuio(uap->iovs, uap->iovs_len, &uio); if (error != 0) return (error); error = kern_preadv(td, uap->fd, uio, uap->offset); @@ -106,7 +106,7 @@ cloudabi32_sys_fd_pwrite(struct thread *td, struct uio *uio; int error; - error = cloudabi32_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); + 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); @@ -121,7 +121,7 @@ cloudabi32_sys_fd_read(struct thread *td, struct uio *uio; int error; - error = cloudabi32_copyinuio(uap->iov, uap->iovcnt, &uio); + error = cloudabi32_copyinuio(uap->iovs, uap->iovs_len, &uio); if (error != 0) return (error); error = kern_readv(td, uap->fd, uio); @@ -136,7 +136,7 @@ cloudabi32_sys_fd_write(struct thread *td, struct uio *uio; int error; - error = cloudabi32_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); + error = cloudabi32_copyinuio(TO_PTR(uap->iovs), uap->iovs_len, &uio); if (error != 0) return (error); error = kern_writev(td, uap->fd, uio); diff --git a/sys/compat/cloudabi32/cloudabi32_poll.c b/sys/compat/cloudabi32/cloudabi32_poll.c index 5215580..dfffdc6 100644 --- a/sys/compat/cloudabi32/cloudabi32_poll.c +++ b/sys/compat/cloudabi32/cloudabi32_poll.c @@ -398,11 +398,11 @@ cloudabi32_sys_poll_fd(struct thread *td, return (EINVAL); timeout.tv_sec = subtimo.clock.timeout / 1000000000; timeout.tv_nsec = subtimo.clock.timeout % 1000000000; - return (kern_kevent(td, uap->fd, uap->nin, uap->nout, ©ops, - &timeout)); + return (kern_kevent(td, uap->fd, uap->in_len, uap->out_len, + ©ops, &timeout)); } else { /* Poll without a timeout. */ - return (kern_kevent(td, uap->fd, uap->nin, uap->nout, ©ops, - NULL)); + return (kern_kevent(td, uap->fd, uap->in_len, uap->out_len, + ©ops, NULL)); } } diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h index 3f028d5..ca03f67 100644 --- a/sys/compat/cloudabi32/cloudabi32_proto.h +++ b/sys/compat/cloudabi32/cloudabi32_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 312353 2017-01-17 22:03:08Z ed */ #ifndef _CLOUDABI32_SYSPROTO_H_ @@ -63,20 +63,20 @@ struct cloudabi_sys_fd_dup_args { }; struct cloudabi32_sys_fd_pread_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char 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 iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char 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 iov_l_[PADL_(const cloudabi32_iovec_t *)]; const cloudabi32_iovec_t * iov; char iov_r_[PADR_(const cloudabi32_iovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + char 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)]; @@ -101,8 +101,8 @@ struct cloudabi_sys_fd_sync_args { }; struct cloudabi32_sys_fd_write_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; - char iov_l_[PADL_(const cloudabi32_ciovec_t *)]; const cloudabi32_ciovec_t * iov; char iov_r_[PADR_(const cloudabi32_ciovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_t)]; + 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)]; @@ -118,44 +118,44 @@ struct cloudabi_sys_file_allocate_args { struct cloudabi_sys_file_create_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char 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 path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + 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 path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; + 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 bufsize_l_[PADL_(size_t)]; size_t bufsize; char bufsize_r_[PADR_(size_t)]; + 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 oldfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t oldfd; char oldfd_r_[PADR_(cloudabi_fd_t)]; - char old_l_[PADL_(const char *)]; const char * old; char old_r_[PADR_(const char *)]; - char oldlen_l_[PADL_(size_t)]; size_t oldlen; char oldlen_r_[PADR_(size_t)]; - char newfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t newfd; char newfd_r_[PADR_(cloudabi_fd_t)]; - char new_l_[PADL_(const char *)]; const char * new; char new_r_[PADR_(const char *)]; - char newlen_l_[PADL_(size_t)]; size_t newlen; char newlen_r_[PADR_(size_t)]; + 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)]; @@ -169,27 +169,27 @@ struct cloudabi_sys_file_stat_fput_args { struct cloudabi_sys_file_stat_get_args { char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + 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 path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; + 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 { @@ -197,13 +197,13 @@ struct cloudabi_sys_lock_unlock_args { char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; }; struct cloudabi_sys_mem_advise_args { - char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char 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_lock_args { - char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char mapping_l_[PADL_(const void *)]; const void * mapping; char mapping_r_[PADR_(const void *)]; + char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_mem_map_args { char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; @@ -214,22 +214,22 @@ struct cloudabi_sys_mem_map_args { char off_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t off; char off_r_[PADR_(cloudabi_filesize_t)]; }; struct cloudabi_sys_mem_protect_args { - char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char 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 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 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_unlock_args { - char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char mapping_l_[PADL_(const void *)]; const void * mapping; char mapping_r_[PADR_(const void *)]; + char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_mem_unmap_args { - char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + 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 *)]; @@ -239,17 +239,17 @@ struct cloudabi32_sys_poll_args { struct cloudabi32_sys_poll_fd_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)]; - char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)]; + char in_len_l_[PADL_(size_t)]; size_t in_len; char in_len_r_[PADR_(size_t)]; char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)]; - char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)]; + char out_len_l_[PADL_(size_t)]; size_t out_len; char out_len_r_[PADR_(size_t)]; char timeout_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi32_subscription_t *)]; }; struct cloudabi_sys_proc_exec_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)]; - char datalen_l_[PADL_(size_t)]; size_t datalen; char datalen_r_[PADR_(size_t)]; + char 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 fdslen_l_[PADL_(size_t)]; size_t fdslen; char fdslen_r_[PADR_(size_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)]; @@ -262,7 +262,7 @@ struct cloudabi_sys_proc_raise_args { }; struct cloudabi_sys_random_get_args { char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; - char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + char buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_sock_accept_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; @@ -272,13 +272,13 @@ struct cloudabi_sys_sock_bind_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_sock_connect_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_sock_listen_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; diff --git a/sys/compat/cloudabi32/cloudabi32_sock.c b/sys/compat/cloudabi32/cloudabi32_sock.c index 24ed32c..1b01fc6 100644 --- a/sys/compat/cloudabi32/cloudabi32_sock.c +++ b/sys/compat/cloudabi32/cloudabi32_sock.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * 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 @@ -29,9 +29,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> #include <sys/malloc.h> -#include <sys/proc.h> -#include <sys/socket.h> -#include <sys/syscallsubr.h> #include <sys/systm.h> #include <sys/uio.h> @@ -48,53 +45,43 @@ int cloudabi32_sys_sock_recv(struct thread *td, struct cloudabi32_sys_sock_recv_args *uap) { - struct sockaddr_storage ss; cloudabi32_recv_in_t ri; cloudabi32_recv_out_t ro = {}; cloudabi32_iovec_t iovobj; - struct msghdr msghdr = {}; + struct iovec *iov; const cloudabi32_iovec_t *user_iov; - size_t i; + size_t i, rdatalen, rfdslen; int error; error = copyin(uap->in, &ri, sizeof(ri)); if (error != 0) return (error); - /* Convert results in cloudabi_recv_in_t to struct msghdr. */ - if (ri.ri_datalen > UIO_MAXIOV) + /* Convert iovecs to native format. */ + if (ri.ri_data_len > UIO_MAXIOV) return (EINVAL); - msghdr.msg_iovlen = ri.ri_datalen; - msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), + iov = malloc(ri.ri_data_len * sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(ri.ri_data); - for (i = 0; i < msghdr.msg_iovlen; i++) { + for (i = 0; i < ri.ri_data_len; i++) { error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { - free(msghdr.msg_iov, M_SOCKET); + free(iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); - msghdr.msg_iov[i].iov_len = iovobj.iov_len; + iov[i].iov_base = TO_PTR(iovobj.buf); + iov[i].iov_len = iovobj.buf_len; } - msghdr.msg_name = &ss; - msghdr.msg_namelen = sizeof(ss); - if (ri.ri_flags & CLOUDABI_MSG_PEEK) - msghdr.msg_flags |= MSG_PEEK; - if (ri.ri_flags & CLOUDABI_MSG_WAITALL) - msghdr.msg_flags |= MSG_WAITALL; - - /* TODO(ed): Add file descriptor passing. */ - error = kern_recvit(td, uap->sock, &msghdr, UIO_SYSSPACE, NULL); - free(msghdr.msg_iov, M_SOCKET); + + 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_peername, &ro.ro_flags); + free(iov, M_SOCKET); if (error != 0) return (error); - /* Convert results in msghdr to cloudabi_recv_out_t. */ - ro.ro_datalen = td->td_retval[0]; - cloudabi_convert_sockaddr((struct sockaddr *)&ss, - MIN(msghdr.msg_namelen, sizeof(ss)), &ro.ro_peername); - td->td_retval[0] = 0; + ro.ro_datalen = rdatalen; + ro.ro_fdslen = rfdslen; return (copyout(&ro, uap->out, sizeof(ro))); } @@ -105,44 +92,37 @@ cloudabi32_sys_sock_send(struct thread *td, cloudabi32_send_in_t si; cloudabi32_send_out_t so = {}; cloudabi32_ciovec_t iovobj; - struct msghdr msghdr = {}; + struct iovec *iov; const cloudabi32_ciovec_t *user_iov; - size_t i; - int error, flags; + size_t datalen, i; + int error; error = copyin(uap->in, &si, sizeof(si)); if (error != 0) return (error); - /* Convert results in cloudabi_send_in_t to struct msghdr. */ - if (si.si_datalen > UIO_MAXIOV) + /* Convert iovecs to native format. */ + if (si.si_data_len > UIO_MAXIOV) return (EINVAL); - msghdr.msg_iovlen = si.si_datalen; - msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), + iov = malloc(si.si_data_len * sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(si.si_data); - for (i = 0; i < msghdr.msg_iovlen; i++) { + for (i = 0; i < si.si_data_len; i++) { error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { - free(msghdr.msg_iov, M_SOCKET); + free(iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); - msghdr.msg_iov[i].iov_len = iovobj.iov_len; + iov[i].iov_base = TO_PTR(iovobj.buf); + iov[i].iov_len = iovobj.buf_len; } - flags = MSG_NOSIGNAL; - if (si.si_flags & CLOUDABI_MSG_EOR) - flags |= MSG_EOR; - - /* TODO(ed): Add file descriptor passing. */ - error = kern_sendit(td, uap->sock, &msghdr, flags, NULL, UIO_USERSPACE); - free(msghdr.msg_iov, M_SOCKET); + error = cloudabi_sock_send(td, uap->sock, iov, si.si_data_len, + TO_PTR(si.si_fds), si.si_fds_len, si.si_flags, &datalen); + free(iov, M_SOCKET); if (error != 0) return (error); - /* Convert results in msghdr to cloudabi_send_out_t. */ - so.so_datalen = td->td_retval[0]; - td->td_retval[0] = 0; + 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 index 4cba6fd..3ec07f1 100644 --- a/sys/compat/cloudabi32/cloudabi32_syscall.h +++ b/sys/compat/cloudabi32/cloudabi32_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 312353 2017-01-17 22:03:08Z ed */ #define CLOUDABI32_SYS_cloudabi_sys_clock_res_get 0 diff --git a/sys/compat/cloudabi32/cloudabi32_syscalls.c b/sys/compat/cloudabi32/cloudabi32_syscalls.c index 56a46fb..c24ad81 100644 --- a/sys/compat/cloudabi32/cloudabi32_syscalls.c +++ b/sys/compat/cloudabi32/cloudabi32_syscalls.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 312353 2017-01-17 22:03:08Z ed */ const char *cloudabi32_syscallnames[] = { diff --git a/sys/compat/cloudabi32/cloudabi32_sysent.c b/sys/compat/cloudabi32/cloudabi32_sysent.c index 187e384..e2a67ae 100644 --- a/sys/compat/cloudabi32/cloudabi32_sysent.c +++ b/sys/compat/cloudabi32/cloudabi32_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 304563 2016-08-21 15:56:19Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls32.master 312353 2017-01-17 22:03:08Z ed */ #include <sys/sysent.h> diff --git a/sys/compat/cloudabi32/cloudabi32_systrace_args.c b/sys/compat/cloudabi32/cloudabi32_systrace_args.c index 0ba5ec5..92b2490 100644 --- a/sys/compat/cloudabi32/cloudabi32_systrace_args.c +++ b/sys/compat/cloudabi32/cloudabi32_systrace_args.c @@ -74,8 +74,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 8: { struct cloudabi32_sys_fd_pread_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi32_iovec_t * */ - uarg[2] = p->iovcnt; /* size_t */ + 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; @@ -84,8 +84,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 9: { struct cloudabi32_sys_fd_pwrite_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi32_ciovec_t * */ - uarg[2] = p->iovcnt; /* size_t */ + 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; @@ -94,8 +94,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 10: { struct cloudabi32_sys_fd_read_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi32_iovec_t * */ - uarg[2] = p->iovcnt; /* size_t */ + uarg[1] = (intptr_t) p->iovs; /* const cloudabi32_iovec_t * */ + uarg[2] = p->iovs_len; /* size_t */ *n_args = 3; break; } @@ -144,8 +144,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 16: { struct cloudabi32_sys_fd_write_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi32_ciovec_t * */ - uarg[2] = p->iovcnt; /* size_t */ + uarg[1] = (intptr_t) p->iovs; /* const cloudabi32_ciovec_t * */ + uarg[2] = p->iovs_len; /* size_t */ *n_args = 3; break; } @@ -173,7 +173,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_create_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ iarg[3] = p->type; /* cloudabi_filetype_t */ *n_args = 4; break; @@ -183,10 +183,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_link_args *p = params; iarg[0] = p->fd1; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path1; /* const char * */ - uarg[2] = p->path1len; /* size_t */ + 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->path2len; /* size_t */ + uarg[5] = p->path2_len; /* size_t */ *n_args = 6; break; } @@ -195,7 +195,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_open_args *p = params; iarg[0] = p->dirfd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + 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; @@ -206,7 +206,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_readdir_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* void * */ - uarg[2] = p->nbyte; /* size_t */ + uarg[2] = p->buf_len; /* size_t */ iarg[3] = p->cookie; /* cloudabi_dircookie_t */ *n_args = 4; break; @@ -216,21 +216,21 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_readlink_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ uarg[3] = (intptr_t) p->buf; /* char * */ - uarg[4] = p->bufsize; /* size_t */ + 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->oldfd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->old; /* const char * */ - uarg[2] = p->oldlen; /* size_t */ - iarg[3] = p->newfd; /* cloudabi_fd_t */ - uarg[4] = (intptr_t) p->new; /* const char * */ - uarg[5] = p->newlen; /* size_t */ + 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; } @@ -256,7 +256,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_stat_get_args *p = params; iarg[0] = p->fd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ uarg[3] = (intptr_t) p->buf; /* cloudabi_filestat_t * */ *n_args = 4; break; @@ -266,7 +266,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_stat_put_args *p = params; iarg[0] = p->fd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[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; @@ -276,10 +276,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 29: { struct cloudabi_sys_file_symlink_args *p = params; uarg[0] = (intptr_t) p->path1; /* const char * */ - uarg[1] = p->path1len; /* size_t */ + 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->path2len; /* size_t */ + uarg[4] = p->path2_len; /* size_t */ *n_args = 5; break; } @@ -288,7 +288,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_unlink_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ iarg[3] = p->flags; /* cloudabi_ulflags_t */ *n_args = 4; break; @@ -304,8 +304,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_advise */ case 32: { struct cloudabi_sys_mem_advise_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + 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; @@ -313,8 +313,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_lock */ case 33: { struct cloudabi_sys_mem_lock_args *p = params; - uarg[0] = (intptr_t) p->addr; /* const void * */ - uarg[1] = p->len; /* size_t */ + uarg[0] = (intptr_t) p->mapping; /* const void * */ + uarg[1] = p->mapping_len; /* size_t */ *n_args = 2; break; } @@ -333,8 +333,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_protect */ case 35: { struct cloudabi_sys_mem_protect_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + 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; @@ -342,8 +342,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_sync */ case 36: { struct cloudabi_sys_mem_sync_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + 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; @@ -351,16 +351,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_unlock */ case 37: { struct cloudabi_sys_mem_unlock_args *p = params; - uarg[0] = (intptr_t) p->addr; /* const void * */ - uarg[1] = p->len; /* size_t */ + uarg[0] = (intptr_t) p->mapping; /* const void * */ + uarg[1] = p->mapping_len; /* size_t */ *n_args = 2; break; } /* cloudabi_sys_mem_unmap */ case 38: { struct cloudabi_sys_mem_unmap_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + uarg[0] = (intptr_t) p->mapping; /* void * */ + uarg[1] = p->mapping_len; /* size_t */ *n_args = 2; break; } @@ -378,9 +378,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi32_sys_poll_fd_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */ - uarg[2] = p->nin; /* size_t */ + uarg[2] = p->in_len; /* size_t */ uarg[3] = (intptr_t) p->out; /* cloudabi32_event_t * */ - uarg[4] = p->nout; /* size_t */ + uarg[4] = p->out_len; /* size_t */ uarg[5] = (intptr_t) p->timeout; /* const cloudabi32_subscription_t * */ *n_args = 6; break; @@ -390,9 +390,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_proc_exec_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->data; /* const void * */ - uarg[2] = p->datalen; /* size_t */ + uarg[2] = p->data_len; /* size_t */ uarg[3] = (intptr_t) p->fds; /* const cloudabi_fd_t * */ - uarg[4] = p->fdslen; /* size_t */ + uarg[4] = p->fds_len; /* size_t */ *n_args = 5; break; } @@ -419,7 +419,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 45: { struct cloudabi_sys_random_get_args *p = params; uarg[0] = (intptr_t) p->buf; /* void * */ - uarg[1] = p->nbyte; /* size_t */ + uarg[1] = p->buf_len; /* size_t */ *n_args = 2; break; } @@ -437,7 +437,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ uarg[2] = (intptr_t) p->path; /* const char * */ - uarg[3] = p->pathlen; /* size_t */ + uarg[3] = p->path_len; /* size_t */ *n_args = 4; break; } @@ -447,7 +447,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ uarg[2] = (intptr_t) p->path; /* const char * */ - uarg[3] = p->pathlen; /* size_t */ + uarg[3] = p->path_len; /* size_t */ *n_args = 4; break; } diff --git a/sys/compat/cloudabi32/cloudabi32_thread.c b/sys/compat/cloudabi32/cloudabi32_thread.c index 50538d9..233700b 100644 --- a/sys/compat/cloudabi32/cloudabi32_thread.c +++ b/sys/compat/cloudabi32/cloudabi32_thread.c @@ -65,9 +65,9 @@ cloudabi32_sys_thread_create(struct thread *td, return (error); /* Remove some space on the top of the stack for the TCB. */ - args.tcb = rounddown(args.attr.stack + args.attr.stack_size - + args.tcb = rounddown(args.attr.stack + args.attr.stack_len - sizeof(cloudabi32_tcb_t), _Alignof(cloudabi32_tcb_t)); - args.attr.stack_size = args.tcb - args.attr.stack; + args.attr.stack_len = args.tcb - args.attr.stack; error = thread_create(td, NULL, initialize_thread, &args); if (error != 0) diff --git a/sys/compat/cloudabi64/cloudabi64_fd.c b/sys/compat/cloudabi64/cloudabi64_fd.c index fcfcc42..ea403cf 100644 --- a/sys/compat/cloudabi64/cloudabi64_fd.c +++ b/sys/compat/cloudabi64/cloudabi64_fd.c @@ -71,8 +71,8 @@ cloudabi64_copyinuio(const cloudabi64_iovec_t *iovp, size_t iovcnt, free(uio, M_IOV); return (error); } - iov[i].iov_base = TO_PTR(iovobj.iov_base); - iov[i].iov_len = iovobj.iov_len; + 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); @@ -91,7 +91,7 @@ cloudabi64_sys_fd_pread(struct thread *td, struct uio *uio; int error; - error = cloudabi64_copyinuio(uap->iov, uap->iovcnt, &uio); + error = cloudabi64_copyinuio(uap->iovs, uap->iovs_len, &uio); if (error != 0) return (error); error = kern_preadv(td, uap->fd, uio, uap->offset); @@ -106,7 +106,7 @@ cloudabi64_sys_fd_pwrite(struct thread *td, struct uio *uio; int error; - error = cloudabi64_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); + 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); @@ -121,7 +121,7 @@ cloudabi64_sys_fd_read(struct thread *td, struct uio *uio; int error; - error = cloudabi64_copyinuio(uap->iov, uap->iovcnt, &uio); + error = cloudabi64_copyinuio(uap->iovs, uap->iovs_len, &uio); if (error != 0) return (error); error = kern_readv(td, uap->fd, uio); @@ -136,7 +136,7 @@ cloudabi64_sys_fd_write(struct thread *td, struct uio *uio; int error; - error = cloudabi64_copyinuio(TO_PTR(uap->iov), uap->iovcnt, &uio); + error = cloudabi64_copyinuio(TO_PTR(uap->iovs), uap->iovs_len, &uio); if (error != 0) return (error); error = kern_writev(td, uap->fd, uio); diff --git a/sys/compat/cloudabi64/cloudabi64_poll.c b/sys/compat/cloudabi64/cloudabi64_poll.c index 63d8120..3df5265 100644 --- a/sys/compat/cloudabi64/cloudabi64_poll.c +++ b/sys/compat/cloudabi64/cloudabi64_poll.c @@ -398,11 +398,11 @@ cloudabi64_sys_poll_fd(struct thread *td, return (EINVAL); timeout.tv_sec = subtimo.clock.timeout / 1000000000; timeout.tv_nsec = subtimo.clock.timeout % 1000000000; - return (kern_kevent(td, uap->fd, uap->nin, uap->nout, ©ops, - &timeout)); + return (kern_kevent(td, uap->fd, uap->in_len, uap->out_len, + ©ops, &timeout)); } else { /* Poll without a timeout. */ - return (kern_kevent(td, uap->fd, uap->nin, uap->nout, ©ops, - NULL)); + return (kern_kevent(td, uap->fd, uap->in_len, uap->out_len, + ©ops, NULL)); } } diff --git a/sys/compat/cloudabi64/cloudabi64_proto.h b/sys/compat/cloudabi64/cloudabi64_proto.h index aed44ad..40c3a53 100644 --- a/sys/compat/cloudabi64/cloudabi64_proto.h +++ b/sys/compat/cloudabi64/cloudabi64_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 312353 2017-01-17 22:03:08Z ed */ #ifndef _CLOUDABI64_SYSPROTO_H_ @@ -63,20 +63,20 @@ struct cloudabi_sys_fd_dup_args { }; 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 iov_l_[PADL_(const cloudabi64_iovec_t *)]; const cloudabi64_iovec_t * iov; char iov_r_[PADR_(const cloudabi64_iovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_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 iov_l_[PADL_(const cloudabi64_ciovec_t *)]; const cloudabi64_ciovec_t * iov; char iov_r_[PADR_(const cloudabi64_ciovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_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 iov_l_[PADL_(const cloudabi64_iovec_t *)]; const cloudabi64_iovec_t * iov; char iov_r_[PADR_(const cloudabi64_iovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_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)]; @@ -101,8 +101,8 @@ struct cloudabi_sys_fd_sync_args { }; 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 iov_l_[PADL_(const cloudabi64_ciovec_t *)]; const cloudabi64_ciovec_t * iov; char iov_r_[PADR_(const cloudabi64_ciovec_t *)]; - char iovcnt_l_[PADL_(size_t)]; size_t iovcnt; char iovcnt_r_[PADR_(size_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)]; @@ -118,44 +118,44 @@ struct cloudabi_sys_file_allocate_args { struct cloudabi_sys_file_create_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char 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 path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + 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 path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; + 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 bufsize_l_[PADL_(size_t)]; size_t bufsize; char bufsize_r_[PADR_(size_t)]; + 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 oldfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t oldfd; char oldfd_r_[PADR_(cloudabi_fd_t)]; - char old_l_[PADL_(const char *)]; const char * old; char old_r_[PADR_(const char *)]; - char oldlen_l_[PADL_(size_t)]; size_t oldlen; char oldlen_r_[PADR_(size_t)]; - char newfd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t newfd; char newfd_r_[PADR_(cloudabi_fd_t)]; - char new_l_[PADL_(const char *)]; const char * new; char new_r_[PADR_(const char *)]; - char newlen_l_[PADL_(size_t)]; size_t newlen; char newlen_r_[PADR_(size_t)]; + 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)]; @@ -169,27 +169,27 @@ struct cloudabi_sys_file_stat_fput_args { struct cloudabi_sys_file_stat_get_args { char fd_l_[PADL_(cloudabi_lookup_t)]; cloudabi_lookup_t fd; char fd_r_[PADR_(cloudabi_lookup_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 path1len_l_[PADL_(size_t)]; size_t path1len; char path1len_r_[PADR_(size_t)]; + 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 path2len_l_[PADL_(size_t)]; size_t path2len; char path2len_r_[PADR_(size_t)]; + 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 pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + 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 { @@ -197,13 +197,13 @@ struct cloudabi_sys_lock_unlock_args { char scope_l_[PADL_(cloudabi_scope_t)]; cloudabi_scope_t scope; char scope_r_[PADR_(cloudabi_scope_t)]; }; struct cloudabi_sys_mem_advise_args { - char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char 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_lock_args { - char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char mapping_l_[PADL_(const void *)]; const void * mapping; char mapping_r_[PADR_(const void *)]; + char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_mem_map_args { char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; @@ -214,22 +214,22 @@ struct cloudabi_sys_mem_map_args { char off_l_[PADL_(cloudabi_filesize_t)]; cloudabi_filesize_t off; char off_r_[PADR_(cloudabi_filesize_t)]; }; struct cloudabi_sys_mem_protect_args { - char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char 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 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 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_unlock_args { - char addr_l_[PADL_(const void *)]; const void * addr; char addr_r_[PADR_(const void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + char mapping_l_[PADL_(const void *)]; const void * mapping; char mapping_r_[PADR_(const void *)]; + char mapping_len_l_[PADL_(size_t)]; size_t mapping_len; char mapping_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_mem_unmap_args { - char addr_l_[PADL_(void *)]; void * addr; char addr_r_[PADR_(void *)]; - char len_l_[PADL_(size_t)]; size_t len; char len_r_[PADR_(size_t)]; + 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 *)]; @@ -239,17 +239,17 @@ struct cloudabi64_sys_poll_args { struct cloudabi64_sys_poll_fd_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)]; - char nin_l_[PADL_(size_t)]; size_t nin; char nin_r_[PADR_(size_t)]; + char in_len_l_[PADL_(size_t)]; size_t in_len; char in_len_r_[PADR_(size_t)]; char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)]; - char nout_l_[PADL_(size_t)]; size_t nout; char nout_r_[PADR_(size_t)]; + char out_len_l_[PADL_(size_t)]; size_t out_len; char out_len_r_[PADR_(size_t)]; char timeout_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * timeout; char timeout_r_[PADR_(const cloudabi64_subscription_t *)]; }; struct cloudabi_sys_proc_exec_args { char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char data_l_[PADL_(const void *)]; const void * data; char data_r_[PADR_(const void *)]; - char datalen_l_[PADL_(size_t)]; size_t datalen; char datalen_r_[PADR_(size_t)]; + 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 fdslen_l_[PADL_(size_t)]; size_t fdslen; char fdslen_r_[PADR_(size_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)]; @@ -262,7 +262,7 @@ struct cloudabi_sys_proc_raise_args { }; struct cloudabi_sys_random_get_args { char buf_l_[PADL_(void *)]; void * buf; char buf_r_[PADR_(void *)]; - char nbyte_l_[PADL_(size_t)]; size_t nbyte; char nbyte_r_[PADR_(size_t)]; + char buf_len_l_[PADL_(size_t)]; size_t buf_len; char buf_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_sock_accept_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; @@ -272,13 +272,13 @@ struct cloudabi_sys_sock_bind_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_sock_connect_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; char fd_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t fd; char fd_r_[PADR_(cloudabi_fd_t)]; char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)]; - char pathlen_l_[PADL_(size_t)]; size_t pathlen; char pathlen_r_[PADR_(size_t)]; + char path_len_l_[PADL_(size_t)]; size_t path_len; char path_len_r_[PADR_(size_t)]; }; struct cloudabi_sys_sock_listen_args { char sock_l_[PADL_(cloudabi_fd_t)]; cloudabi_fd_t sock; char sock_r_[PADR_(cloudabi_fd_t)]; diff --git a/sys/compat/cloudabi64/cloudabi64_sock.c b/sys/compat/cloudabi64/cloudabi64_sock.c index 3915ddf..22ec664 100644 --- a/sys/compat/cloudabi64/cloudabi64_sock.c +++ b/sys/compat/cloudabi64/cloudabi64_sock.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015 Nuxi, https://nuxi.nl/ + * 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 @@ -29,9 +29,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/kernel.h> #include <sys/malloc.h> -#include <sys/proc.h> -#include <sys/socket.h> -#include <sys/syscallsubr.h> #include <sys/systm.h> #include <sys/uio.h> @@ -48,53 +45,43 @@ int cloudabi64_sys_sock_recv(struct thread *td, struct cloudabi64_sys_sock_recv_args *uap) { - struct sockaddr_storage ss; cloudabi64_recv_in_t ri; cloudabi64_recv_out_t ro = {}; cloudabi64_iovec_t iovobj; - struct msghdr msghdr = {}; + struct iovec *iov; const cloudabi64_iovec_t *user_iov; - size_t i; + size_t i, rdatalen, rfdslen; int error; error = copyin(uap->in, &ri, sizeof(ri)); if (error != 0) return (error); - /* Convert results in cloudabi_recv_in_t to struct msghdr. */ - if (ri.ri_datalen > UIO_MAXIOV) + /* Convert iovecs to native format. */ + if (ri.ri_data_len > UIO_MAXIOV) return (EINVAL); - msghdr.msg_iovlen = ri.ri_datalen; - msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), + iov = malloc(ri.ri_data_len * sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(ri.ri_data); - for (i = 0; i < msghdr.msg_iovlen; i++) { + for (i = 0; i < ri.ri_data_len; i++) { error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { - free(msghdr.msg_iov, M_SOCKET); + free(iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); - msghdr.msg_iov[i].iov_len = iovobj.iov_len; + iov[i].iov_base = TO_PTR(iovobj.buf); + iov[i].iov_len = iovobj.buf_len; } - msghdr.msg_name = &ss; - msghdr.msg_namelen = sizeof(ss); - if (ri.ri_flags & CLOUDABI_MSG_PEEK) - msghdr.msg_flags |= MSG_PEEK; - if (ri.ri_flags & CLOUDABI_MSG_WAITALL) - msghdr.msg_flags |= MSG_WAITALL; - - /* TODO(ed): Add file descriptor passing. */ - error = kern_recvit(td, uap->sock, &msghdr, UIO_SYSSPACE, NULL); - free(msghdr.msg_iov, M_SOCKET); + + 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_peername, &ro.ro_flags); + free(iov, M_SOCKET); if (error != 0) return (error); - /* Convert results in msghdr to cloudabi_recv_out_t. */ - ro.ro_datalen = td->td_retval[0]; - cloudabi_convert_sockaddr((struct sockaddr *)&ss, - MIN(msghdr.msg_namelen, sizeof(ss)), &ro.ro_peername); - td->td_retval[0] = 0; + ro.ro_datalen = rdatalen; + ro.ro_fdslen = rfdslen; return (copyout(&ro, uap->out, sizeof(ro))); } @@ -105,44 +92,37 @@ cloudabi64_sys_sock_send(struct thread *td, cloudabi64_send_in_t si; cloudabi64_send_out_t so = {}; cloudabi64_ciovec_t iovobj; - struct msghdr msghdr = {}; + struct iovec *iov; const cloudabi64_ciovec_t *user_iov; - size_t i; - int error, flags; + size_t datalen, i; + int error; error = copyin(uap->in, &si, sizeof(si)); if (error != 0) return (error); - /* Convert results in cloudabi_send_in_t to struct msghdr. */ - if (si.si_datalen > UIO_MAXIOV) + /* Convert iovecs to native format. */ + if (si.si_data_len > UIO_MAXIOV) return (EINVAL); - msghdr.msg_iovlen = si.si_datalen; - msghdr.msg_iov = malloc(msghdr.msg_iovlen * sizeof(struct iovec), + iov = malloc(si.si_data_len * sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(si.si_data); - for (i = 0; i < msghdr.msg_iovlen; i++) { + for (i = 0; i < si.si_data_len; i++) { error = copyin(&user_iov[i], &iovobj, sizeof(iovobj)); if (error != 0) { - free(msghdr.msg_iov, M_SOCKET); + free(iov, M_SOCKET); return (error); } - msghdr.msg_iov[i].iov_base = TO_PTR(iovobj.iov_base); - msghdr.msg_iov[i].iov_len = iovobj.iov_len; + iov[i].iov_base = TO_PTR(iovobj.buf); + iov[i].iov_len = iovobj.buf_len; } - flags = MSG_NOSIGNAL; - if (si.si_flags & CLOUDABI_MSG_EOR) - flags |= MSG_EOR; - - /* TODO(ed): Add file descriptor passing. */ - error = kern_sendit(td, uap->sock, &msghdr, flags, NULL, UIO_USERSPACE); - free(msghdr.msg_iov, M_SOCKET); + error = cloudabi_sock_send(td, uap->sock, iov, si.si_data_len, + TO_PTR(si.si_fds), si.si_fds_len, si.si_flags, &datalen); + free(iov, M_SOCKET); if (error != 0) return (error); - /* Convert results in msghdr to cloudabi_send_out_t. */ - so.so_datalen = td->td_retval[0]; - td->td_retval[0] = 0; + 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 index 7d99d5e..50089dd 100644 --- a/sys/compat/cloudabi64/cloudabi64_syscall.h +++ b/sys/compat/cloudabi64/cloudabi64_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 312353 2017-01-17 22:03:08Z ed */ #define CLOUDABI64_SYS_cloudabi_sys_clock_res_get 0 diff --git a/sys/compat/cloudabi64/cloudabi64_syscalls.c b/sys/compat/cloudabi64/cloudabi64_syscalls.c index d430056..5388299 100644 --- a/sys/compat/cloudabi64/cloudabi64_syscalls.c +++ b/sys/compat/cloudabi64/cloudabi64_syscalls.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 312353 2017-01-17 22:03:08Z ed */ const char *cloudabi64_syscallnames[] = { diff --git a/sys/compat/cloudabi64/cloudabi64_sysent.c b/sys/compat/cloudabi64/cloudabi64_sysent.c index 3b11850..d922a06 100644 --- a/sys/compat/cloudabi64/cloudabi64_sysent.c +++ b/sys/compat/cloudabi64/cloudabi64_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 304483 2016-08-19 17:53:37Z ed + * created from FreeBSD: head/sys/contrib/cloudabi/syscalls64.master 312353 2017-01-17 22:03:08Z ed */ #include <sys/sysent.h> diff --git a/sys/compat/cloudabi64/cloudabi64_systrace_args.c b/sys/compat/cloudabi64/cloudabi64_systrace_args.c index 3e97b25..24190c5 100644 --- a/sys/compat/cloudabi64/cloudabi64_systrace_args.c +++ b/sys/compat/cloudabi64/cloudabi64_systrace_args.c @@ -74,8 +74,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 8: { struct cloudabi64_sys_fd_pread_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi64_iovec_t * */ - uarg[2] = p->iovcnt; /* size_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; @@ -84,8 +84,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 9: { struct cloudabi64_sys_fd_pwrite_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi64_ciovec_t * */ - uarg[2] = p->iovcnt; /* size_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; @@ -94,8 +94,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 10: { struct cloudabi64_sys_fd_read_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi64_iovec_t * */ - uarg[2] = p->iovcnt; /* size_t */ + uarg[1] = (intptr_t) p->iovs; /* const cloudabi64_iovec_t * */ + uarg[2] = p->iovs_len; /* size_t */ *n_args = 3; break; } @@ -144,8 +144,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 16: { struct cloudabi64_sys_fd_write_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->iov; /* const cloudabi64_ciovec_t * */ - uarg[2] = p->iovcnt; /* size_t */ + uarg[1] = (intptr_t) p->iovs; /* const cloudabi64_ciovec_t * */ + uarg[2] = p->iovs_len; /* size_t */ *n_args = 3; break; } @@ -173,7 +173,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_create_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ iarg[3] = p->type; /* cloudabi_filetype_t */ *n_args = 4; break; @@ -183,10 +183,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_link_args *p = params; iarg[0] = p->fd1; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path1; /* const char * */ - uarg[2] = p->path1len; /* size_t */ + 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->path2len; /* size_t */ + uarg[5] = p->path2_len; /* size_t */ *n_args = 6; break; } @@ -195,7 +195,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_open_args *p = params; iarg[0] = p->dirfd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + 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; @@ -206,7 +206,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_readdir_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* void * */ - uarg[2] = p->nbyte; /* size_t */ + uarg[2] = p->buf_len; /* size_t */ iarg[3] = p->cookie; /* cloudabi_dircookie_t */ *n_args = 4; break; @@ -216,21 +216,21 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_readlink_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ uarg[3] = (intptr_t) p->buf; /* char * */ - uarg[4] = p->bufsize; /* size_t */ + 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->oldfd; /* cloudabi_fd_t */ - uarg[1] = (intptr_t) p->old; /* const char * */ - uarg[2] = p->oldlen; /* size_t */ - iarg[3] = p->newfd; /* cloudabi_fd_t */ - uarg[4] = (intptr_t) p->new; /* const char * */ - uarg[5] = p->newlen; /* size_t */ + 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; } @@ -256,7 +256,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_stat_get_args *p = params; iarg[0] = p->fd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ uarg[3] = (intptr_t) p->buf; /* cloudabi_filestat_t * */ *n_args = 4; break; @@ -266,7 +266,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_stat_put_args *p = params; iarg[0] = p->fd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[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; @@ -276,10 +276,10 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 29: { struct cloudabi_sys_file_symlink_args *p = params; uarg[0] = (intptr_t) p->path1; /* const char * */ - uarg[1] = p->path1len; /* size_t */ + 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->path2len; /* size_t */ + uarg[4] = p->path2_len; /* size_t */ *n_args = 5; break; } @@ -288,7 +288,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_file_unlink_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ - uarg[2] = p->pathlen; /* size_t */ + uarg[2] = p->path_len; /* size_t */ iarg[3] = p->flags; /* cloudabi_ulflags_t */ *n_args = 4; break; @@ -304,8 +304,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_advise */ case 32: { struct cloudabi_sys_mem_advise_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + 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; @@ -313,8 +313,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_lock */ case 33: { struct cloudabi_sys_mem_lock_args *p = params; - uarg[0] = (intptr_t) p->addr; /* const void * */ - uarg[1] = p->len; /* size_t */ + uarg[0] = (intptr_t) p->mapping; /* const void * */ + uarg[1] = p->mapping_len; /* size_t */ *n_args = 2; break; } @@ -333,8 +333,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_protect */ case 35: { struct cloudabi_sys_mem_protect_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + 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; @@ -342,8 +342,8 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_sync */ case 36: { struct cloudabi_sys_mem_sync_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + 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; @@ -351,16 +351,16 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) /* cloudabi_sys_mem_unlock */ case 37: { struct cloudabi_sys_mem_unlock_args *p = params; - uarg[0] = (intptr_t) p->addr; /* const void * */ - uarg[1] = p->len; /* size_t */ + uarg[0] = (intptr_t) p->mapping; /* const void * */ + uarg[1] = p->mapping_len; /* size_t */ *n_args = 2; break; } /* cloudabi_sys_mem_unmap */ case 38: { struct cloudabi_sys_mem_unmap_args *p = params; - uarg[0] = (intptr_t) p->addr; /* void * */ - uarg[1] = p->len; /* size_t */ + uarg[0] = (intptr_t) p->mapping; /* void * */ + uarg[1] = p->mapping_len; /* size_t */ *n_args = 2; break; } @@ -378,9 +378,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi64_sys_poll_fd_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */ - uarg[2] = p->nin; /* size_t */ + uarg[2] = p->in_len; /* size_t */ uarg[3] = (intptr_t) p->out; /* cloudabi64_event_t * */ - uarg[4] = p->nout; /* size_t */ + uarg[4] = p->out_len; /* size_t */ uarg[5] = (intptr_t) p->timeout; /* const cloudabi64_subscription_t * */ *n_args = 6; break; @@ -390,9 +390,9 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) struct cloudabi_sys_proc_exec_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->data; /* const void * */ - uarg[2] = p->datalen; /* size_t */ + uarg[2] = p->data_len; /* size_t */ uarg[3] = (intptr_t) p->fds; /* const cloudabi_fd_t * */ - uarg[4] = p->fdslen; /* size_t */ + uarg[4] = p->fds_len; /* size_t */ *n_args = 5; break; } @@ -419,7 +419,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) case 45: { struct cloudabi_sys_random_get_args *p = params; uarg[0] = (intptr_t) p->buf; /* void * */ - uarg[1] = p->nbyte; /* size_t */ + uarg[1] = p->buf_len; /* size_t */ *n_args = 2; break; } @@ -437,7 +437,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ uarg[2] = (intptr_t) p->path; /* const char * */ - uarg[3] = p->pathlen; /* size_t */ + uarg[3] = p->path_len; /* size_t */ *n_args = 4; break; } @@ -447,7 +447,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ uarg[2] = (intptr_t) p->path; /* const char * */ - uarg[3] = p->pathlen; /* size_t */ + uarg[3] = p->path_len; /* size_t */ *n_args = 4; break; } diff --git a/sys/compat/cloudabi64/cloudabi64_thread.c b/sys/compat/cloudabi64/cloudabi64_thread.c index 429ad33..4cb980b 100644 --- a/sys/compat/cloudabi64/cloudabi64_thread.c +++ b/sys/compat/cloudabi64/cloudabi64_thread.c @@ -65,9 +65,9 @@ cloudabi64_sys_thread_create(struct thread *td, return (error); /* Remove some space on the top of the stack for the TCB. */ - args.tcb = rounddown(args.attr.stack + args.attr.stack_size - + args.tcb = rounddown(args.attr.stack + args.attr.stack_len - sizeof(cloudabi64_tcb_t), _Alignof(cloudabi64_tcb_t)); - args.attr.stack_size = args.tcb - args.attr.stack; + args.attr.stack_len = args.tcb - args.attr.stack; error = thread_create(td, NULL, initialize_thread, &args); if (error != 0) diff --git a/sys/contrib/cloudabi/cloudabi32_types.h b/sys/contrib/cloudabi/cloudabi32_types.h index 71d6429..2986e89 100644 --- a/sys/contrib/cloudabi/cloudabi32_types.h +++ b/sys/contrib/cloudabi/cloudabi32_types.h @@ -44,11 +44,11 @@ _Static_assert(sizeof(cloudabi32_auxv_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_auxv_t) == 4, "Incorrect layout"); typedef struct { - _Alignas(4) uint32_t iov_base; - _Alignas(4) uint32_t iov_len; + _Alignas(4) uint32_t buf; + _Alignas(4) uint32_t buf_len; } cloudabi32_ciovec_t; -_Static_assert(offsetof(cloudabi32_ciovec_t, iov_base) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_ciovec_t, iov_len) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_ciovec_t, buf) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_ciovec_t, buf_len) == 4, "Incorrect layout"); _Static_assert(sizeof(cloudabi32_ciovec_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_ciovec_t) == 4, "Incorrect layout"); @@ -94,11 +94,11 @@ _Static_assert(sizeof(cloudabi32_event_t) == 32, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_event_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(4) uint32_t iov_base; - _Alignas(4) uint32_t iov_len; + _Alignas(4) uint32_t buf; + _Alignas(4) uint32_t buf_len; } cloudabi32_iovec_t; -_Static_assert(offsetof(cloudabi32_iovec_t, iov_base) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_iovec_t, iov_len) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_iovec_t, buf) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_iovec_t, buf_len) == 4, "Incorrect layout"); _Static_assert(sizeof(cloudabi32_iovec_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_iovec_t) == 4, "Incorrect layout"); @@ -106,30 +106,30 @@ typedef void cloudabi32_processentry_t(uint32_t auxv); typedef struct { _Alignas(4) uint32_t ri_data; - _Alignas(4) uint32_t ri_datalen; + _Alignas(4) uint32_t ri_data_len; _Alignas(4) uint32_t ri_fds; - _Alignas(4) uint32_t ri_fdslen; + _Alignas(4) uint32_t ri_fds_len; _Alignas(2) cloudabi_msgflags_t ri_flags; } cloudabi32_recv_in_t; _Static_assert(offsetof(cloudabi32_recv_in_t, ri_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_datalen) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_data_len) == 4, "Incorrect layout"); _Static_assert(offsetof(cloudabi32_recv_in_t, ri_fds) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_recv_in_t, ri_fdslen) == 12, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_recv_in_t, ri_fds_len) == 12, "Incorrect layout"); _Static_assert(offsetof(cloudabi32_recv_in_t, ri_flags) == 16, "Incorrect layout"); _Static_assert(sizeof(cloudabi32_recv_in_t) == 20, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_recv_in_t) == 4, "Incorrect layout"); typedef struct { _Alignas(4) uint32_t si_data; - _Alignas(4) uint32_t si_datalen; + _Alignas(4) uint32_t si_data_len; _Alignas(4) uint32_t si_fds; - _Alignas(4) uint32_t si_fdslen; + _Alignas(4) uint32_t si_fds_len; _Alignas(2) cloudabi_msgflags_t si_flags; } cloudabi32_send_in_t; _Static_assert(offsetof(cloudabi32_send_in_t, si_data) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_send_in_t, si_datalen) == 4, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_send_in_t, si_data_len) == 4, "Incorrect layout"); _Static_assert(offsetof(cloudabi32_send_in_t, si_fds) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_send_in_t, si_fdslen) == 12, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_send_in_t, si_fds_len) == 12, "Incorrect layout"); _Static_assert(offsetof(cloudabi32_send_in_t, si_flags) == 16, "Incorrect layout"); _Static_assert(sizeof(cloudabi32_send_in_t) == 20, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_send_in_t) == 4, "Incorrect layout"); @@ -219,12 +219,12 @@ _Static_assert(_Alignof(cloudabi32_recv_out_t) == 4, "Incorrect layout"); typedef struct { _Alignas(4) uint32_t entry_point; _Alignas(4) uint32_t stack; - _Alignas(4) uint32_t stack_size; + _Alignas(4) uint32_t stack_len; _Alignas(4) uint32_t argument; } cloudabi32_threadattr_t; _Static_assert(offsetof(cloudabi32_threadattr_t, entry_point) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi32_threadattr_t, stack) == 4, "Incorrect layout"); -_Static_assert(offsetof(cloudabi32_threadattr_t, stack_size) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi32_threadattr_t, stack_len) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi32_threadattr_t, argument) == 12, "Incorrect layout"); _Static_assert(sizeof(cloudabi32_threadattr_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi32_threadattr_t) == 4, "Incorrect layout"); diff --git a/sys/contrib/cloudabi/cloudabi64_types.h b/sys/contrib/cloudabi/cloudabi64_types.h index 5d54e7e..0a185ac 100644 --- a/sys/contrib/cloudabi/cloudabi64_types.h +++ b/sys/contrib/cloudabi/cloudabi64_types.h @@ -44,12 +44,11 @@ _Static_assert(sizeof(cloudabi64_auxv_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_auxv_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) uint64_t iov_base; - _Alignas(8) uint64_t iov_len; + _Alignas(8) uint64_t buf; + _Alignas(8) uint64_t buf_len; } cloudabi64_ciovec_t; -_Static_assert(offsetof(cloudabi64_ciovec_t, iov_base) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_ciovec_t, iov_len) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_ciovec_t, buf) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_ciovec_t, buf_len) == 8, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_ciovec_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_ciovec_t) == 8, "Incorrect layout"); @@ -82,33 +81,24 @@ typedef struct { _Static_assert(offsetof(cloudabi64_event_t, userdata) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_event_t, error) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_event_t, type) == 10, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, clock.identifier) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, condvar.condvar) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.nbytes) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.fd) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.flags) == 28, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, lock.lock) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.fd) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.signal) == 20, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.exitcode) == 24, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, clock.identifier) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, condvar.condvar) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.nbytes) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.fd) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, fd_readwrite.flags) == 28, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, lock.lock) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.fd) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.signal) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_event_t, proc_terminate.exitcode) == 24, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_event_t) == 32, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_event_t) == 8, "Incorrect layout"); typedef struct { - _Alignas(8) uint64_t iov_base; - _Alignas(8) uint64_t iov_len; + _Alignas(8) uint64_t buf; + _Alignas(8) uint64_t buf_len; } cloudabi64_iovec_t; -_Static_assert(offsetof(cloudabi64_iovec_t, iov_base) == 0, "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_iovec_t, iov_len) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_iovec_t, buf) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_iovec_t, buf_len) == 8, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_iovec_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_iovec_t) == 8, "Incorrect layout"); @@ -116,47 +106,38 @@ typedef void cloudabi64_processentry_t(uint64_t auxv); typedef struct { _Alignas(8) uint64_t ri_data; - _Alignas(8) uint64_t ri_datalen; + _Alignas(8) uint64_t ri_data_len; _Alignas(8) uint64_t ri_fds; - _Alignas(8) uint64_t ri_fdslen; + _Alignas(8) uint64_t ri_fds_len; _Alignas(2) cloudabi_msgflags_t ri_flags; } cloudabi64_recv_in_t; -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_datalen) == 8, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fdslen) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_in_t, ri_flags) == 32, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_data_len) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_fds_len) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_in_t, ri_flags) == 32, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_recv_in_t) == 40, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_recv_in_t) == 8, "Incorrect layout"); typedef struct { _Alignas(8) uint64_t si_data; - _Alignas(8) uint64_t si_datalen; + _Alignas(8) uint64_t si_data_len; _Alignas(8) uint64_t si_fds; - _Alignas(8) uint64_t si_fdslen; + _Alignas(8) uint64_t si_fds_len; _Alignas(2) cloudabi_msgflags_t si_flags; } cloudabi64_send_in_t; -_Static_assert(offsetof(cloudabi64_send_in_t, si_data) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_datalen) == 8, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_fds) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_fdslen) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_send_in_t, si_flags) == 32, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_data) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_data_len) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_fds) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_fds_len) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_send_in_t, si_flags) == 32, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_send_in_t) == 40, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_send_in_t) == 8, "Incorrect layout"); -typedef struct { _Alignas(8) uint64_t so_datalen; } cloudabi64_send_out_t; -_Static_assert(offsetof(cloudabi64_send_out_t, so_datalen) == 0, - "Incorrect layout"); +typedef struct { + _Alignas(8) uint64_t so_datalen; +} cloudabi64_send_out_t; +_Static_assert(offsetof(cloudabi64_send_out_t, so_datalen) == 0, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_send_out_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_send_out_t) == 8, "Incorrect layout"); @@ -191,44 +172,29 @@ typedef struct { } proc_terminate; }; } cloudabi64_subscription_t; -_Static_assert(offsetof(cloudabi64_subscription_t, userdata) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, flags) == 8, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, type) == 10, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.identifier) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.clock_id) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.timeout) == 32, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.precision) == 40, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, clock.flags) == 48, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar_scope) == 32, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock_scope) == 33, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.fd) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.flags) == 20, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock_scope) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_subscription_t, proc_terminate.fd) == 16, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, userdata) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, flags) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, type) == 10, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.identifier) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.clock_id) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.timeout) == 32, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.precision) == 40, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, clock.flags) == 48, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.condvar_scope) == 32, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, condvar.lock_scope) == 33, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.fd) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, fd_readwrite.flags) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, lock.lock_scope) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_subscription_t, proc_terminate.fd) == 16, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_subscription_t) == 56, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_subscription_t) == 8, "Incorrect layout"); -typedef struct { _Alignas(8) uint64_t parent; } cloudabi64_tcb_t; +typedef struct { + _Alignas(8) uint64_t parent; +} cloudabi64_tcb_t; _Static_assert(offsetof(cloudabi64_tcb_t, parent) == 0, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_tcb_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_tcb_t) == 8, "Incorrect layout"); @@ -242,33 +208,24 @@ typedef struct { _Alignas(2) cloudabi_sockaddr_t ro_peername; _Alignas(2) cloudabi_msgflags_t ro_flags; } cloudabi64_recv_out_t; -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_datalen) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_fdslen) == 8, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_sockname) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_peername) == 36, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_recv_out_t, ro_flags) == 56, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_datalen) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_fdslen) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_sockname) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_peername) == 36, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_recv_out_t, ro_flags) == 56, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_recv_out_t) == 64, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_recv_out_t) == 8, "Incorrect layout"); typedef struct { _Alignas(8) uint64_t entry_point; _Alignas(8) uint64_t stack; - _Alignas(8) uint64_t stack_size; + _Alignas(8) uint64_t stack_len; _Alignas(8) uint64_t argument; } cloudabi64_threadattr_t; -_Static_assert(offsetof(cloudabi64_threadattr_t, entry_point) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, stack) == 8, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, stack_size) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi64_threadattr_t, argument) == 24, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, entry_point) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, stack) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, stack_len) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi64_threadattr_t, argument) == 24, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_threadattr_t) == 32, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_threadattr_t) == 8, "Incorrect layout"); diff --git a/sys/contrib/cloudabi/cloudabi_types_common.h b/sys/contrib/cloudabi/cloudabi_types_common.h index 0297e2a9..86e76d3 100644 --- a/sys/contrib/cloudabi/cloudabi_types_common.h +++ b/sys/contrib/cloudabi/cloudabi_types_common.h @@ -38,34 +38,34 @@ #endif typedef uint8_t cloudabi_advice_t; -#define CLOUDABI_ADVICE_DONTNEED 1 -#define CLOUDABI_ADVICE_NOREUSE 2 -#define CLOUDABI_ADVICE_NORMAL 3 -#define CLOUDABI_ADVICE_RANDOM 4 +#define CLOUDABI_ADVICE_DONTNEED 1 +#define CLOUDABI_ADVICE_NOREUSE 2 +#define CLOUDABI_ADVICE_NORMAL 3 +#define CLOUDABI_ADVICE_RANDOM 4 #define CLOUDABI_ADVICE_SEQUENTIAL 5 -#define CLOUDABI_ADVICE_WILLNEED 6 +#define CLOUDABI_ADVICE_WILLNEED 6 typedef uint32_t cloudabi_auxtype_t; -#define CLOUDABI_AT_ARGDATA 256 -#define CLOUDABI_AT_ARGDATALEN 257 -#define CLOUDABI_AT_BASE 7 -#define CLOUDABI_AT_CANARY 258 -#define CLOUDABI_AT_CANARYLEN 259 -#define CLOUDABI_AT_NCPUS 260 -#define CLOUDABI_AT_NULL 0 -#define CLOUDABI_AT_PAGESZ 6 -#define CLOUDABI_AT_PHDR 3 -#define CLOUDABI_AT_PHNUM 4 +#define CLOUDABI_AT_ARGDATA 256 +#define CLOUDABI_AT_ARGDATALEN 257 +#define CLOUDABI_AT_BASE 7 +#define CLOUDABI_AT_CANARY 258 +#define CLOUDABI_AT_CANARYLEN 259 +#define CLOUDABI_AT_NCPUS 260 +#define CLOUDABI_AT_NULL 0 +#define CLOUDABI_AT_PAGESZ 6 +#define CLOUDABI_AT_PHDR 3 +#define CLOUDABI_AT_PHNUM 4 #define CLOUDABI_AT_SYSINFO_EHDR 262 -#define CLOUDABI_AT_TID 261 +#define CLOUDABI_AT_TID 261 typedef uint32_t cloudabi_backlog_t; typedef uint32_t cloudabi_clockid_t; -#define CLOUDABI_CLOCK_MONOTONIC 1 +#define CLOUDABI_CLOCK_MONOTONIC 1 #define CLOUDABI_CLOCK_PROCESS_CPUTIME_ID 2 -#define CLOUDABI_CLOCK_REALTIME 3 -#define CLOUDABI_CLOCK_THREAD_CPUTIME_ID 4 +#define CLOUDABI_CLOCK_REALTIME 3 +#define CLOUDABI_CLOCK_THREAD_CPUTIME_ID 4 typedef uint32_t cloudabi_condvar_t; #define CLOUDABI_CONDVAR_HAS_NO_WAITERS 0 @@ -76,110 +76,110 @@ typedef uint64_t cloudabi_dircookie_t; #define CLOUDABI_DIRCOOKIE_START 0 typedef uint16_t cloudabi_errno_t; -#define CLOUDABI_E2BIG 1 -#define CLOUDABI_EACCES 2 -#define CLOUDABI_EADDRINUSE 3 -#define CLOUDABI_EADDRNOTAVAIL 4 -#define CLOUDABI_EAFNOSUPPORT 5 -#define CLOUDABI_EAGAIN 6 -#define CLOUDABI_EALREADY 7 -#define CLOUDABI_EBADF 8 -#define CLOUDABI_EBADMSG 9 -#define CLOUDABI_EBUSY 10 -#define CLOUDABI_ECANCELED 11 -#define CLOUDABI_ECHILD 12 -#define CLOUDABI_ECONNABORTED 13 -#define CLOUDABI_ECONNREFUSED 14 -#define CLOUDABI_ECONNRESET 15 -#define CLOUDABI_EDEADLK 16 -#define CLOUDABI_EDESTADDRREQ 17 -#define CLOUDABI_EDOM 18 -#define CLOUDABI_EDQUOT 19 -#define CLOUDABI_EEXIST 20 -#define CLOUDABI_EFAULT 21 -#define CLOUDABI_EFBIG 22 -#define CLOUDABI_EHOSTUNREACH 23 -#define CLOUDABI_EIDRM 24 -#define CLOUDABI_EILSEQ 25 -#define CLOUDABI_EINPROGRESS 26 -#define CLOUDABI_EINTR 27 -#define CLOUDABI_EINVAL 28 -#define CLOUDABI_EIO 29 -#define CLOUDABI_EISCONN 30 -#define CLOUDABI_EISDIR 31 -#define CLOUDABI_ELOOP 32 -#define CLOUDABI_EMFILE 33 -#define CLOUDABI_EMLINK 34 -#define CLOUDABI_EMSGSIZE 35 -#define CLOUDABI_EMULTIHOP 36 -#define CLOUDABI_ENAMETOOLONG 37 -#define CLOUDABI_ENETDOWN 38 -#define CLOUDABI_ENETRESET 39 -#define CLOUDABI_ENETUNREACH 40 -#define CLOUDABI_ENFILE 41 -#define CLOUDABI_ENOBUFS 42 -#define CLOUDABI_ENODEV 43 -#define CLOUDABI_ENOENT 44 -#define CLOUDABI_ENOEXEC 45 -#define CLOUDABI_ENOLCK 46 -#define CLOUDABI_ENOLINK 47 -#define CLOUDABI_ENOMEM 48 -#define CLOUDABI_ENOMSG 49 -#define CLOUDABI_ENOPROTOOPT 50 -#define CLOUDABI_ENOSPC 51 -#define CLOUDABI_ENOSYS 52 -#define CLOUDABI_ENOTCONN 53 -#define CLOUDABI_ENOTDIR 54 -#define CLOUDABI_ENOTEMPTY 55 +#define CLOUDABI_E2BIG 1 +#define CLOUDABI_EACCES 2 +#define CLOUDABI_EADDRINUSE 3 +#define CLOUDABI_EADDRNOTAVAIL 4 +#define CLOUDABI_EAFNOSUPPORT 5 +#define CLOUDABI_EAGAIN 6 +#define CLOUDABI_EALREADY 7 +#define CLOUDABI_EBADF 8 +#define CLOUDABI_EBADMSG 9 +#define CLOUDABI_EBUSY 10 +#define CLOUDABI_ECANCELED 11 +#define CLOUDABI_ECHILD 12 +#define CLOUDABI_ECONNABORTED 13 +#define CLOUDABI_ECONNREFUSED 14 +#define CLOUDABI_ECONNRESET 15 +#define CLOUDABI_EDEADLK 16 +#define CLOUDABI_EDESTADDRREQ 17 +#define CLOUDABI_EDOM 18 +#define CLOUDABI_EDQUOT 19 +#define CLOUDABI_EEXIST 20 +#define CLOUDABI_EFAULT 21 +#define CLOUDABI_EFBIG 22 +#define CLOUDABI_EHOSTUNREACH 23 +#define CLOUDABI_EIDRM 24 +#define CLOUDABI_EILSEQ 25 +#define CLOUDABI_EINPROGRESS 26 +#define CLOUDABI_EINTR 27 +#define CLOUDABI_EINVAL 28 +#define CLOUDABI_EIO 29 +#define CLOUDABI_EISCONN 30 +#define CLOUDABI_EISDIR 31 +#define CLOUDABI_ELOOP 32 +#define CLOUDABI_EMFILE 33 +#define CLOUDABI_EMLINK 34 +#define CLOUDABI_EMSGSIZE 35 +#define CLOUDABI_EMULTIHOP 36 +#define CLOUDABI_ENAMETOOLONG 37 +#define CLOUDABI_ENETDOWN 38 +#define CLOUDABI_ENETRESET 39 +#define CLOUDABI_ENETUNREACH 40 +#define CLOUDABI_ENFILE 41 +#define CLOUDABI_ENOBUFS 42 +#define CLOUDABI_ENODEV 43 +#define CLOUDABI_ENOENT 44 +#define CLOUDABI_ENOEXEC 45 +#define CLOUDABI_ENOLCK 46 +#define CLOUDABI_ENOLINK 47 +#define CLOUDABI_ENOMEM 48 +#define CLOUDABI_ENOMSG 49 +#define CLOUDABI_ENOPROTOOPT 50 +#define CLOUDABI_ENOSPC 51 +#define CLOUDABI_ENOSYS 52 +#define CLOUDABI_ENOTCONN 53 +#define CLOUDABI_ENOTDIR 54 +#define CLOUDABI_ENOTEMPTY 55 #define CLOUDABI_ENOTRECOVERABLE 56 -#define CLOUDABI_ENOTSOCK 57 -#define CLOUDABI_ENOTSUP 58 -#define CLOUDABI_ENOTTY 59 -#define CLOUDABI_ENXIO 60 -#define CLOUDABI_EOVERFLOW 61 -#define CLOUDABI_EOWNERDEAD 62 -#define CLOUDABI_EPERM 63 -#define CLOUDABI_EPIPE 64 -#define CLOUDABI_EPROTO 65 +#define CLOUDABI_ENOTSOCK 57 +#define CLOUDABI_ENOTSUP 58 +#define CLOUDABI_ENOTTY 59 +#define CLOUDABI_ENXIO 60 +#define CLOUDABI_EOVERFLOW 61 +#define CLOUDABI_EOWNERDEAD 62 +#define CLOUDABI_EPERM 63 +#define CLOUDABI_EPIPE 64 +#define CLOUDABI_EPROTO 65 #define CLOUDABI_EPROTONOSUPPORT 66 -#define CLOUDABI_EPROTOTYPE 67 -#define CLOUDABI_ERANGE 68 -#define CLOUDABI_EROFS 69 -#define CLOUDABI_ESPIPE 70 -#define CLOUDABI_ESRCH 71 -#define CLOUDABI_ESTALE 72 -#define CLOUDABI_ETIMEDOUT 73 -#define CLOUDABI_ETXTBSY 74 -#define CLOUDABI_EXDEV 75 -#define CLOUDABI_ENOTCAPABLE 76 +#define CLOUDABI_EPROTOTYPE 67 +#define CLOUDABI_ERANGE 68 +#define CLOUDABI_EROFS 69 +#define CLOUDABI_ESPIPE 70 +#define CLOUDABI_ESRCH 71 +#define CLOUDABI_ESTALE 72 +#define CLOUDABI_ETIMEDOUT 73 +#define CLOUDABI_ETXTBSY 74 +#define CLOUDABI_EXDEV 75 +#define CLOUDABI_ENOTCAPABLE 76 typedef uint16_t cloudabi_eventrwflags_t; #define CLOUDABI_EVENT_FD_READWRITE_HANGUP 0x0001 typedef uint8_t cloudabi_eventtype_t; -#define CLOUDABI_EVENTTYPE_CLOCK 1 -#define CLOUDABI_EVENTTYPE_CONDVAR 2 -#define CLOUDABI_EVENTTYPE_FD_READ 3 -#define CLOUDABI_EVENTTYPE_FD_WRITE 4 -#define CLOUDABI_EVENTTYPE_LOCK_RDLOCK 5 -#define CLOUDABI_EVENTTYPE_LOCK_WRLOCK 6 +#define CLOUDABI_EVENTTYPE_CLOCK 1 +#define CLOUDABI_EVENTTYPE_CONDVAR 2 +#define CLOUDABI_EVENTTYPE_FD_READ 3 +#define CLOUDABI_EVENTTYPE_FD_WRITE 4 +#define CLOUDABI_EVENTTYPE_LOCK_RDLOCK 5 +#define CLOUDABI_EVENTTYPE_LOCK_WRLOCK 6 #define CLOUDABI_EVENTTYPE_PROC_TERMINATE 7 typedef uint32_t cloudabi_exitcode_t; typedef uint32_t cloudabi_fd_t; #define CLOUDABI_PROCESS_CHILD 0xffffffff -#define CLOUDABI_MAP_ANON_FD 0xffffffff +#define CLOUDABI_MAP_ANON_FD 0xffffffff typedef uint16_t cloudabi_fdflags_t; -#define CLOUDABI_FDFLAG_APPEND 0x0001 -#define CLOUDABI_FDFLAG_DSYNC 0x0002 +#define CLOUDABI_FDFLAG_APPEND 0x0001 +#define CLOUDABI_FDFLAG_DSYNC 0x0002 #define CLOUDABI_FDFLAG_NONBLOCK 0x0004 -#define CLOUDABI_FDFLAG_RSYNC 0x0008 -#define CLOUDABI_FDFLAG_SYNC 0x0010 +#define CLOUDABI_FDFLAG_RSYNC 0x0008 +#define CLOUDABI_FDFLAG_SYNC 0x0010 typedef uint16_t cloudabi_fdsflags_t; -#define CLOUDABI_FDSTAT_FLAGS 0x0001 +#define CLOUDABI_FDSTAT_FLAGS 0x0001 #define CLOUDABI_FDSTAT_RIGHTS 0x0002 typedef int64_t cloudabi_filedelta_t; @@ -187,155 +187,155 @@ typedef int64_t cloudabi_filedelta_t; typedef uint64_t cloudabi_filesize_t; typedef uint8_t cloudabi_filetype_t; -#define CLOUDABI_FILETYPE_UNKNOWN 0 -#define CLOUDABI_FILETYPE_BLOCK_DEVICE 16 -#define CLOUDABI_FILETYPE_CHARACTER_DEVICE 17 -#define CLOUDABI_FILETYPE_DIRECTORY 32 -#define CLOUDABI_FILETYPE_FIFO 48 -#define CLOUDABI_FILETYPE_POLL 64 -#define CLOUDABI_FILETYPE_PROCESS 80 -#define CLOUDABI_FILETYPE_REGULAR_FILE 96 -#define CLOUDABI_FILETYPE_SHARED_MEMORY 112 -#define CLOUDABI_FILETYPE_SOCKET_DGRAM 128 +#define CLOUDABI_FILETYPE_UNKNOWN 0 +#define CLOUDABI_FILETYPE_BLOCK_DEVICE 16 +#define CLOUDABI_FILETYPE_CHARACTER_DEVICE 17 +#define CLOUDABI_FILETYPE_DIRECTORY 32 +#define CLOUDABI_FILETYPE_FIFO 48 +#define CLOUDABI_FILETYPE_POLL 64 +#define CLOUDABI_FILETYPE_PROCESS 80 +#define CLOUDABI_FILETYPE_REGULAR_FILE 96 +#define CLOUDABI_FILETYPE_SHARED_MEMORY 112 +#define CLOUDABI_FILETYPE_SOCKET_DGRAM 128 #define CLOUDABI_FILETYPE_SOCKET_SEQPACKET 129 -#define CLOUDABI_FILETYPE_SOCKET_STREAM 130 -#define CLOUDABI_FILETYPE_SYMBOLIC_LINK 144 +#define CLOUDABI_FILETYPE_SOCKET_STREAM 130 +#define CLOUDABI_FILETYPE_SYMBOLIC_LINK 144 typedef uint16_t cloudabi_fsflags_t; -#define CLOUDABI_FILESTAT_ATIM 0x0001 +#define CLOUDABI_FILESTAT_ATIM 0x0001 #define CLOUDABI_FILESTAT_ATIM_NOW 0x0002 -#define CLOUDABI_FILESTAT_MTIM 0x0004 +#define CLOUDABI_FILESTAT_MTIM 0x0004 #define CLOUDABI_FILESTAT_MTIM_NOW 0x0008 -#define CLOUDABI_FILESTAT_SIZE 0x0010 +#define CLOUDABI_FILESTAT_SIZE 0x0010 typedef uint64_t cloudabi_inode_t; typedef uint32_t cloudabi_linkcount_t; typedef uint32_t cloudabi_lock_t; -#define CLOUDABI_LOCK_UNLOCKED 0x00000000 -#define CLOUDABI_LOCK_WRLOCKED 0x40000000 +#define CLOUDABI_LOCK_UNLOCKED 0x00000000 +#define CLOUDABI_LOCK_WRLOCKED 0x40000000 #define CLOUDABI_LOCK_KERNEL_MANAGED 0x80000000 -#define CLOUDABI_LOCK_BOGUS 0x80000000 +#define CLOUDABI_LOCK_BOGUS 0x80000000 typedef uint32_t cloudabi_lookupflags_t; #define CLOUDABI_LOOKUP_SYMLINK_FOLLOW 0x00000001 typedef uint8_t cloudabi_mflags_t; -#define CLOUDABI_MAP_ANON 0x01 -#define CLOUDABI_MAP_FIXED 0x02 +#define CLOUDABI_MAP_ANON 0x01 +#define CLOUDABI_MAP_FIXED 0x02 #define CLOUDABI_MAP_PRIVATE 0x04 -#define CLOUDABI_MAP_SHARED 0x08 +#define CLOUDABI_MAP_SHARED 0x08 typedef uint8_t cloudabi_mprot_t; -#define CLOUDABI_PROT_EXEC 0x01 +#define CLOUDABI_PROT_EXEC 0x01 #define CLOUDABI_PROT_WRITE 0x02 -#define CLOUDABI_PROT_READ 0x04 +#define CLOUDABI_PROT_READ 0x04 typedef uint8_t cloudabi_msflags_t; -#define CLOUDABI_MS_ASYNC 0x01 +#define CLOUDABI_MS_ASYNC 0x01 #define CLOUDABI_MS_INVALIDATE 0x02 -#define CLOUDABI_MS_SYNC 0x04 +#define CLOUDABI_MS_SYNC 0x04 typedef uint16_t cloudabi_msgflags_t; -#define CLOUDABI_MSG_CTRUNC 0x0001 -#define CLOUDABI_MSG_EOR 0x0002 -#define CLOUDABI_MSG_PEEK 0x0004 -#define CLOUDABI_MSG_TRUNC 0x0008 +#define CLOUDABI_MSG_CTRUNC 0x0001 +#define CLOUDABI_MSG_EOR 0x0002 +#define CLOUDABI_MSG_PEEK 0x0004 +#define CLOUDABI_MSG_TRUNC 0x0008 #define CLOUDABI_MSG_WAITALL 0x0010 typedef uint32_t cloudabi_nthreads_t; typedef uint16_t cloudabi_oflags_t; -#define CLOUDABI_O_CREAT 0x0001 +#define CLOUDABI_O_CREAT 0x0001 #define CLOUDABI_O_DIRECTORY 0x0002 -#define CLOUDABI_O_EXCL 0x0004 -#define CLOUDABI_O_TRUNC 0x0008 +#define CLOUDABI_O_EXCL 0x0004 +#define CLOUDABI_O_TRUNC 0x0008 typedef uint64_t cloudabi_rights_t; -#define CLOUDABI_RIGHT_FD_DATASYNC 0x0000000000000001 -#define CLOUDABI_RIGHT_FD_READ 0x0000000000000002 -#define CLOUDABI_RIGHT_FD_SEEK 0x0000000000000004 -#define CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS 0x0000000000000008 -#define CLOUDABI_RIGHT_FD_SYNC 0x0000000000000010 -#define CLOUDABI_RIGHT_FD_TELL 0x0000000000000020 -#define CLOUDABI_RIGHT_FD_WRITE 0x0000000000000040 -#define CLOUDABI_RIGHT_FILE_ADVISE 0x0000000000000080 -#define CLOUDABI_RIGHT_FILE_ALLOCATE 0x0000000000000100 -#define CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY 0x0000000000000200 -#define CLOUDABI_RIGHT_FILE_CREATE_FILE 0x0000000000000400 -#define CLOUDABI_RIGHT_FILE_CREATE_FIFO 0x0000000000000800 -#define CLOUDABI_RIGHT_FILE_LINK_SOURCE 0x0000000000001000 -#define CLOUDABI_RIGHT_FILE_LINK_TARGET 0x0000000000002000 -#define CLOUDABI_RIGHT_FILE_OPEN 0x0000000000004000 -#define CLOUDABI_RIGHT_FILE_READDIR 0x0000000000008000 -#define CLOUDABI_RIGHT_FILE_READLINK 0x0000000000010000 -#define CLOUDABI_RIGHT_FILE_RENAME_SOURCE 0x0000000000020000 -#define CLOUDABI_RIGHT_FILE_RENAME_TARGET 0x0000000000040000 -#define CLOUDABI_RIGHT_FILE_STAT_FGET 0x0000000000080000 -#define CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE 0x0000000000100000 -#define CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES 0x0000000000200000 -#define CLOUDABI_RIGHT_FILE_STAT_GET 0x0000000000400000 -#define CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES 0x0000000000800000 -#define CLOUDABI_RIGHT_FILE_SYMLINK 0x0000000001000000 -#define CLOUDABI_RIGHT_FILE_UNLINK 0x0000000002000000 -#define CLOUDABI_RIGHT_MEM_MAP 0x0000000004000000 -#define CLOUDABI_RIGHT_MEM_MAP_EXEC 0x0000000008000000 -#define CLOUDABI_RIGHT_POLL_FD_READWRITE 0x0000000010000000 -#define CLOUDABI_RIGHT_POLL_MODIFY 0x0000000020000000 -#define CLOUDABI_RIGHT_POLL_PROC_TERMINATE 0x0000000040000000 -#define CLOUDABI_RIGHT_POLL_WAIT 0x0000000080000000 -#define CLOUDABI_RIGHT_PROC_EXEC 0x0000000100000000 -#define CLOUDABI_RIGHT_SOCK_ACCEPT 0x0000000200000000 -#define CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY 0x0000000400000000 -#define CLOUDABI_RIGHT_SOCK_BIND_SOCKET 0x0000000800000000 +#define CLOUDABI_RIGHT_FD_DATASYNC 0x0000000000000001 +#define CLOUDABI_RIGHT_FD_READ 0x0000000000000002 +#define CLOUDABI_RIGHT_FD_SEEK 0x0000000000000004 +#define CLOUDABI_RIGHT_FD_STAT_PUT_FLAGS 0x0000000000000008 +#define CLOUDABI_RIGHT_FD_SYNC 0x0000000000000010 +#define CLOUDABI_RIGHT_FD_TELL 0x0000000000000020 +#define CLOUDABI_RIGHT_FD_WRITE 0x0000000000000040 +#define CLOUDABI_RIGHT_FILE_ADVISE 0x0000000000000080 +#define CLOUDABI_RIGHT_FILE_ALLOCATE 0x0000000000000100 +#define CLOUDABI_RIGHT_FILE_CREATE_DIRECTORY 0x0000000000000200 +#define CLOUDABI_RIGHT_FILE_CREATE_FILE 0x0000000000000400 +#define CLOUDABI_RIGHT_FILE_CREATE_FIFO 0x0000000000000800 +#define CLOUDABI_RIGHT_FILE_LINK_SOURCE 0x0000000000001000 +#define CLOUDABI_RIGHT_FILE_LINK_TARGET 0x0000000000002000 +#define CLOUDABI_RIGHT_FILE_OPEN 0x0000000000004000 +#define CLOUDABI_RIGHT_FILE_READDIR 0x0000000000008000 +#define CLOUDABI_RIGHT_FILE_READLINK 0x0000000000010000 +#define CLOUDABI_RIGHT_FILE_RENAME_SOURCE 0x0000000000020000 +#define CLOUDABI_RIGHT_FILE_RENAME_TARGET 0x0000000000040000 +#define CLOUDABI_RIGHT_FILE_STAT_FGET 0x0000000000080000 +#define CLOUDABI_RIGHT_FILE_STAT_FPUT_SIZE 0x0000000000100000 +#define CLOUDABI_RIGHT_FILE_STAT_FPUT_TIMES 0x0000000000200000 +#define CLOUDABI_RIGHT_FILE_STAT_GET 0x0000000000400000 +#define CLOUDABI_RIGHT_FILE_STAT_PUT_TIMES 0x0000000000800000 +#define CLOUDABI_RIGHT_FILE_SYMLINK 0x0000000001000000 +#define CLOUDABI_RIGHT_FILE_UNLINK 0x0000000002000000 +#define CLOUDABI_RIGHT_MEM_MAP 0x0000000004000000 +#define CLOUDABI_RIGHT_MEM_MAP_EXEC 0x0000000008000000 +#define CLOUDABI_RIGHT_POLL_FD_READWRITE 0x0000000010000000 +#define CLOUDABI_RIGHT_POLL_MODIFY 0x0000000020000000 +#define CLOUDABI_RIGHT_POLL_PROC_TERMINATE 0x0000000040000000 +#define CLOUDABI_RIGHT_POLL_WAIT 0x0000000080000000 +#define CLOUDABI_RIGHT_PROC_EXEC 0x0000000100000000 +#define CLOUDABI_RIGHT_SOCK_ACCEPT 0x0000000200000000 +#define CLOUDABI_RIGHT_SOCK_BIND_DIRECTORY 0x0000000400000000 +#define CLOUDABI_RIGHT_SOCK_BIND_SOCKET 0x0000000800000000 #define CLOUDABI_RIGHT_SOCK_CONNECT_DIRECTORY 0x0000001000000000 -#define CLOUDABI_RIGHT_SOCK_CONNECT_SOCKET 0x0000002000000000 -#define CLOUDABI_RIGHT_SOCK_LISTEN 0x0000004000000000 -#define CLOUDABI_RIGHT_SOCK_SHUTDOWN 0x0000008000000000 -#define CLOUDABI_RIGHT_SOCK_STAT_GET 0x0000010000000000 +#define CLOUDABI_RIGHT_SOCK_CONNECT_SOCKET 0x0000002000000000 +#define CLOUDABI_RIGHT_SOCK_LISTEN 0x0000004000000000 +#define CLOUDABI_RIGHT_SOCK_SHUTDOWN 0x0000008000000000 +#define CLOUDABI_RIGHT_SOCK_STAT_GET 0x0000010000000000 typedef uint8_t cloudabi_sa_family_t; #define CLOUDABI_AF_UNSPEC 0 -#define CLOUDABI_AF_INET 1 -#define CLOUDABI_AF_INET6 2 -#define CLOUDABI_AF_UNIX 3 +#define CLOUDABI_AF_INET 1 +#define CLOUDABI_AF_INET6 2 +#define CLOUDABI_AF_UNIX 3 typedef uint8_t cloudabi_scope_t; #define CLOUDABI_SCOPE_PRIVATE 4 -#define CLOUDABI_SCOPE_SHARED 8 +#define CLOUDABI_SCOPE_SHARED 8 typedef uint8_t cloudabi_sdflags_t; #define CLOUDABI_SHUT_RD 0x01 #define CLOUDABI_SHUT_WR 0x02 typedef uint8_t cloudabi_signal_t; -#define CLOUDABI_SIGABRT 1 -#define CLOUDABI_SIGALRM 2 -#define CLOUDABI_SIGBUS 3 -#define CLOUDABI_SIGCHLD 4 -#define CLOUDABI_SIGCONT 5 -#define CLOUDABI_SIGFPE 6 -#define CLOUDABI_SIGHUP 7 -#define CLOUDABI_SIGILL 8 -#define CLOUDABI_SIGINT 9 -#define CLOUDABI_SIGKILL 10 -#define CLOUDABI_SIGPIPE 11 -#define CLOUDABI_SIGQUIT 12 -#define CLOUDABI_SIGSEGV 13 -#define CLOUDABI_SIGSTOP 14 -#define CLOUDABI_SIGSYS 15 -#define CLOUDABI_SIGTERM 16 -#define CLOUDABI_SIGTRAP 17 -#define CLOUDABI_SIGTSTP 18 -#define CLOUDABI_SIGTTIN 19 -#define CLOUDABI_SIGTTOU 20 -#define CLOUDABI_SIGURG 21 -#define CLOUDABI_SIGUSR1 22 -#define CLOUDABI_SIGUSR2 23 +#define CLOUDABI_SIGABRT 1 +#define CLOUDABI_SIGALRM 2 +#define CLOUDABI_SIGBUS 3 +#define CLOUDABI_SIGCHLD 4 +#define CLOUDABI_SIGCONT 5 +#define CLOUDABI_SIGFPE 6 +#define CLOUDABI_SIGHUP 7 +#define CLOUDABI_SIGILL 8 +#define CLOUDABI_SIGINT 9 +#define CLOUDABI_SIGKILL 10 +#define CLOUDABI_SIGPIPE 11 +#define CLOUDABI_SIGQUIT 12 +#define CLOUDABI_SIGSEGV 13 +#define CLOUDABI_SIGSTOP 14 +#define CLOUDABI_SIGSYS 15 +#define CLOUDABI_SIGTERM 16 +#define CLOUDABI_SIGTRAP 17 +#define CLOUDABI_SIGTSTP 18 +#define CLOUDABI_SIGTTIN 19 +#define CLOUDABI_SIGTTOU 20 +#define CLOUDABI_SIGURG 21 +#define CLOUDABI_SIGUSR1 22 +#define CLOUDABI_SIGUSR2 23 #define CLOUDABI_SIGVTALRM 24 -#define CLOUDABI_SIGXCPU 25 -#define CLOUDABI_SIGXFSZ 26 +#define CLOUDABI_SIGXCPU 25 +#define CLOUDABI_SIGXFSZ 26 typedef uint8_t cloudabi_ssflags_t; #define CLOUDABI_SOCKSTAT_CLEAR_ERROR 0x01 @@ -347,11 +347,11 @@ typedef uint16_t cloudabi_subclockflags_t; #define CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME 0x0001 typedef uint16_t cloudabi_subflags_t; -#define CLOUDABI_SUBSCRIPTION_ADD 0x0001 -#define CLOUDABI_SUBSCRIPTION_CLEAR 0x0002 -#define CLOUDABI_SUBSCRIPTION_DELETE 0x0004 +#define CLOUDABI_SUBSCRIPTION_ADD 0x0001 +#define CLOUDABI_SUBSCRIPTION_CLEAR 0x0002 +#define CLOUDABI_SUBSCRIPTION_DELETE 0x0004 #define CLOUDABI_SUBSCRIPTION_DISABLE 0x0008 -#define CLOUDABI_SUBSCRIPTION_ENABLE 0x0010 +#define CLOUDABI_SUBSCRIPTION_ENABLE 0x0010 #define CLOUDABI_SUBSCRIPTION_ONESHOT 0x0020 typedef uint16_t cloudabi_subrwflags_t; @@ -390,13 +390,10 @@ typedef struct { _Alignas(8) cloudabi_rights_t fs_rights_base; _Alignas(8) cloudabi_rights_t fs_rights_inheriting; } cloudabi_fdstat_t; -_Static_assert(offsetof(cloudabi_fdstat_t, fs_filetype) == 0, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi_fdstat_t, fs_filetype) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_fdstat_t, fs_flags) == 2, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_base) == 8, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_inheriting) == 16, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_base) == 8, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_inheriting) == 16, "Incorrect layout"); _Static_assert(sizeof(cloudabi_fdstat_t) == 24, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_fdstat_t) == 8, "Incorrect layout"); @@ -412,18 +409,12 @@ typedef struct { } cloudabi_filestat_t; _Static_assert(offsetof(cloudabi_filestat_t, st_dev) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_ino) == 8, "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_filetype) == 16, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_nlink) == 20, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_size) == 24, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_atim) == 32, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_mtim) == 40, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_filestat_t, st_ctim) == 48, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_filetype) == 16, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_nlink) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_size) == 24, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_atim) == 32, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_mtim) == 40, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_filestat_t, st_ctim) == 48, "Incorrect layout"); _Static_assert(sizeof(cloudabi_filestat_t) == 56, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_filestat_t) == 8, "Incorrect layout"); @@ -449,16 +440,11 @@ typedef struct { } sa_inet6; }; } cloudabi_sockaddr_t; -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_family) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.addr) == 2, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.port) == 6, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.addr) == 2, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.port) == 18, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_family) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.addr) == 2, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet.port) == 6, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.addr) == 2, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockaddr_t, sa_inet6.port) == 18, "Incorrect layout"); _Static_assert(sizeof(cloudabi_sockaddr_t) == 20, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_sockaddr_t) == 2, "Incorrect layout"); @@ -468,14 +454,10 @@ typedef struct { _Alignas(2) cloudabi_errno_t ss_error; _Alignas(4) cloudabi_sstate_t ss_state; } cloudabi_sockstat_t; -_Static_assert(offsetof(cloudabi_sockstat_t, ss_sockname) == 0, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockstat_t, ss_peername) == 20, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockstat_t, ss_error) == 40, - "Incorrect layout"); -_Static_assert(offsetof(cloudabi_sockstat_t, ss_state) == 44, - "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_sockname) == 0, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_peername) == 20, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_error) == 40, "Incorrect layout"); +_Static_assert(offsetof(cloudabi_sockstat_t, ss_state) == 44, "Incorrect layout"); _Static_assert(sizeof(cloudabi_sockstat_t) == 48, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_sockstat_t) == 4, "Incorrect layout"); diff --git a/sys/contrib/cloudabi/syscalls32.master b/sys/contrib/cloudabi/syscalls32.master index aa3314b..4e0c2b2 100644 --- a/sys/contrib/cloudabi/syscalls32.master +++ b/sys/contrib/cloudabi/syscalls32.master @@ -65,20 +65,20 @@ 8 AUE_NULL STD { size_t cloudabi32_sys_fd_pread( \ cloudabi_fd_t fd, \ - const cloudabi32_iovec_t *iov, \ - size_t iovcnt, \ + const cloudabi32_iovec_t *iovs, \ + size_t iovs_len, \ cloudabi_filesize_t offset); } 9 AUE_NULL STD { size_t cloudabi32_sys_fd_pwrite( \ cloudabi_fd_t fd, \ - const cloudabi32_ciovec_t *iov, \ - size_t iovcnt, \ + const cloudabi32_ciovec_t *iovs, \ + size_t iovs_len, \ cloudabi_filesize_t offset); } 10 AUE_NULL STD { size_t cloudabi32_sys_fd_read( \ cloudabi_fd_t fd, \ - const cloudabi32_iovec_t *iov, \ - size_t iovcnt); } + const cloudabi32_iovec_t *iovs, \ + size_t iovs_len); } 11 AUE_NULL STD { void cloudabi_sys_fd_replace( \ cloudabi_fd_t from, \ @@ -104,8 +104,8 @@ 16 AUE_NULL STD { size_t cloudabi32_sys_fd_write( \ cloudabi_fd_t fd, \ - const cloudabi32_ciovec_t *iov, \ - size_t iovcnt); } + const cloudabi32_ciovec_t *iovs, \ + size_t iovs_len); } 17 AUE_NULL STD { void cloudabi_sys_file_advise( \ cloudabi_fd_t fd, \ @@ -121,44 +121,44 @@ 19 AUE_NULL STD { void cloudabi_sys_file_create( \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_filetype_t type); } 20 AUE_NULL STD { void cloudabi_sys_file_link( \ cloudabi_lookup_t fd1, \ const char *path1, \ - size_t path1len, \ + size_t path1_len, \ cloudabi_fd_t fd2, \ const char *path2, \ - size_t path2len); } + size_t path2_len); } 21 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_file_open( \ cloudabi_lookup_t dirfd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_oflags_t oflags, \ const cloudabi_fdstat_t *fds); } 22 AUE_NULL STD { size_t cloudabi_sys_file_readdir( \ cloudabi_fd_t fd, \ void *buf, \ - size_t nbyte, \ + size_t buf_len, \ cloudabi_dircookie_t cookie); } 23 AUE_NULL STD { size_t cloudabi_sys_file_readlink( \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ char *buf, \ - size_t bufsize); } + size_t buf_len); } 24 AUE_NULL STD { void cloudabi_sys_file_rename( \ - cloudabi_fd_t oldfd, \ - const char *old, \ - size_t oldlen, \ - cloudabi_fd_t newfd, \ - const char *new, \ - size_t newlen); } + cloudabi_fd_t fd1, \ + const char *path1, \ + size_t path1_len, \ + cloudabi_fd_t fd2, \ + const char *path2, \ + size_t path2_len); } 25 AUE_NULL STD { void cloudabi_sys_file_stat_fget( \ cloudabi_fd_t fd, \ @@ -172,27 +172,27 @@ 27 AUE_NULL STD { void cloudabi_sys_file_stat_get( \ cloudabi_lookup_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_filestat_t *buf); } 28 AUE_NULL STD { void cloudabi_sys_file_stat_put( \ cloudabi_lookup_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ const cloudabi_filestat_t *buf, \ cloudabi_fsflags_t flags); } 29 AUE_NULL STD { void cloudabi_sys_file_symlink( \ const char *path1, \ - size_t path1len, \ + size_t path1_len, \ cloudabi_fd_t fd, \ const char *path2, \ - size_t path2len); } + size_t path2_len); } 30 AUE_NULL STD { void cloudabi_sys_file_unlink( \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_ulflags_t flags); } 31 AUE_NULL STD { void cloudabi_sys_lock_unlock( \ @@ -200,13 +200,13 @@ cloudabi_scope_t scope); } 32 AUE_NULL STD { void cloudabi_sys_mem_advise( \ - void *addr, \ - size_t len, \ + void *mapping, \ + size_t mapping_len, \ cloudabi_advice_t advice); } 33 AUE_NULL STD { void cloudabi_sys_mem_lock( \ - const void *addr, \ - size_t len); } + const void *mapping, \ + size_t mapping_len); } 34 AUE_NULL STD { void cloudabi_sys_mem_map( \ void *addr, \ @@ -217,22 +217,22 @@ cloudabi_filesize_t off); } 35 AUE_NULL STD { void cloudabi_sys_mem_protect( \ - void *addr, \ - size_t len, \ + void *mapping, \ + size_t mapping_len, \ cloudabi_mprot_t prot); } 36 AUE_NULL STD { void cloudabi_sys_mem_sync( \ - void *addr, \ - size_t len, \ + void *mapping, \ + size_t mapping_len, \ cloudabi_msflags_t flags); } 37 AUE_NULL STD { void cloudabi_sys_mem_unlock( \ - const void *addr, \ - size_t len); } + const void *mapping, \ + size_t mapping_len); } 38 AUE_NULL STD { void cloudabi_sys_mem_unmap( \ - void *addr, \ - size_t len); } + void *mapping, \ + size_t mapping_len); } 39 AUE_NULL STD { size_t cloudabi32_sys_poll( \ const cloudabi32_subscription_t *in, \ @@ -242,17 +242,17 @@ 40 AUE_NULL STD { size_t cloudabi32_sys_poll_fd( \ cloudabi_fd_t fd, \ const cloudabi32_subscription_t *in, \ - size_t nin, \ + size_t in_len, \ cloudabi32_event_t *out, \ - size_t nout, \ + size_t out_len, \ const cloudabi32_subscription_t *timeout); } 41 AUE_NULL STD { void cloudabi_sys_proc_exec( \ cloudabi_fd_t fd, \ const void *data, \ - size_t datalen, \ + size_t data_len, \ const cloudabi_fd_t *fds, \ - size_t fdslen); } + size_t fds_len); } 42 AUE_NULL STD { void cloudabi_sys_proc_exit( \ cloudabi_exitcode_t rval); } @@ -264,7 +264,7 @@ 45 AUE_NULL STD { void cloudabi_sys_random_get( \ void *buf, \ - size_t nbyte); } + size_t buf_len); } 46 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_sock_accept( \ cloudabi_fd_t sock, \ @@ -274,13 +274,13 @@ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen); } + size_t path_len); } 48 AUE_NULL STD { void cloudabi_sys_sock_connect( \ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen); } + size_t path_len); } 49 AUE_NULL STD { void cloudabi_sys_sock_listen( \ cloudabi_fd_t sock, \ diff --git a/sys/contrib/cloudabi/syscalls64.master b/sys/contrib/cloudabi/syscalls64.master index b2378bd..7f57d76 100644 --- a/sys/contrib/cloudabi/syscalls64.master +++ b/sys/contrib/cloudabi/syscalls64.master @@ -65,20 +65,20 @@ 8 AUE_NULL STD { size_t cloudabi64_sys_fd_pread( \ cloudabi_fd_t fd, \ - const cloudabi64_iovec_t *iov, \ - size_t iovcnt, \ + const cloudabi64_iovec_t *iovs, \ + size_t iovs_len, \ cloudabi_filesize_t offset); } 9 AUE_NULL STD { size_t cloudabi64_sys_fd_pwrite( \ cloudabi_fd_t fd, \ - const cloudabi64_ciovec_t *iov, \ - size_t iovcnt, \ + const cloudabi64_ciovec_t *iovs, \ + size_t iovs_len, \ cloudabi_filesize_t offset); } 10 AUE_NULL STD { size_t cloudabi64_sys_fd_read( \ cloudabi_fd_t fd, \ - const cloudabi64_iovec_t *iov, \ - size_t iovcnt); } + const cloudabi64_iovec_t *iovs, \ + size_t iovs_len); } 11 AUE_NULL STD { void cloudabi_sys_fd_replace( \ cloudabi_fd_t from, \ @@ -104,8 +104,8 @@ 16 AUE_NULL STD { size_t cloudabi64_sys_fd_write( \ cloudabi_fd_t fd, \ - const cloudabi64_ciovec_t *iov, \ - size_t iovcnt); } + const cloudabi64_ciovec_t *iovs, \ + size_t iovs_len); } 17 AUE_NULL STD { void cloudabi_sys_file_advise( \ cloudabi_fd_t fd, \ @@ -121,44 +121,44 @@ 19 AUE_NULL STD { void cloudabi_sys_file_create( \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_filetype_t type); } 20 AUE_NULL STD { void cloudabi_sys_file_link( \ cloudabi_lookup_t fd1, \ const char *path1, \ - size_t path1len, \ + size_t path1_len, \ cloudabi_fd_t fd2, \ const char *path2, \ - size_t path2len); } + size_t path2_len); } 21 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_file_open( \ cloudabi_lookup_t dirfd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_oflags_t oflags, \ const cloudabi_fdstat_t *fds); } 22 AUE_NULL STD { size_t cloudabi_sys_file_readdir( \ cloudabi_fd_t fd, \ void *buf, \ - size_t nbyte, \ + size_t buf_len, \ cloudabi_dircookie_t cookie); } 23 AUE_NULL STD { size_t cloudabi_sys_file_readlink( \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ char *buf, \ - size_t bufsize); } + size_t buf_len); } 24 AUE_NULL STD { void cloudabi_sys_file_rename( \ - cloudabi_fd_t oldfd, \ - const char *old, \ - size_t oldlen, \ - cloudabi_fd_t newfd, \ - const char *new, \ - size_t newlen); } + cloudabi_fd_t fd1, \ + const char *path1, \ + size_t path1_len, \ + cloudabi_fd_t fd2, \ + const char *path2, \ + size_t path2_len); } 25 AUE_NULL STD { void cloudabi_sys_file_stat_fget( \ cloudabi_fd_t fd, \ @@ -172,27 +172,27 @@ 27 AUE_NULL STD { void cloudabi_sys_file_stat_get( \ cloudabi_lookup_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_filestat_t *buf); } 28 AUE_NULL STD { void cloudabi_sys_file_stat_put( \ cloudabi_lookup_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ const cloudabi_filestat_t *buf, \ cloudabi_fsflags_t flags); } 29 AUE_NULL STD { void cloudabi_sys_file_symlink( \ const char *path1, \ - size_t path1len, \ + size_t path1_len, \ cloudabi_fd_t fd, \ const char *path2, \ - size_t path2len); } + size_t path2_len); } 30 AUE_NULL STD { void cloudabi_sys_file_unlink( \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen, \ + size_t path_len, \ cloudabi_ulflags_t flags); } 31 AUE_NULL STD { void cloudabi_sys_lock_unlock( \ @@ -200,13 +200,13 @@ cloudabi_scope_t scope); } 32 AUE_NULL STD { void cloudabi_sys_mem_advise( \ - void *addr, \ - size_t len, \ + void *mapping, \ + size_t mapping_len, \ cloudabi_advice_t advice); } 33 AUE_NULL STD { void cloudabi_sys_mem_lock( \ - const void *addr, \ - size_t len); } + const void *mapping, \ + size_t mapping_len); } 34 AUE_NULL STD { void cloudabi_sys_mem_map( \ void *addr, \ @@ -217,22 +217,22 @@ cloudabi_filesize_t off); } 35 AUE_NULL STD { void cloudabi_sys_mem_protect( \ - void *addr, \ - size_t len, \ + void *mapping, \ + size_t mapping_len, \ cloudabi_mprot_t prot); } 36 AUE_NULL STD { void cloudabi_sys_mem_sync( \ - void *addr, \ - size_t len, \ + void *mapping, \ + size_t mapping_len, \ cloudabi_msflags_t flags); } 37 AUE_NULL STD { void cloudabi_sys_mem_unlock( \ - const void *addr, \ - size_t len); } + const void *mapping, \ + size_t mapping_len); } 38 AUE_NULL STD { void cloudabi_sys_mem_unmap( \ - void *addr, \ - size_t len); } + void *mapping, \ + size_t mapping_len); } 39 AUE_NULL STD { size_t cloudabi64_sys_poll( \ const cloudabi64_subscription_t *in, \ @@ -242,17 +242,17 @@ 40 AUE_NULL STD { size_t cloudabi64_sys_poll_fd( \ cloudabi_fd_t fd, \ const cloudabi64_subscription_t *in, \ - size_t nin, \ + size_t in_len, \ cloudabi64_event_t *out, \ - size_t nout, \ + size_t out_len, \ const cloudabi64_subscription_t *timeout); } 41 AUE_NULL STD { void cloudabi_sys_proc_exec( \ cloudabi_fd_t fd, \ const void *data, \ - size_t datalen, \ + size_t data_len, \ const cloudabi_fd_t *fds, \ - size_t fdslen); } + size_t fds_len); } 42 AUE_NULL STD { void cloudabi_sys_proc_exit( \ cloudabi_exitcode_t rval); } @@ -264,7 +264,7 @@ 45 AUE_NULL STD { void cloudabi_sys_random_get( \ void *buf, \ - size_t nbyte); } + size_t buf_len); } 46 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_sock_accept( \ cloudabi_fd_t sock, \ @@ -274,13 +274,13 @@ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen); } + size_t path_len); } 48 AUE_NULL STD { void cloudabi_sys_sock_connect( \ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ - size_t pathlen); } + size_t path_len); } 49 AUE_NULL STD { void cloudabi_sys_sock_listen( \ cloudabi_fd_t sock, \ diff --git a/sys/i386/cloudabi32/cloudabi32_sysvec.c b/sys/i386/cloudabi32/cloudabi32_sysvec.c index 118b80e..45b9e5c 100644 --- a/sys/i386/cloudabi32/cloudabi32_sysvec.c +++ b/sys/i386/cloudabi32/cloudabi32_sysvec.c @@ -156,7 +156,7 @@ cloudabi32_thread_setregs(struct thread *td, /* Perform standard register initialization. */ stack.ss_sp = TO_PTR(attr->stack); - stack.ss_size = attr->stack_size - sizeof(args); + stack.ss_size = attr->stack_len - sizeof(args); cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack); /* |