aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/cloudabi32/cloudabi32_module.c24
-rw-r--r--sys/compat/cloudabi32/cloudabi32_poll.c21
-rw-r--r--sys/compat/cloudabi32/cloudabi32_proto.h2
-rw-r--r--sys/compat/cloudabi32/cloudabi32_systrace_args.c4
-rw-r--r--sys/compat/cloudabi64/cloudabi64_module.c24
-rw-r--r--sys/compat/cloudabi64/cloudabi64_poll.c21
-rw-r--r--sys/compat/cloudabi64/cloudabi64_proto.h2
-rw-r--r--sys/compat/cloudabi64/cloudabi64_systrace_args.c4
-rw-r--r--sys/contrib/cloudabi/cloudabi32_types.h41
-rw-r--r--sys/contrib/cloudabi/cloudabi64_types.h41
-rw-r--r--sys/contrib/cloudabi/cloudabi_types_common.h30
-rw-r--r--sys/contrib/cloudabi/syscalls32.master2
-rw-r--r--sys/contrib/cloudabi/syscalls64.master2
13 files changed, 86 insertions, 132 deletions
diff --git a/sys/compat/cloudabi32/cloudabi32_module.c b/sys/compat/cloudabi32/cloudabi32_module.c
index 3e4e4a733971..001c673a7d7a 100644
--- a/sys/compat/cloudabi32/cloudabi32_module.c
+++ b/sys/compat/cloudabi32/cloudabi32_module.c
@@ -63,10 +63,10 @@ cloudabi32_copyout_strings(struct image_params *imgp)
int
cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
{
- char canarybuf[64];
+ char canarybuf[64], pidbuf[16];
Elf32_Auxargs *args;
struct thread *td;
- void *argdata, *canary;
+ void *argdata, *canary, *pid;
size_t argdatalen;
int error;
@@ -79,8 +79,9 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
td = curthread;
td->td_proc->p_osrel = __FreeBSD_version;
- /* Store canary for stack smashing protection. */
argdata = *stack_base;
+
+ /* Store canary for stack smashing protection. */
arc4rand(canarybuf, sizeof(canarybuf), 0);
*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
canary = *stack_base;
@@ -89,6 +90,20 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
return (error);
/*
+ * Generate a random UUID that identifies the process. Right now
+ * we don't store this UUID in the kernel. Ideally, it should be
+ * exposed through ps(1).
+ */
+ arc4rand(pidbuf, sizeof(pidbuf), 0);
+ pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
+ pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
+ *stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
+ pid = *stack_base;
+ error = copyout(pidbuf, pid, sizeof(pidbuf));
+ if (error != 0)
+ return (error);
+
+ /*
* Compute length of program arguments. As the argument data is
* binary safe, we had to add a trailing null byte in
* exec_copyin_data_fds(). Undo this by reducing the length.
@@ -111,9 +126,10 @@ cloudabi32_fixup(register_t **stack_base, struct image_params *imgp)
VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
- VAL(CLOUDABI_AT_TID, td->td_tid),
+ PTR(CLOUDABI_AT_PID, pid),
PTR(CLOUDABI_AT_SYSINFO_EHDR,
imgp->proc->p_sysent->sv_shared_page_base),
+ VAL(CLOUDABI_AT_TID, td->td_tid),
#undef VAL
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
diff --git a/sys/compat/cloudabi32/cloudabi32_poll.c b/sys/compat/cloudabi32/cloudabi32_poll.c
index 9bdd9ecb86a7..02e7e7f9ae4f 100644
--- a/sys/compat/cloudabi32/cloudabi32_poll.c
+++ b/sys/compat/cloudabi32/cloudabi32_poll.c
@@ -78,7 +78,7 @@ convert_signal(int sig)
struct cloudabi32_kevent_args {
const cloudabi32_subscription_t *in;
- cloudabi32_event_t *out;
+ cloudabi_event_t *out;
};
/* Converts CloudABI's subscription objects to FreeBSD's struct kevent. */
@@ -145,7 +145,7 @@ cloudabi32_kevent_copyin(void *arg, struct kevent *kevp, int count)
static int
cloudabi32_kevent_copyout(void *arg, struct kevent *kevp, int count)
{
- cloudabi32_event_t ev;
+ cloudabi_event_t ev;
struct cloudabi32_kevent_args *args;
int error;
@@ -157,19 +157,15 @@ cloudabi32_kevent_copyout(void *arg, struct kevent *kevp, int count)
switch (kevp->filter) {
case EVFILT_TIMER:
ev.type = CLOUDABI_EVENTTYPE_CLOCK;
- ev.clock.identifier = kevp->ident;
break;
case EVFILT_READ:
ev.type = CLOUDABI_EVENTTYPE_FD_READ;
- ev.fd_readwrite.fd = kevp->ident;
break;
case EVFILT_WRITE:
ev.type = CLOUDABI_EVENTTYPE_FD_WRITE;
- ev.fd_readwrite.fd = kevp->ident;
break;
case EVFILT_PROCDESC:
ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE;
- ev.proc_terminate.fd = kevp->ident;
break;
}
@@ -231,7 +227,7 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
*/
if (uap->nsubscriptions == 1) {
cloudabi32_subscription_t sub;
- cloudabi32_event_t ev = {};
+ cloudabi_event_t ev = {};
int error;
error = copyin(uap->in, &sub, sizeof(sub));
@@ -241,7 +237,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
ev.type = sub.type;
if (sub.type == CLOUDABI_EVENTTYPE_CONDVAR) {
/* Wait on a condition variable. */
- ev.condvar.condvar = sub.condvar.condvar;
ev.error = cloudabi_convert_errno(
cloudabi_futex_condvar_wait(
td, TO_PTR(sub.condvar.condvar),
@@ -253,7 +248,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
return (copyout(&ev, uap->out, sizeof(ev)));
} else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK) {
/* Acquire a read lock. */
- ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_rdlock(
td, TO_PTR(sub.lock.lock),
@@ -263,7 +257,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
return (copyout(&ev, uap->out, sizeof(ev)));
} else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK) {
/* Acquire a write lock. */
- ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_wrlock(
td, TO_PTR(sub.lock.lock),
@@ -274,7 +267,7 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
}
} else if (uap->nsubscriptions == 2) {
cloudabi32_subscription_t sub[2];
- cloudabi32_event_t ev[2] = {};
+ cloudabi_event_t ev[2] = {};
int error;
error = copyin(uap->in, &sub, sizeof(sub));
@@ -288,8 +281,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Wait for a condition variable with timeout. */
- ev[0].condvar.condvar = sub[0].condvar.condvar;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_condvar_wait(
td, TO_PTR(sub[0].condvar.condvar),
sub[0].condvar.condvar_scope,
@@ -309,8 +300,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Acquire a read lock with a timeout. */
- ev[0].lock.lock = sub[0].lock.lock;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_rdlock(
td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
@@ -328,8 +317,6 @@ cloudabi32_sys_poll(struct thread *td, struct cloudabi32_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Acquire a write lock with a timeout. */
- ev[0].lock.lock = sub[0].lock.lock;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_wrlock(
td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
diff --git a/sys/compat/cloudabi32/cloudabi32_proto.h b/sys/compat/cloudabi32/cloudabi32_proto.h
index 16a072278267..cd1e774ddb2c 100644
--- a/sys/compat/cloudabi32/cloudabi32_proto.h
+++ b/sys/compat/cloudabi32/cloudabi32_proto.h
@@ -224,7 +224,7 @@ struct cloudabi_sys_mem_unmap_args {
};
struct cloudabi32_sys_poll_args {
char in_l_[PADL_(const cloudabi32_subscription_t *)]; const cloudabi32_subscription_t * in; char in_r_[PADR_(const cloudabi32_subscription_t *)];
- char out_l_[PADL_(cloudabi32_event_t *)]; cloudabi32_event_t * out; char out_r_[PADR_(cloudabi32_event_t *)];
+ char out_l_[PADL_(cloudabi_event_t *)]; cloudabi_event_t * out; char out_r_[PADR_(cloudabi_event_t *)];
char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)];
};
struct cloudabi_sys_proc_exec_args {
diff --git a/sys/compat/cloudabi32/cloudabi32_systrace_args.c b/sys/compat/cloudabi32/cloudabi32_systrace_args.c
index 4221955ab5e6..cdc98200160c 100644
--- a/sys/compat/cloudabi32/cloudabi32_systrace_args.c
+++ b/sys/compat/cloudabi32/cloudabi32_systrace_args.c
@@ -352,7 +352,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
case 37: {
struct cloudabi32_sys_poll_args *p = params;
uarg[0] = (intptr_t) p->in; /* const cloudabi32_subscription_t * */
- uarg[1] = (intptr_t) p->out; /* cloudabi32_event_t * */
+ uarg[1] = (intptr_t) p->out; /* cloudabi_event_t * */
uarg[2] = p->nsubscriptions; /* size_t */
*n_args = 3;
break;
@@ -1062,7 +1062,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
p = "userland const cloudabi32_subscription_t *";
break;
case 1:
- p = "userland cloudabi32_event_t *";
+ p = "userland cloudabi_event_t *";
break;
case 2:
p = "size_t";
diff --git a/sys/compat/cloudabi64/cloudabi64_module.c b/sys/compat/cloudabi64/cloudabi64_module.c
index da1ea1149a4b..9c71b87b08f4 100644
--- a/sys/compat/cloudabi64/cloudabi64_module.c
+++ b/sys/compat/cloudabi64/cloudabi64_module.c
@@ -63,10 +63,10 @@ cloudabi64_copyout_strings(struct image_params *imgp)
int
cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
{
- char canarybuf[64];
+ char canarybuf[64], pidbuf[16];
Elf64_Auxargs *args;
struct thread *td;
- void *argdata, *canary;
+ void *argdata, *canary, *pid;
size_t argdatalen;
int error;
@@ -79,8 +79,9 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
td = curthread;
td->td_proc->p_osrel = __FreeBSD_version;
- /* Store canary for stack smashing protection. */
argdata = *stack_base;
+
+ /* Store canary for stack smashing protection. */
arc4rand(canarybuf, sizeof(canarybuf), 0);
*stack_base -= howmany(sizeof(canarybuf), sizeof(register_t));
canary = *stack_base;
@@ -89,6 +90,20 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
return (error);
/*
+ * Generate a random UUID that identifies the process. Right now
+ * we don't store this UUID in the kernel. Ideally, it should be
+ * exposed through ps(1).
+ */
+ arc4rand(pidbuf, sizeof(pidbuf), 0);
+ pidbuf[6] = (pidbuf[6] & 0x0f) | 0x40;
+ pidbuf[8] = (pidbuf[8] & 0x3f) | 0x80;
+ *stack_base -= howmany(sizeof(pidbuf), sizeof(register_t));
+ pid = *stack_base;
+ error = copyout(pidbuf, pid, sizeof(pidbuf));
+ if (error != 0)
+ return (error);
+
+ /*
* Compute length of program arguments. As the argument data is
* binary safe, we had to add a trailing null byte in
* exec_copyin_data_fds(). Undo this by reducing the length.
@@ -111,9 +126,10 @@ cloudabi64_fixup(register_t **stack_base, struct image_params *imgp)
VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
- VAL(CLOUDABI_AT_TID, td->td_tid),
+ PTR(CLOUDABI_AT_PID, pid),
PTR(CLOUDABI_AT_SYSINFO_EHDR,
imgp->proc->p_sysent->sv_shared_page_base),
+ VAL(CLOUDABI_AT_TID, td->td_tid),
#undef VAL
#undef PTR
{ .a_type = CLOUDABI_AT_NULL },
diff --git a/sys/compat/cloudabi64/cloudabi64_poll.c b/sys/compat/cloudabi64/cloudabi64_poll.c
index 2b80d7af6b62..52950928b27c 100644
--- a/sys/compat/cloudabi64/cloudabi64_poll.c
+++ b/sys/compat/cloudabi64/cloudabi64_poll.c
@@ -78,7 +78,7 @@ convert_signal(int sig)
struct cloudabi64_kevent_args {
const cloudabi64_subscription_t *in;
- cloudabi64_event_t *out;
+ cloudabi_event_t *out;
};
/* Converts CloudABI's subscription objects to FreeBSD's struct kevent. */
@@ -145,7 +145,7 @@ cloudabi64_kevent_copyin(void *arg, struct kevent *kevp, int count)
static int
cloudabi64_kevent_copyout(void *arg, struct kevent *kevp, int count)
{
- cloudabi64_event_t ev;
+ cloudabi_event_t ev;
struct cloudabi64_kevent_args *args;
int error;
@@ -157,19 +157,15 @@ cloudabi64_kevent_copyout(void *arg, struct kevent *kevp, int count)
switch (kevp->filter) {
case EVFILT_TIMER:
ev.type = CLOUDABI_EVENTTYPE_CLOCK;
- ev.clock.identifier = kevp->ident;
break;
case EVFILT_READ:
ev.type = CLOUDABI_EVENTTYPE_FD_READ;
- ev.fd_readwrite.fd = kevp->ident;
break;
case EVFILT_WRITE:
ev.type = CLOUDABI_EVENTTYPE_FD_WRITE;
- ev.fd_readwrite.fd = kevp->ident;
break;
case EVFILT_PROCDESC:
ev.type = CLOUDABI_EVENTTYPE_PROC_TERMINATE;
- ev.proc_terminate.fd = kevp->ident;
break;
}
@@ -231,7 +227,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
*/
if (uap->nsubscriptions == 1) {
cloudabi64_subscription_t sub;
- cloudabi64_event_t ev = {};
+ cloudabi_event_t ev = {};
int error;
error = copyin(uap->in, &sub, sizeof(sub));
@@ -241,7 +237,6 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
ev.type = sub.type;
if (sub.type == CLOUDABI_EVENTTYPE_CONDVAR) {
/* Wait on a condition variable. */
- ev.condvar.condvar = sub.condvar.condvar;
ev.error = cloudabi_convert_errno(
cloudabi_futex_condvar_wait(
td, TO_PTR(sub.condvar.condvar),
@@ -253,7 +248,6 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
return (copyout(&ev, uap->out, sizeof(ev)));
} else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_RDLOCK) {
/* Acquire a read lock. */
- ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_rdlock(
td, TO_PTR(sub.lock.lock),
@@ -263,7 +257,6 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
return (copyout(&ev, uap->out, sizeof(ev)));
} else if (sub.type == CLOUDABI_EVENTTYPE_LOCK_WRLOCK) {
/* Acquire a write lock. */
- ev.lock.lock = sub.lock.lock;
ev.error = cloudabi_convert_errno(
cloudabi_futex_lock_wrlock(
td, TO_PTR(sub.lock.lock),
@@ -274,7 +267,7 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
}
} else if (uap->nsubscriptions == 2) {
cloudabi64_subscription_t sub[2];
- cloudabi64_event_t ev[2] = {};
+ cloudabi_event_t ev[2] = {};
int error;
error = copyin(uap->in, &sub, sizeof(sub));
@@ -288,8 +281,6 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Wait for a condition variable with timeout. */
- ev[0].condvar.condvar = sub[0].condvar.condvar;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_condvar_wait(
td, TO_PTR(sub[0].condvar.condvar),
sub[0].condvar.condvar_scope,
@@ -309,8 +300,6 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Acquire a read lock with a timeout. */
- ev[0].lock.lock = sub[0].lock.lock;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_rdlock(
td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
@@ -328,8 +317,6 @@ cloudabi64_sys_poll(struct thread *td, struct cloudabi64_sys_poll_args *uap)
sub[1].type == CLOUDABI_EVENTTYPE_CLOCK &&
sub[1].clock.flags == CLOUDABI_SUBSCRIPTION_CLOCK_ABSTIME) {
/* Acquire a write lock with a timeout. */
- ev[0].lock.lock = sub[0].lock.lock;
- ev[1].clock.identifier = sub[1].clock.identifier;
error = cloudabi_futex_lock_wrlock(
td, TO_PTR(sub[0].lock.lock),
sub[0].lock.lock_scope, sub[1].clock.clock_id,
diff --git a/sys/compat/cloudabi64/cloudabi64_proto.h b/sys/compat/cloudabi64/cloudabi64_proto.h
index 2f0302f9aa11..acaf078d7b09 100644
--- a/sys/compat/cloudabi64/cloudabi64_proto.h
+++ b/sys/compat/cloudabi64/cloudabi64_proto.h
@@ -224,7 +224,7 @@ struct cloudabi_sys_mem_unmap_args {
};
struct cloudabi64_sys_poll_args {
char in_l_[PADL_(const cloudabi64_subscription_t *)]; const cloudabi64_subscription_t * in; char in_r_[PADR_(const cloudabi64_subscription_t *)];
- char out_l_[PADL_(cloudabi64_event_t *)]; cloudabi64_event_t * out; char out_r_[PADR_(cloudabi64_event_t *)];
+ char out_l_[PADL_(cloudabi_event_t *)]; cloudabi_event_t * out; char out_r_[PADR_(cloudabi_event_t *)];
char nsubscriptions_l_[PADL_(size_t)]; size_t nsubscriptions; char nsubscriptions_r_[PADR_(size_t)];
};
struct cloudabi_sys_proc_exec_args {
diff --git a/sys/compat/cloudabi64/cloudabi64_systrace_args.c b/sys/compat/cloudabi64/cloudabi64_systrace_args.c
index 6dc8fc77163a..b2bbbfa06f08 100644
--- a/sys/compat/cloudabi64/cloudabi64_systrace_args.c
+++ b/sys/compat/cloudabi64/cloudabi64_systrace_args.c
@@ -352,7 +352,7 @@ systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)
case 37: {
struct cloudabi64_sys_poll_args *p = params;
uarg[0] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */
- uarg[1] = (intptr_t) p->out; /* cloudabi64_event_t * */
+ uarg[1] = (intptr_t) p->out; /* cloudabi_event_t * */
uarg[2] = p->nsubscriptions; /* size_t */
*n_args = 3;
break;
@@ -1062,7 +1062,7 @@ systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)
p = "userland const cloudabi64_subscription_t *";
break;
case 1:
- p = "userland cloudabi64_event_t *";
+ p = "userland cloudabi_event_t *";
break;
case 2:
p = "size_t";
diff --git a/sys/contrib/cloudabi/cloudabi32_types.h b/sys/contrib/cloudabi/cloudabi32_types.h
index 58f4d7cb9bb0..d685e42c0335 100644
--- a/sys/contrib/cloudabi/cloudabi32_types.h
+++ b/sys/contrib/cloudabi/cloudabi32_types.h
@@ -53,47 +53,6 @@ _Static_assert(sizeof(cloudabi32_ciovec_t) == 8, "Incorrect layout");
_Static_assert(_Alignof(cloudabi32_ciovec_t) == 4, "Incorrect layout");
typedef struct {
- _Alignas(8) cloudabi_userdata_t userdata;
- _Alignas(2) cloudabi_errno_t error;
- _Alignas(1) cloudabi_eventtype_t type;
- union {
- struct {
- _Alignas(8) cloudabi_userdata_t identifier;
- } clock;
- struct {
- _Alignas(4) uint32_t condvar;
- } condvar;
- struct {
- _Alignas(8) cloudabi_filesize_t nbytes;
- _Alignas(4) cloudabi_fd_t fd;
- _Alignas(2) cloudabi_eventrwflags_t flags;
- } fd_readwrite;
- struct {
- _Alignas(4) uint32_t lock;
- } lock;
- struct {
- _Alignas(4) cloudabi_fd_t fd;
- _Alignas(1) cloudabi_signal_t signal;
- _Alignas(4) cloudabi_exitcode_t exitcode;
- } proc_terminate;
- };
-} cloudabi32_event_t;
-_Static_assert(offsetof(cloudabi32_event_t, userdata) == 0, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, error) == 8, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, type) == 10, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, clock.identifier) == 16, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, condvar.condvar) == 16, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, fd_readwrite.nbytes) == 16, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, fd_readwrite.fd) == 24, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, fd_readwrite.flags) == 28, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, lock.lock) == 16, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, proc_terminate.fd) == 16, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, proc_terminate.signal) == 20, "Incorrect layout");
-_Static_assert(offsetof(cloudabi32_event_t, proc_terminate.exitcode) == 24, "Incorrect layout");
-_Static_assert(sizeof(cloudabi32_event_t) == 32, "Incorrect layout");
-_Static_assert(_Alignof(cloudabi32_event_t) == 8, "Incorrect layout");
-
-typedef struct {
_Alignas(4) uint32_t buf;
_Alignas(4) uint32_t buf_len;
} cloudabi32_iovec_t;
diff --git a/sys/contrib/cloudabi/cloudabi64_types.h b/sys/contrib/cloudabi/cloudabi64_types.h
index f45ad81e8b38..da1629b8a74c 100644
--- a/sys/contrib/cloudabi/cloudabi64_types.h
+++ b/sys/contrib/cloudabi/cloudabi64_types.h
@@ -53,47 +53,6 @@ _Static_assert(sizeof(cloudabi64_ciovec_t) == 16, "Incorrect layout");
_Static_assert(_Alignof(cloudabi64_ciovec_t) == 8, "Incorrect layout");
typedef struct {
- _Alignas(8) cloudabi_userdata_t userdata;
- _Alignas(2) cloudabi_errno_t error;
- _Alignas(1) cloudabi_eventtype_t type;
- union {
- struct {
- _Alignas(8) cloudabi_userdata_t identifier;
- } clock;
- struct {
- _Alignas(8) uint64_t condvar;
- } condvar;
- struct {
- _Alignas(8) cloudabi_filesize_t nbytes;
- _Alignas(4) cloudabi_fd_t fd;
- _Alignas(2) cloudabi_eventrwflags_t flags;
- } fd_readwrite;
- struct {
- _Alignas(8) uint64_t lock;
- } lock;
- struct {
- _Alignas(4) cloudabi_fd_t fd;
- _Alignas(1) cloudabi_signal_t signal;
- _Alignas(4) cloudabi_exitcode_t exitcode;
- } proc_terminate;
- };
-} cloudabi64_event_t;
-_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(sizeof(cloudabi64_event_t) == 32, "Incorrect layout");
-_Static_assert(_Alignof(cloudabi64_event_t) == 8, "Incorrect layout");
-
-typedef struct {
_Alignas(8) uint64_t buf;
_Alignas(8) uint64_t buf_len;
} cloudabi64_iovec_t;
diff --git a/sys/contrib/cloudabi/cloudabi_types_common.h b/sys/contrib/cloudabi/cloudabi_types_common.h
index 1c403b00d330..db723a3badbf 100644
--- a/sys/contrib/cloudabi/cloudabi_types_common.h
+++ b/sys/contrib/cloudabi/cloudabi_types_common.h
@@ -56,6 +56,7 @@ typedef uint32_t cloudabi_auxtype_t;
#define CLOUDABI_AT_PAGESZ 6
#define CLOUDABI_AT_PHDR 3
#define CLOUDABI_AT_PHNUM 4
+#define CLOUDABI_AT_PID 263
#define CLOUDABI_AT_SYSINFO_EHDR 262
#define CLOUDABI_AT_TID 261
@@ -353,6 +354,35 @@ _Static_assert(sizeof(cloudabi_dirent_t) == 24, "Incorrect layout");
_Static_assert(_Alignof(cloudabi_dirent_t) == 8, "Incorrect layout");
typedef struct {
+ _Alignas(8) cloudabi_userdata_t userdata;
+ _Alignas(2) cloudabi_errno_t error;
+ _Alignas(1) cloudabi_eventtype_t type;
+ union {
+ struct {
+ _Alignas(8) cloudabi_filesize_t nbytes;
+ _Alignas(1) char unused[4];
+ _Alignas(2) cloudabi_eventrwflags_t flags;
+ } fd_readwrite;
+ struct {
+ _Alignas(1) char unused[4];
+ _Alignas(1) cloudabi_signal_t signal;
+ _Alignas(4) cloudabi_exitcode_t exitcode;
+ } proc_terminate;
+ };
+} cloudabi_event_t;
+_Static_assert(offsetof(cloudabi_event_t, userdata) == 0, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, error) == 8, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, type) == 10, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, fd_readwrite.nbytes) == 16, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, fd_readwrite.unused) == 24, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, fd_readwrite.flags) == 28, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, proc_terminate.unused) == 16, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, proc_terminate.signal) == 20, "Incorrect layout");
+_Static_assert(offsetof(cloudabi_event_t, proc_terminate.exitcode) == 24, "Incorrect layout");
+_Static_assert(sizeof(cloudabi_event_t) == 32, "Incorrect layout");
+_Static_assert(_Alignof(cloudabi_event_t) == 8, "Incorrect layout");
+
+typedef struct {
_Alignas(1) cloudabi_filetype_t fs_filetype;
_Alignas(2) cloudabi_fdflags_t fs_flags;
_Alignas(8) cloudabi_rights_t fs_rights_base;
diff --git a/sys/contrib/cloudabi/syscalls32.master b/sys/contrib/cloudabi/syscalls32.master
index 0d6eb94fb0d3..4e37300f81d1 100644
--- a/sys/contrib/cloudabi/syscalls32.master
+++ b/sys/contrib/cloudabi/syscalls32.master
@@ -228,7 +228,7 @@
37 AUE_NULL STD { size_t cloudabi32_sys_poll( \
const cloudabi32_subscription_t *in, \
- cloudabi32_event_t *out, \
+ cloudabi_event_t *out, \
size_t nsubscriptions); }
38 AUE_NULL STD { void cloudabi_sys_proc_exec( \
diff --git a/sys/contrib/cloudabi/syscalls64.master b/sys/contrib/cloudabi/syscalls64.master
index 678598aff338..c9bc9fc4f55c 100644
--- a/sys/contrib/cloudabi/syscalls64.master
+++ b/sys/contrib/cloudabi/syscalls64.master
@@ -228,7 +228,7 @@
37 AUE_NULL STD { size_t cloudabi64_sys_poll( \
const cloudabi64_subscription_t *in, \
- cloudabi64_event_t *out, \
+ cloudabi_event_t *out, \
size_t nsubscriptions); }
38 AUE_NULL STD { void cloudabi_sys_proc_exec( \