Index: head/sys/compat/cloudabi/cloudabi_futex.c =================================================================== --- head/sys/compat/cloudabi/cloudabi_futex.c (revision 297467) +++ head/sys/compat/cloudabi/cloudabi_futex.c (revision 297468) @@ -1,1162 +1,1162 @@ /*- * Copyright (c) 2015 Nuxi, https://nuxi.nl/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include #include #include /* * Futexes for CloudABI. * * On most systems, futexes are implemented as objects of a single type * on which a set of operations can be performed. CloudABI makes a clear * distinction between locks and condition variables. A lock may have * zero or more associated condition variables. A condition variable is * always associated with exactly one lock. There is a strict topology. * This approach has two advantages: * * - This topology is guaranteed to be acyclic. Requeueing of threads * only happens in one direction (from condition variables to locks). * This eases locking. * - It means that a futex object for a lock exists when it is unlocked, * but has threads waiting on associated condition variables. Threads * can be requeued to a lock even if the thread performing the wakeup * does not have the lock mapped in its address space. * * This futex implementation only implements a single lock type, namely * a read-write lock. A regular mutex type would not be necessary, as * the read-write lock is as efficient as a mutex if used as such. * Userspace futex locks are 32 bits in size: * * - 1 bit: has threads waiting in kernel-space. * - 1 bit: is write-locked. * - 30 bits: * - if write-locked: thread ID of owner. * - if not write-locked: number of read locks held. * * Condition variables are also 32 bits in size. Its value is modified * by kernel-space exclusively. Zero indicates that it has no waiting * threads. Non-zero indicates the opposite. * * This implementation is optimal, in the sense that it only wakes up * threads if they can actually continue execution. It does not suffer * from the thundering herd problem. If multiple threads waiting on a * condition variable need to be woken up, only a single thread is * scheduled. All other threads are 'donated' to this thread. After the * thread manages to reacquire the lock, it requeues its donated threads * to the lock. * * TODO(ed): Integrate this functionality into kern_umtx.c instead. * TODO(ed): Store futex objects in a hash table. * TODO(ed): Add actual priority inheritance. * TODO(ed): Let futex_queue also take priorities into account. * TODO(ed): Make locking fine-grained. * TODO(ed): Perform sleeps until an actual absolute point in time, * instead of converting the timestamp to a relative value. */ struct futex_address; struct futex_condvar; struct futex_lock; struct futex_queue; struct futex_waiter; /* Identifier of a location in memory. */ struct futex_address { struct umtx_key fa_key; }; /* A set of waiting threads. */ struct futex_queue { STAILQ_HEAD(, futex_waiter) fq_list; unsigned int fq_count; }; /* Condition variables. */ struct futex_condvar { /* Address of the condition variable. */ struct futex_address fc_address; /* The lock the waiters should be moved to when signalled. */ struct futex_lock * fc_lock; /* Threads waiting on the condition variable. */ struct futex_queue fc_waiters; /* * Number of threads blocked on this condition variable, or * being blocked on the lock after being requeued. */ unsigned int fc_waitcount; /* Global list pointers. */ LIST_ENTRY(futex_condvar) fc_next; }; /* Read-write locks. */ struct futex_lock { /* Address of the lock. */ struct futex_address fl_address; /* * Current owner of the lock. LOCK_UNMANAGED if the lock is * currently not owned by the kernel. LOCK_OWNER_UNKNOWN in case * the owner is not known (e.g., when the lock is read-locked). */ cloudabi_tid_t fl_owner; #define LOCK_UNMANAGED 0x0 #define LOCK_OWNER_UNKNOWN 0x1 /* Writers blocked on the lock. */ struct futex_queue fl_writers; /* Readers blocked on the lock. */ struct futex_queue fl_readers; /* Number of threads blocked on this lock + condition variables. */ unsigned int fl_waitcount; /* Global list pointers. */ LIST_ENTRY(futex_lock) fl_next; }; /* Information associated with a thread blocked on an object. */ struct futex_waiter { /* Thread ID. */ cloudabi_tid_t fw_tid; /* Condition variable used for waiting. */ struct cv fw_wait; /* Queue this waiter is currently placed in. */ struct futex_queue * fw_queue; /* List pointers of fw_queue. */ STAILQ_ENTRY(futex_waiter) fw_next; /* Lock has been acquired. */ bool fw_locked; /* If not locked, threads that should block after acquiring. */ struct futex_queue fw_donated; }; /* Global data structures. */ static MALLOC_DEFINE(M_FUTEX, "futex", "CloudABI futex"); static struct sx futex_global_lock; SX_SYSINIT(futex_global_lock, &futex_global_lock, "CloudABI futex global lock"); static LIST_HEAD(, futex_lock) futex_lock_list = LIST_HEAD_INITIALIZER(&futex_lock_list); static LIST_HEAD(, futex_condvar) futex_condvar_list = LIST_HEAD_INITIALIZER(&futex_condvar_list); /* Utility functions. */ static void futex_lock_assert(const struct futex_lock *); static struct futex_lock *futex_lock_lookup_locked(struct futex_address *); static void futex_lock_release(struct futex_lock *); static int futex_lock_tryrdlock(struct futex_lock *, cloudabi_lock_t *); static int futex_lock_unmanage(struct futex_lock *, cloudabi_lock_t *); static int futex_lock_update_owner(struct futex_lock *, cloudabi_lock_t *); static int futex_lock_wake_up_next(struct futex_lock *, cloudabi_lock_t *); static unsigned int futex_queue_count(const struct futex_queue *); static void futex_queue_init(struct futex_queue *); static void futex_queue_requeue(struct futex_queue *, struct futex_queue *, unsigned int); static int futex_queue_sleep(struct futex_queue *, struct futex_lock *, struct futex_waiter *, struct thread *, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); static cloudabi_tid_t futex_queue_tid_best(const struct futex_queue *); static void futex_queue_wake_up_all(struct futex_queue *); static void futex_queue_wake_up_best(struct futex_queue *); static void futex_queue_wake_up_donate(struct futex_queue *, unsigned int); static int futex_user_load(uint32_t *, uint32_t *); static int futex_user_store(uint32_t *, uint32_t); static int futex_user_cmpxchg(uint32_t *, uint32_t, uint32_t *, uint32_t); /* * futex_address operations. */ static int futex_address_create(struct futex_address *fa, struct thread *td, - const void *object, cloudabi_mflags_t scope) + const void *object, cloudabi_scope_t scope) { KASSERT(td == curthread, ("Can only create umtx keys for the current thread")); switch (scope) { - case CLOUDABI_MAP_PRIVATE: + case CLOUDABI_SCOPE_PRIVATE: return (umtx_key_get(object, TYPE_FUTEX, THREAD_SHARE, &fa->fa_key)); - case CLOUDABI_MAP_SHARED: + case CLOUDABI_SCOPE_SHARED: return (umtx_key_get(object, TYPE_FUTEX, AUTO_SHARE, &fa->fa_key)); default: return (EINVAL); } } static void futex_address_free(struct futex_address *fa) { umtx_key_release(&fa->fa_key); } static bool futex_address_match(const struct futex_address *fa1, const struct futex_address *fa2) { return (umtx_key_match(&fa1->fa_key, &fa2->fa_key)); } /* * futex_condvar operations. */ static void futex_condvar_assert(const struct futex_condvar *fc) { KASSERT(fc->fc_waitcount >= futex_queue_count(&fc->fc_waiters), ("Total number of waiters cannot be smaller than the wait queue")); futex_lock_assert(fc->fc_lock); } static int futex_condvar_lookup(struct thread *td, const cloudabi_condvar_t *address, - cloudabi_mflags_t scope, struct futex_condvar **fcret) + cloudabi_scope_t scope, struct futex_condvar **fcret) { struct futex_address fa_condvar; struct futex_condvar *fc; int error; error = futex_address_create(&fa_condvar, td, address, scope); if (error != 0) return (error); sx_xlock(&futex_global_lock); LIST_FOREACH(fc, &futex_condvar_list, fc_next) { if (futex_address_match(&fc->fc_address, &fa_condvar)) { /* Found matching lock object. */ futex_address_free(&fa_condvar); futex_condvar_assert(fc); *fcret = fc; return (0); } } sx_xunlock(&futex_global_lock); futex_address_free(&fa_condvar); return (ENOENT); } static int futex_condvar_lookup_or_create(struct thread *td, - const cloudabi_condvar_t *condvar, cloudabi_mflags_t condvar_scope, - const cloudabi_lock_t *lock, cloudabi_mflags_t lock_scope, + const cloudabi_condvar_t *condvar, cloudabi_scope_t condvar_scope, + const cloudabi_lock_t *lock, cloudabi_scope_t lock_scope, struct futex_condvar **fcret) { struct futex_address fa_condvar, fa_lock; struct futex_condvar *fc; struct futex_lock *fl; int error; error = futex_address_create(&fa_condvar, td, condvar, condvar_scope); if (error != 0) return (error); error = futex_address_create(&fa_lock, td, lock, lock_scope); if (error != 0) { futex_address_free(&fa_condvar); return (error); } sx_xlock(&futex_global_lock); LIST_FOREACH(fc, &futex_condvar_list, fc_next) { if (!futex_address_match(&fc->fc_address, &fa_condvar)) continue; fl = fc->fc_lock; if (!futex_address_match(&fl->fl_address, &fa_lock)) { /* Condition variable is owned by a different lock. */ futex_address_free(&fa_condvar); futex_address_free(&fa_lock); sx_xunlock(&futex_global_lock); return (EINVAL); } /* Found fully matching condition variable. */ futex_address_free(&fa_condvar); futex_address_free(&fa_lock); futex_condvar_assert(fc); *fcret = fc; return (0); } /* None found. Create new condition variable object. */ fc = malloc(sizeof(*fc), M_FUTEX, M_WAITOK); fc->fc_address = fa_condvar; fc->fc_lock = futex_lock_lookup_locked(&fa_lock); futex_queue_init(&fc->fc_waiters); fc->fc_waitcount = 0; LIST_INSERT_HEAD(&futex_condvar_list, fc, fc_next); *fcret = fc; return (0); } static void futex_condvar_release(struct futex_condvar *fc) { struct futex_lock *fl; futex_condvar_assert(fc); fl = fc->fc_lock; if (fc->fc_waitcount == 0) { /* Condition variable has no waiters. Deallocate it. */ futex_address_free(&fc->fc_address); LIST_REMOVE(fc, fc_next); free(fc, M_FUTEX); } futex_lock_release(fl); } static int futex_condvar_unmanage(struct futex_condvar *fc, cloudabi_condvar_t *condvar) { if (futex_queue_count(&fc->fc_waiters) != 0) return (0); return (futex_user_store(condvar, CLOUDABI_CONDVAR_HAS_NO_WAITERS)); } /* * futex_lock operations. */ static void futex_lock_assert(const struct futex_lock *fl) { /* * A futex lock can only be kernel-managed if it has waiters. * Vice versa: if a futex lock has waiters, it must be * kernel-managed. */ KASSERT((fl->fl_owner == LOCK_UNMANAGED) == (futex_queue_count(&fl->fl_readers) == 0 && futex_queue_count(&fl->fl_writers) == 0), ("Managed locks must have waiting threads")); KASSERT(fl->fl_waitcount != 0 || fl->fl_owner == LOCK_UNMANAGED, ("Lock with no waiters must be unmanaged")); } static int futex_lock_lookup(struct thread *td, const cloudabi_lock_t *address, - cloudabi_mflags_t scope, struct futex_lock **flret) + cloudabi_scope_t scope, struct futex_lock **flret) { struct futex_address fa; int error; error = futex_address_create(&fa, td, address, scope); if (error != 0) return (error); sx_xlock(&futex_global_lock); *flret = futex_lock_lookup_locked(&fa); return (0); } static struct futex_lock * futex_lock_lookup_locked(struct futex_address *fa) { struct futex_lock *fl; LIST_FOREACH(fl, &futex_lock_list, fl_next) { if (futex_address_match(&fl->fl_address, fa)) { /* Found matching lock object. */ futex_address_free(fa); futex_lock_assert(fl); return (fl); } } /* None found. Create new lock object. */ fl = malloc(sizeof(*fl), M_FUTEX, M_WAITOK); fl->fl_address = *fa; fl->fl_owner = LOCK_UNMANAGED; futex_queue_init(&fl->fl_readers); futex_queue_init(&fl->fl_writers); fl->fl_waitcount = 0; LIST_INSERT_HEAD(&futex_lock_list, fl, fl_next); return (fl); } static int futex_lock_rdlock(struct futex_lock *fl, struct thread *td, cloudabi_lock_t *lock, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision) { struct futex_waiter fw; int error; error = futex_lock_tryrdlock(fl, lock); if (error == EBUSY) { /* Suspend execution. */ KASSERT(fl->fl_owner != LOCK_UNMANAGED, ("Attempted to sleep on an unmanaged lock")); error = futex_queue_sleep(&fl->fl_readers, fl, &fw, td, clock_id, timeout, precision); KASSERT((error == 0) == fw.fw_locked, ("Should have locked write lock on success")); KASSERT(futex_queue_count(&fw.fw_donated) == 0, ("Lock functions cannot receive threads")); } if (error != 0) futex_lock_unmanage(fl, lock); return (error); } static void futex_lock_release(struct futex_lock *fl) { futex_lock_assert(fl); if (fl->fl_waitcount == 0) { /* Lock object is unreferenced. Deallocate it. */ KASSERT(fl->fl_owner == LOCK_UNMANAGED, ("Attempted to free a managed lock")); futex_address_free(&fl->fl_address); LIST_REMOVE(fl, fl_next); free(fl, M_FUTEX); } sx_xunlock(&futex_global_lock); } static int futex_lock_unmanage(struct futex_lock *fl, cloudabi_lock_t *lock) { cloudabi_lock_t cmp, old; int error; if (futex_queue_count(&fl->fl_readers) == 0 && futex_queue_count(&fl->fl_writers) == 0) { /* Lock should be unmanaged. */ fl->fl_owner = LOCK_UNMANAGED; /* Clear kernel-managed bit. */ error = futex_user_load(lock, &old); if (error != 0) return (error); for (;;) { cmp = old; error = futex_user_cmpxchg(lock, cmp, &old, cmp & ~CLOUDABI_LOCK_KERNEL_MANAGED); if (error != 0) return (error); if (old == cmp) break; } } return (0); } /* Sets an owner of a lock, based on a userspace lock value. */ static void futex_lock_set_owner(struct futex_lock *fl, cloudabi_lock_t lock) { /* Lock has no explicit owner. */ if ((lock & ~CLOUDABI_LOCK_WRLOCKED) == 0) { fl->fl_owner = LOCK_OWNER_UNKNOWN; return; } lock &= ~(CLOUDABI_LOCK_WRLOCKED | CLOUDABI_LOCK_KERNEL_MANAGED); /* Don't allow userspace to silently unlock. */ if (lock == LOCK_UNMANAGED) { fl->fl_owner = LOCK_OWNER_UNKNOWN; return; } fl->fl_owner = lock; } static int futex_lock_unlock(struct futex_lock *fl, struct thread *td, cloudabi_lock_t *lock) { int error; /* Validate that this thread is allowed to unlock. */ error = futex_lock_update_owner(fl, lock); if (error != 0) return (error); if (fl->fl_owner != LOCK_UNMANAGED && fl->fl_owner != td->td_tid) return (EPERM); return (futex_lock_wake_up_next(fl, lock)); } /* Syncs in the owner of the lock from userspace if needed. */ static int futex_lock_update_owner(struct futex_lock *fl, cloudabi_lock_t *address) { cloudabi_lock_t lock; int error; if (fl->fl_owner == LOCK_OWNER_UNKNOWN) { error = futex_user_load(address, &lock); if (error != 0) return (error); futex_lock_set_owner(fl, lock); } return (0); } static int futex_lock_tryrdlock(struct futex_lock *fl, cloudabi_lock_t *address) { cloudabi_lock_t old, cmp; int error; if (fl->fl_owner != LOCK_UNMANAGED) { /* Lock is already acquired. */ return (EBUSY); } old = CLOUDABI_LOCK_UNLOCKED; for (;;) { if ((old & CLOUDABI_LOCK_KERNEL_MANAGED) != 0) { /* * Userspace lock is kernel-managed, even though * the kernel disagrees. */ return (EINVAL); } if ((old & CLOUDABI_LOCK_WRLOCKED) == 0) { /* * Lock is not write-locked. Attempt to acquire * it by increasing the read count. */ cmp = old; error = futex_user_cmpxchg(address, cmp, &old, cmp + 1); if (error != 0) return (error); if (old == cmp) { /* Success. */ return (0); } } else { /* Lock is write-locked. Make it kernel-managed. */ cmp = old; error = futex_user_cmpxchg(address, cmp, &old, cmp | CLOUDABI_LOCK_KERNEL_MANAGED); if (error != 0) return (error); if (old == cmp) { /* Success. */ futex_lock_set_owner(fl, cmp); return (EBUSY); } } } } static int futex_lock_trywrlock(struct futex_lock *fl, cloudabi_lock_t *address, cloudabi_tid_t tid, bool force_kernel_managed) { cloudabi_lock_t old, new, cmp; int error; if (fl->fl_owner == tid) { /* Attempted to acquire lock recursively. */ return (EDEADLK); } if (fl->fl_owner != LOCK_UNMANAGED) { /* Lock is already acquired. */ return (EBUSY); } old = CLOUDABI_LOCK_UNLOCKED; for (;;) { if ((old & CLOUDABI_LOCK_KERNEL_MANAGED) != 0) { /* * Userspace lock is kernel-managed, even though * the kernel disagrees. */ return (EINVAL); } if (old == (tid | CLOUDABI_LOCK_WRLOCKED)) { /* Attempted to acquire lock recursively. */ return (EDEADLK); } if (old == CLOUDABI_LOCK_UNLOCKED) { /* Lock is unlocked. Attempt to acquire it. */ new = tid | CLOUDABI_LOCK_WRLOCKED; if (force_kernel_managed) new |= CLOUDABI_LOCK_KERNEL_MANAGED; error = futex_user_cmpxchg(address, CLOUDABI_LOCK_UNLOCKED, &old, new); if (error != 0) return (error); if (old == CLOUDABI_LOCK_UNLOCKED) { /* Success. */ if (force_kernel_managed) fl->fl_owner = tid; return (0); } } else { /* Lock is still locked. Make it kernel-managed. */ cmp = old; error = futex_user_cmpxchg(address, cmp, &old, cmp | CLOUDABI_LOCK_KERNEL_MANAGED); if (error != 0) return (error); if (old == cmp) { /* Success. */ futex_lock_set_owner(fl, cmp); return (EBUSY); } } } } static int futex_lock_wake_up_next(struct futex_lock *fl, cloudabi_lock_t *lock) { cloudabi_tid_t tid; int error; /* * Determine which thread(s) to wake up. Prefer waking up * writers over readers to prevent write starvation. */ if (futex_queue_count(&fl->fl_writers) > 0) { /* Transfer ownership to a single write-locker. */ if (futex_queue_count(&fl->fl_writers) > 1 || futex_queue_count(&fl->fl_readers) > 0) { /* Lock should remain managed afterwards. */ tid = futex_queue_tid_best(&fl->fl_writers); error = futex_user_store(lock, tid | CLOUDABI_LOCK_WRLOCKED | CLOUDABI_LOCK_KERNEL_MANAGED); if (error != 0) return (error); futex_queue_wake_up_best(&fl->fl_writers); fl->fl_owner = tid; } else { /* Lock can become unmanaged afterwards. */ error = futex_user_store(lock, futex_queue_tid_best(&fl->fl_writers) | CLOUDABI_LOCK_WRLOCKED); if (error != 0) return (error); futex_queue_wake_up_best(&fl->fl_writers); fl->fl_owner = LOCK_UNMANAGED; } } else { /* Transfer ownership to all read-lockers (if any). */ error = futex_user_store(lock, futex_queue_count(&fl->fl_readers)); if (error != 0) return (error); /* Wake up all threads. */ futex_queue_wake_up_all(&fl->fl_readers); fl->fl_owner = LOCK_UNMANAGED; } return (0); } static int futex_lock_wrlock(struct futex_lock *fl, struct thread *td, cloudabi_lock_t *lock, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, struct futex_queue *donated) { struct futex_waiter fw; int error; error = futex_lock_trywrlock(fl, lock, td->td_tid, futex_queue_count(donated) > 0); if (error == 0 || error == EBUSY) { /* Put donated threads in queue before suspending. */ KASSERT(futex_queue_count(donated) == 0 || fl->fl_owner != LOCK_UNMANAGED, ("Lock should be managed if we are going to donate")); futex_queue_requeue(donated, &fl->fl_writers, UINT_MAX); } else { /* * This thread cannot deal with the donated threads. * Wake up the next thread and let it try it by itself. */ futex_queue_wake_up_donate(donated, UINT_MAX); } if (error == EBUSY) { /* Suspend execution if the lock was busy. */ KASSERT(fl->fl_owner != LOCK_UNMANAGED, ("Attempted to sleep on an unmanaged lock")); error = futex_queue_sleep(&fl->fl_writers, fl, &fw, td, clock_id, timeout, precision); KASSERT((error == 0) == fw.fw_locked, ("Should have locked write lock on success")); KASSERT(futex_queue_count(&fw.fw_donated) == 0, ("Lock functions cannot receive threads")); } if (error != 0) futex_lock_unmanage(fl, lock); return (error); } /* * futex_queue operations. */ static cloudabi_tid_t futex_queue_tid_best(const struct futex_queue *fq) { return (STAILQ_FIRST(&fq->fq_list)->fw_tid); } static unsigned int futex_queue_count(const struct futex_queue *fq) { return (fq->fq_count); } static void futex_queue_init(struct futex_queue *fq) { STAILQ_INIT(&fq->fq_list); fq->fq_count = 0; } /* Converts a relative timestamp to an sbintime. */ static sbintime_t futex_queue_convert_timestamp_relative(cloudabi_timestamp_t ts) { cloudabi_timestamp_t s, ns; s = ts / 1000000000; ns = ts % 1000000000; if (s > INT32_MAX) return (INT64_MAX); return ((s << 32) + (ns << 32) / 1000000000); } /* Converts an absolute timestamp and precision to a pair of sbintime values. */ static int futex_queue_convert_timestamp(struct thread *td, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision, sbintime_t *sbttimeout, sbintime_t *sbtprecision) { cloudabi_timestamp_t now; int error; /* Make the time relative. */ error = cloudabi_clock_time_get(td, clock_id, &now); if (error != 0) return (error); timeout = timeout < now ? 0 : timeout - now; *sbttimeout = futex_queue_convert_timestamp_relative(timeout); *sbtprecision = futex_queue_convert_timestamp_relative(precision); return (0); } static int futex_queue_sleep(struct futex_queue *fq, struct futex_lock *fl, struct futex_waiter *fw, struct thread *td, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision) { sbintime_t sbttimeout, sbtprecision; int error; /* Initialize futex_waiter object. */ fw->fw_tid = td->td_tid; fw->fw_locked = false; futex_queue_init(&fw->fw_donated); if (timeout != UINT64_MAX) { /* Convert timeout duration. */ error = futex_queue_convert_timestamp(td, clock_id, timeout, precision, &sbttimeout, &sbtprecision); if (error != 0) return (error); } /* Place object in the queue. */ fw->fw_queue = fq; STAILQ_INSERT_TAIL(&fq->fq_list, fw, fw_next); ++fq->fq_count; cv_init(&fw->fw_wait, "futex"); ++fl->fl_waitcount; futex_lock_assert(fl); if (timeout == UINT64_MAX) { /* Wait without a timeout. */ error = cv_wait_sig(&fw->fw_wait, &futex_global_lock); } else { /* Wait respecting the timeout. */ error = cv_timedwait_sig_sbt(&fw->fw_wait, &futex_global_lock, sbttimeout, sbtprecision, 0); futex_lock_assert(fl); if (error == EWOULDBLOCK && fw->fw_queue != NULL && fw->fw_queue != fq) { /* * We got signalled on a condition variable, but * observed a timeout while waiting to reacquire * the lock. In other words, we didn't actually * time out. Go back to sleep and wait for the * lock to be reacquired. */ error = cv_wait_sig(&fw->fw_wait, &futex_global_lock); } } futex_lock_assert(fl); --fl->fl_waitcount; cv_destroy(&fw->fw_wait); fq = fw->fw_queue; if (fq == NULL) { /* Thread got dequeued, so we've slept successfully. */ return (0); } /* Thread is still enqueued. Remove it. */ KASSERT(error != 0, ("Woken up thread is still enqueued")); STAILQ_REMOVE(&fq->fq_list, fw, futex_waiter, fw_next); --fq->fq_count; return (error == EWOULDBLOCK ? ETIMEDOUT : error); } /* Moves up to nwaiters waiters from one queue to another. */ static void futex_queue_requeue(struct futex_queue *fqfrom, struct futex_queue *fqto, unsigned int nwaiters) { struct futex_waiter *fw; /* Move waiters to the target queue. */ while (nwaiters-- > 0 && !STAILQ_EMPTY(&fqfrom->fq_list)) { fw = STAILQ_FIRST(&fqfrom->fq_list); STAILQ_REMOVE_HEAD(&fqfrom->fq_list, fw_next); --fqfrom->fq_count; fw->fw_queue = fqto; STAILQ_INSERT_TAIL(&fqto->fq_list, fw, fw_next); ++fqto->fq_count; } } /* Wakes up all waiters in a queue. */ static void futex_queue_wake_up_all(struct futex_queue *fq) { struct futex_waiter *fw; STAILQ_FOREACH(fw, &fq->fq_list, fw_next) { fw->fw_locked = true; fw->fw_queue = NULL; cv_signal(&fw->fw_wait); } STAILQ_INIT(&fq->fq_list); fq->fq_count = 0; } /* * Wakes up the best waiter (i.e., the waiter having the highest * priority) in a queue. */ static void futex_queue_wake_up_best(struct futex_queue *fq) { struct futex_waiter *fw; fw = STAILQ_FIRST(&fq->fq_list); fw->fw_locked = true; fw->fw_queue = NULL; cv_signal(&fw->fw_wait); STAILQ_REMOVE_HEAD(&fq->fq_list, fw_next); --fq->fq_count; } static void futex_queue_wake_up_donate(struct futex_queue *fq, unsigned int nwaiters) { struct futex_waiter *fw; fw = STAILQ_FIRST(&fq->fq_list); if (fw == NULL) return; fw->fw_locked = false; fw->fw_queue = NULL; cv_signal(&fw->fw_wait); STAILQ_REMOVE_HEAD(&fq->fq_list, fw_next); --fq->fq_count; futex_queue_requeue(fq, &fw->fw_donated, nwaiters); } /* * futex_user operations. Used to adjust values in userspace. */ static int futex_user_load(uint32_t *obj, uint32_t *val) { return (fueword32(obj, val) != 0 ? EFAULT : 0); } static int futex_user_store(uint32_t *obj, uint32_t val) { return (suword32(obj, val) != 0 ? EFAULT : 0); } static int futex_user_cmpxchg(uint32_t *obj, uint32_t cmp, uint32_t *old, uint32_t new) { return (casueword32(obj, cmp, old, new) != 0 ? EFAULT : 0); } /* * Blocking calls: acquiring locks, waiting on condition variables. */ int cloudabi_futex_condvar_wait(struct thread *td, cloudabi_condvar_t *condvar, - cloudabi_mflags_t condvar_scope, cloudabi_lock_t *lock, - cloudabi_mflags_t lock_scope, cloudabi_clockid_t clock_id, + cloudabi_scope_t condvar_scope, cloudabi_lock_t *lock, + cloudabi_scope_t lock_scope, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision) { struct futex_condvar *fc; struct futex_lock *fl; struct futex_waiter fw; int error, error2; /* Lookup condition variable object. */ error = futex_condvar_lookup_or_create(td, condvar, condvar_scope, lock, lock_scope, &fc); if (error != 0) return (error); fl = fc->fc_lock; /* * Set the condition variable to something other than * CLOUDABI_CONDVAR_HAS_NO_WAITERS to make userspace threads * call into the kernel to perform wakeups. */ error = futex_user_store(condvar, ~CLOUDABI_CONDVAR_HAS_NO_WAITERS); if (error != 0) { futex_condvar_release(fc); return (error); } /* Drop the lock. */ error = futex_lock_unlock(fl, td, lock); if (error != 0) { futex_condvar_unmanage(fc, condvar); futex_condvar_release(fc); return (error); } /* Go to sleep. */ ++fc->fc_waitcount; error = futex_queue_sleep(&fc->fc_waiters, fc->fc_lock, &fw, td, clock_id, timeout, precision); if (fw.fw_locked) { /* Waited and got the lock assigned to us. */ KASSERT(futex_queue_count(&fw.fw_donated) == 0, ("Received threads while being locked")); } else if (error == 0 || error == ETIMEDOUT) { if (error != 0) futex_condvar_unmanage(fc, condvar); /* * Got woken up without having the lock assigned to us. * This can happen in two cases: * * 1. We observed a timeout on a condition variable. * 2. We got signalled on a condition variable while the * associated lock is unlocked. We are the first * thread that gets woken up. This thread is * responsible for reacquiring the userspace lock. */ error2 = futex_lock_wrlock(fl, td, lock, CLOUDABI_CLOCK_MONOTONIC, UINT64_MAX, 0, &fw.fw_donated); if (error2 != 0) error = error2; } else { KASSERT(futex_queue_count(&fw.fw_donated) == 0, ("Received threads on error")); futex_condvar_unmanage(fc, condvar); futex_lock_unmanage(fl, lock); } --fc->fc_waitcount; futex_condvar_release(fc); return (error); } int cloudabi_futex_lock_rdlock(struct thread *td, cloudabi_lock_t *lock, - cloudabi_mflags_t scope, cloudabi_clockid_t clock_id, + cloudabi_scope_t scope, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision) { struct futex_lock *fl; int error; /* Look up lock object. */ error = futex_lock_lookup(td, lock, scope, &fl); if (error != 0) return (error); error = futex_lock_rdlock(fl, td, lock, clock_id, timeout, precision); futex_lock_release(fl); return (error); } int cloudabi_futex_lock_wrlock(struct thread *td, cloudabi_lock_t *lock, - cloudabi_mflags_t scope, cloudabi_clockid_t clock_id, + cloudabi_scope_t scope, cloudabi_clockid_t clock_id, cloudabi_timestamp_t timeout, cloudabi_timestamp_t precision) { struct futex_lock *fl; struct futex_queue fq; int error; /* Look up lock object. */ error = futex_lock_lookup(td, lock, scope, &fl); if (error != 0) return (error); futex_queue_init(&fq); error = futex_lock_wrlock(fl, td, lock, clock_id, timeout, precision, &fq); futex_lock_release(fl); return (error); } /* * Non-blocking calls: releasing locks, signalling condition variables. */ int cloudabi_sys_condvar_signal(struct thread *td, struct cloudabi_sys_condvar_signal_args *uap) { struct futex_condvar *fc; struct futex_lock *fl; cloudabi_nthreads_t nwaiters; int error; nwaiters = uap->nwaiters; if (nwaiters == 0) { /* No threads to wake up. */ return (0); } /* Look up futex object. */ error = futex_condvar_lookup(td, uap->condvar, uap->scope, &fc); if (error != 0) { /* Race condition: condition variable with no waiters. */ return (error == ENOENT ? 0 : error); } fl = fc->fc_lock; if (fl->fl_owner == LOCK_UNMANAGED) { /* * The lock is currently not managed by the kernel, * meaning we must attempt to acquire the userspace lock * first. We cannot requeue threads to an unmanaged lock, * as these threads will then never be scheduled. * * Unfortunately, the memory address of the lock is * unknown from this context, meaning that we cannot * acquire the lock on behalf of the first thread to be * scheduled. The lock may even not be mapped within the * address space of the current thread. * * To solve this, wake up a single waiter that will * attempt to acquire the lock. Donate all of the other * waiters that need to be woken up to this waiter, so * it can requeue them after acquiring the lock. */ futex_queue_wake_up_donate(&fc->fc_waiters, nwaiters - 1); } else { /* * Lock is already managed by the kernel. This makes it * easy, as we can requeue the threads from the * condition variable directly to the associated lock. */ futex_queue_requeue(&fc->fc_waiters, &fl->fl_writers, nwaiters); } /* Clear userspace condition variable if all waiters are gone. */ error = futex_condvar_unmanage(fc, uap->condvar); futex_condvar_release(fc); return (error); } int cloudabi_sys_lock_unlock(struct thread *td, struct cloudabi_sys_lock_unlock_args *uap) { struct futex_lock *fl; int error; error = futex_lock_lookup(td, uap->lock, uap->scope, &fl); if (error != 0) return (error); error = futex_lock_unlock(fl, td, uap->lock); futex_lock_release(fl); return (error); } Index: head/sys/compat/cloudabi/cloudabi_util.h =================================================================== --- head/sys/compat/cloudabi/cloudabi_util.h (revision 297467) +++ head/sys/compat/cloudabi/cloudabi_util.h (revision 297468) @@ -1,79 +1,79 @@ /*- * Copyright (c) 2015 Nuxi, https://nuxi.nl/ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef _CLOUDABI_UTIL_H_ #define _CLOUDABI_UTIL_H_ #include #include struct file; struct thread; struct timespec; /* Fetches the time value of a clock. */ int cloudabi_clock_time_get(struct thread *, cloudabi_clockid_t, cloudabi_timestamp_t *); /* Converts a FreeBSD errno to a CloudABI errno. */ cloudabi_errno_t cloudabi_convert_errno(int); /* Converts 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 *); /* Converts CloudABI rights to a set of Capsicum capabilities. */ int cloudabi_convert_rights(cloudabi_rights_t, cap_rights_t *); /* Removes rights that conflict with the file descriptor type. */ void cloudabi_remove_conflicting_rights(cloudabi_filetype_t, cloudabi_rights_t *, cloudabi_rights_t *); /* Converts a struct timespec to a CloudABI timestamp. */ int cloudabi_convert_timespec(const struct timespec *, cloudabi_timestamp_t *); /* * Blocking futex functions. * * These functions are called by CloudABI's polling system calls to * sleep on a lock or condition variable. */ int cloudabi_futex_condvar_wait(struct thread *, cloudabi_condvar_t *, - cloudabi_mflags_t, cloudabi_lock_t *, cloudabi_mflags_t, cloudabi_clockid_t, + cloudabi_scope_t, cloudabi_lock_t *, cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); int cloudabi_futex_lock_rdlock(struct thread *, cloudabi_lock_t *, - cloudabi_mflags_t, cloudabi_clockid_t, cloudabi_timestamp_t, + cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); int cloudabi_futex_lock_wrlock(struct thread *, cloudabi_lock_t *, - cloudabi_mflags_t, cloudabi_clockid_t, cloudabi_timestamp_t, + cloudabi_scope_t, cloudabi_clockid_t, cloudabi_timestamp_t, cloudabi_timestamp_t); #endif Index: head/sys/compat/cloudabi64/cloudabi64_systrace_args.c =================================================================== --- head/sys/compat/cloudabi64/cloudabi64_systrace_args.c (revision 297467) +++ head/sys/compat/cloudabi64/cloudabi64_systrace_args.c (revision 297468) @@ -1,1724 +1,1724 @@ /* * System call argument to DTrace register array converstion. * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ * This file is part of the DTrace syscall provider. */ static void systrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args) { int64_t *iarg = (int64_t *) uarg; switch (sysnum) { /* cloudabi_sys_clock_res_get */ case 0: { struct cloudabi_sys_clock_res_get_args *p = params; iarg[0] = p->clock_id; /* cloudabi_clockid_t */ *n_args = 1; break; } /* cloudabi_sys_clock_time_get */ case 1: { struct cloudabi_sys_clock_time_get_args *p = params; iarg[0] = p->clock_id; /* cloudabi_clockid_t */ iarg[1] = p->precision; /* cloudabi_timestamp_t */ *n_args = 2; break; } /* cloudabi_sys_condvar_signal */ case 2: { struct cloudabi_sys_condvar_signal_args *p = params; uarg[0] = (intptr_t) p->condvar; /* cloudabi_condvar_t * */ - iarg[1] = p->scope; /* cloudabi_mflags_t */ + iarg[1] = p->scope; /* cloudabi_scope_t */ iarg[2] = p->nwaiters; /* cloudabi_nthreads_t */ *n_args = 3; break; } /* cloudabi_sys_fd_close */ case 3: { struct cloudabi_sys_fd_close_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ *n_args = 1; break; } /* cloudabi_sys_fd_create1 */ case 4: { struct cloudabi_sys_fd_create1_args *p = params; iarg[0] = p->type; /* cloudabi_filetype_t */ *n_args = 1; break; } /* cloudabi_sys_fd_create2 */ case 5: { struct cloudabi_sys_fd_create2_args *p = params; iarg[0] = p->type; /* cloudabi_filetype_t */ *n_args = 1; break; } /* cloudabi_sys_fd_datasync */ case 6: { struct cloudabi_sys_fd_datasync_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ *n_args = 1; break; } /* cloudabi_sys_fd_dup */ case 7: { struct cloudabi_sys_fd_dup_args *p = params; iarg[0] = p->from; /* cloudabi_fd_t */ *n_args = 1; break; } /* cloudabi64_sys_fd_pread */ case 8: { struct cloudabi64_sys_fd_pread_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->iov; /* const cloudabi64_iovec_t * */ uarg[2] = p->iovcnt; /* size_t */ iarg[3] = p->offset; /* cloudabi_filesize_t */ *n_args = 4; break; } /* cloudabi64_sys_fd_pwrite */ case 9: { struct cloudabi64_sys_fd_pwrite_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->iov; /* const cloudabi64_ciovec_t * */ uarg[2] = p->iovcnt; /* size_t */ iarg[3] = p->offset; /* cloudabi_filesize_t */ *n_args = 4; break; } /* cloudabi64_sys_fd_read */ case 10: { struct cloudabi64_sys_fd_read_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->iov; /* const cloudabi64_iovec_t * */ uarg[2] = p->iovcnt; /* size_t */ *n_args = 3; break; } /* cloudabi_sys_fd_replace */ case 11: { struct cloudabi_sys_fd_replace_args *p = params; iarg[0] = p->from; /* cloudabi_fd_t */ iarg[1] = p->to; /* cloudabi_fd_t */ *n_args = 2; break; } /* cloudabi_sys_fd_seek */ case 12: { struct cloudabi_sys_fd_seek_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ iarg[1] = p->offset; /* cloudabi_filedelta_t */ iarg[2] = p->whence; /* cloudabi_whence_t */ *n_args = 3; break; } /* cloudabi_sys_fd_stat_get */ case 13: { struct cloudabi_sys_fd_stat_get_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* cloudabi_fdstat_t * */ *n_args = 2; break; } /* cloudabi_sys_fd_stat_put */ case 14: { struct cloudabi_sys_fd_stat_put_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* const cloudabi_fdstat_t * */ iarg[2] = p->flags; /* cloudabi_fdsflags_t */ *n_args = 3; break; } /* cloudabi_sys_fd_sync */ case 15: { struct cloudabi_sys_fd_sync_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ *n_args = 1; break; } /* cloudabi64_sys_fd_write */ case 16: { struct cloudabi64_sys_fd_write_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->iov; /* const cloudabi64_ciovec_t * */ uarg[2] = p->iovcnt; /* size_t */ *n_args = 3; break; } /* cloudabi_sys_file_advise */ case 17: { struct cloudabi_sys_file_advise_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ iarg[1] = p->offset; /* cloudabi_filesize_t */ iarg[2] = p->len; /* cloudabi_filesize_t */ iarg[3] = p->advice; /* cloudabi_advice_t */ *n_args = 4; break; } /* cloudabi_sys_file_allocate */ case 18: { struct cloudabi_sys_file_allocate_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ iarg[1] = p->offset; /* cloudabi_filesize_t */ iarg[2] = p->len; /* cloudabi_filesize_t */ *n_args = 3; break; } /* cloudabi_sys_file_create */ case 19: { struct cloudabi_sys_file_create_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ uarg[2] = p->pathlen; /* size_t */ iarg[3] = p->type; /* cloudabi_filetype_t */ *n_args = 4; break; } /* cloudabi_sys_file_link */ case 20: { struct cloudabi_sys_file_link_args *p = params; iarg[0] = p->fd1; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path1; /* const char * */ uarg[2] = p->path1len; /* size_t */ iarg[3] = p->fd2; /* cloudabi_fd_t */ uarg[4] = (intptr_t) p->path2; /* const char * */ uarg[5] = p->path2len; /* size_t */ *n_args = 6; break; } /* cloudabi_sys_file_open */ case 21: { struct cloudabi_sys_file_open_args *p = params; iarg[0] = p->dirfd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ uarg[2] = p->pathlen; /* size_t */ iarg[3] = p->oflags; /* cloudabi_oflags_t */ uarg[4] = (intptr_t) p->fds; /* const cloudabi_fdstat_t * */ *n_args = 5; break; } /* cloudabi_sys_file_readdir */ case 22: { struct cloudabi_sys_file_readdir_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* void * */ uarg[2] = p->nbyte; /* size_t */ iarg[3] = p->cookie; /* cloudabi_dircookie_t */ *n_args = 4; break; } /* cloudabi_sys_file_readlink */ case 23: { struct cloudabi_sys_file_readlink_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ uarg[2] = p->pathlen; /* size_t */ uarg[3] = (intptr_t) p->buf; /* char * */ uarg[4] = p->bufsize; /* size_t */ *n_args = 5; break; } /* cloudabi_sys_file_rename */ case 24: { struct cloudabi_sys_file_rename_args *p = params; iarg[0] = p->oldfd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->old; /* const char * */ uarg[2] = p->oldlen; /* size_t */ iarg[3] = p->newfd; /* cloudabi_fd_t */ uarg[4] = (intptr_t) p->new; /* const char * */ uarg[5] = p->newlen; /* size_t */ *n_args = 6; break; } /* cloudabi_sys_file_stat_fget */ case 25: { struct cloudabi_sys_file_stat_fget_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* cloudabi_filestat_t * */ *n_args = 2; break; } /* cloudabi_sys_file_stat_fput */ case 26: { struct cloudabi_sys_file_stat_fput_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* const cloudabi_filestat_t * */ iarg[2] = p->flags; /* cloudabi_fsflags_t */ *n_args = 3; break; } /* cloudabi_sys_file_stat_get */ case 27: { struct cloudabi_sys_file_stat_get_args *p = params; iarg[0] = p->fd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ uarg[2] = p->pathlen; /* size_t */ uarg[3] = (intptr_t) p->buf; /* cloudabi_filestat_t * */ *n_args = 4; break; } /* cloudabi_sys_file_stat_put */ case 28: { struct cloudabi_sys_file_stat_put_args *p = params; iarg[0] = p->fd; /* cloudabi_lookup_t */ uarg[1] = (intptr_t) p->path; /* const char * */ uarg[2] = p->pathlen; /* size_t */ uarg[3] = (intptr_t) p->buf; /* const cloudabi_filestat_t * */ iarg[4] = p->flags; /* cloudabi_fsflags_t */ *n_args = 5; break; } /* cloudabi_sys_file_symlink */ case 29: { struct cloudabi_sys_file_symlink_args *p = params; uarg[0] = (intptr_t) p->path1; /* const char * */ uarg[1] = p->path1len; /* size_t */ iarg[2] = p->fd; /* cloudabi_fd_t */ uarg[3] = (intptr_t) p->path2; /* const char * */ uarg[4] = p->path2len; /* size_t */ *n_args = 5; break; } /* cloudabi_sys_file_unlink */ case 30: { struct cloudabi_sys_file_unlink_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->path; /* const char * */ uarg[2] = p->pathlen; /* size_t */ iarg[3] = p->flags; /* cloudabi_ulflags_t */ *n_args = 4; break; } /* cloudabi_sys_lock_unlock */ case 31: { struct cloudabi_sys_lock_unlock_args *p = params; uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */ - iarg[1] = p->scope; /* cloudabi_mflags_t */ + iarg[1] = p->scope; /* cloudabi_scope_t */ *n_args = 2; break; } /* cloudabi_sys_mem_advise */ case 32: { struct cloudabi_sys_mem_advise_args *p = params; uarg[0] = (intptr_t) p->addr; /* void * */ uarg[1] = p->len; /* size_t */ iarg[2] = p->advice; /* cloudabi_advice_t */ *n_args = 3; break; } /* cloudabi_sys_mem_lock */ case 33: { struct cloudabi_sys_mem_lock_args *p = params; uarg[0] = (intptr_t) p->addr; /* const void * */ uarg[1] = p->len; /* size_t */ *n_args = 2; break; } /* cloudabi_sys_mem_map */ case 34: { struct cloudabi_sys_mem_map_args *p = params; uarg[0] = (intptr_t) p->addr; /* void * */ uarg[1] = p->len; /* size_t */ iarg[2] = p->prot; /* cloudabi_mprot_t */ iarg[3] = p->flags; /* cloudabi_mflags_t */ iarg[4] = p->fd; /* cloudabi_fd_t */ iarg[5] = p->off; /* cloudabi_filesize_t */ *n_args = 6; break; } /* cloudabi_sys_mem_protect */ case 35: { struct cloudabi_sys_mem_protect_args *p = params; uarg[0] = (intptr_t) p->addr; /* void * */ uarg[1] = p->len; /* size_t */ iarg[2] = p->prot; /* cloudabi_mprot_t */ *n_args = 3; break; } /* cloudabi_sys_mem_sync */ case 36: { struct cloudabi_sys_mem_sync_args *p = params; uarg[0] = (intptr_t) p->addr; /* void * */ uarg[1] = p->len; /* size_t */ iarg[2] = p->flags; /* cloudabi_msflags_t */ *n_args = 3; break; } /* cloudabi_sys_mem_unlock */ case 37: { struct cloudabi_sys_mem_unlock_args *p = params; uarg[0] = (intptr_t) p->addr; /* const void * */ uarg[1] = p->len; /* size_t */ *n_args = 2; break; } /* cloudabi_sys_mem_unmap */ case 38: { struct cloudabi_sys_mem_unmap_args *p = params; uarg[0] = (intptr_t) p->addr; /* void * */ uarg[1] = p->len; /* size_t */ *n_args = 2; break; } /* cloudabi64_sys_poll */ case 39: { 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[2] = p->nsubscriptions; /* size_t */ *n_args = 3; break; } /* cloudabi_sys_proc_exec */ case 40: { struct cloudabi_sys_proc_exec_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->data; /* const void * */ uarg[2] = p->datalen; /* size_t */ uarg[3] = (intptr_t) p->fds; /* const cloudabi_fd_t * */ uarg[4] = p->fdslen; /* size_t */ *n_args = 5; break; } /* cloudabi_sys_proc_exit */ case 41: { struct cloudabi_sys_proc_exit_args *p = params; iarg[0] = p->rval; /* cloudabi_exitcode_t */ *n_args = 1; break; } /* cloudabi_sys_proc_fork */ case 42: { *n_args = 0; break; } /* cloudabi_sys_proc_raise */ case 43: { struct cloudabi_sys_proc_raise_args *p = params; iarg[0] = p->sig; /* cloudabi_signal_t */ *n_args = 1; break; } /* cloudabi_sys_random_get */ case 44: { struct cloudabi_sys_random_get_args *p = params; uarg[0] = (intptr_t) p->buf; /* void * */ uarg[1] = p->nbyte; /* size_t */ *n_args = 2; break; } /* cloudabi_sys_sock_accept */ case 45: { struct cloudabi_sys_sock_accept_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */ *n_args = 2; break; } /* cloudabi_sys_sock_bind */ case 46: { struct cloudabi_sys_sock_bind_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ uarg[2] = (intptr_t) p->path; /* const char * */ uarg[3] = p->pathlen; /* size_t */ *n_args = 4; break; } /* cloudabi_sys_sock_connect */ case 47: { struct cloudabi_sys_sock_connect_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->fd; /* cloudabi_fd_t */ uarg[2] = (intptr_t) p->path; /* const char * */ uarg[3] = p->pathlen; /* size_t */ *n_args = 4; break; } /* cloudabi_sys_sock_listen */ case 48: { struct cloudabi_sys_sock_listen_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->backlog; /* cloudabi_backlog_t */ *n_args = 2; break; } /* cloudabi64_sys_sock_recv */ case 49: { struct cloudabi64_sys_sock_recv_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi64_recv_in_t * */ uarg[2] = (intptr_t) p->out; /* cloudabi64_recv_out_t * */ *n_args = 3; break; } /* cloudabi64_sys_sock_send */ case 50: { struct cloudabi64_sys_sock_send_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi64_send_in_t * */ uarg[2] = (intptr_t) p->out; /* cloudabi64_send_out_t * */ *n_args = 3; break; } /* cloudabi_sys_sock_shutdown */ case 51: { struct cloudabi_sys_sock_shutdown_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ iarg[1] = p->how; /* cloudabi_sdflags_t */ *n_args = 2; break; } /* cloudabi_sys_sock_stat_get */ case 52: { struct cloudabi_sys_sock_stat_get_args *p = params; iarg[0] = p->sock; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->buf; /* cloudabi_sockstat_t * */ iarg[2] = p->flags; /* cloudabi_ssflags_t */ *n_args = 3; break; } /* cloudabi64_sys_thread_create */ case 53: { struct cloudabi64_sys_thread_create_args *p = params; uarg[0] = (intptr_t) p->attr; /* cloudabi64_threadattr_t * */ *n_args = 1; break; } /* cloudabi_sys_thread_exit */ case 54: { struct cloudabi_sys_thread_exit_args *p = params; uarg[0] = (intptr_t) p->lock; /* cloudabi_lock_t * */ - iarg[1] = p->scope; /* cloudabi_mflags_t */ + iarg[1] = p->scope; /* cloudabi_scope_t */ *n_args = 2; break; } /* cloudabi_sys_thread_tcb_set */ case 55: { struct cloudabi_sys_thread_tcb_set_args *p = params; uarg[0] = (intptr_t) p->tcb; /* void * */ *n_args = 1; break; } /* cloudabi_sys_thread_yield */ case 56: { *n_args = 0; break; } /* cloudabi64_sys_poll_fd */ case 57: { struct cloudabi64_sys_poll_fd_args *p = params; iarg[0] = p->fd; /* cloudabi_fd_t */ uarg[1] = (intptr_t) p->in; /* const cloudabi64_subscription_t * */ uarg[2] = p->nin; /* size_t */ uarg[3] = (intptr_t) p->out; /* cloudabi64_event_t * */ uarg[4] = p->nout; /* size_t */ uarg[5] = (intptr_t) p->timeout; /* const cloudabi64_subscription_t * */ *n_args = 6; break; } default: *n_args = 0; break; }; } static void systrace_entry_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) { const char *p = NULL; switch (sysnum) { /* cloudabi_sys_clock_res_get */ case 0: switch(ndx) { case 0: p = "cloudabi_clockid_t"; break; default: break; }; break; /* cloudabi_sys_clock_time_get */ case 1: switch(ndx) { case 0: p = "cloudabi_clockid_t"; break; case 1: p = "cloudabi_timestamp_t"; break; default: break; }; break; /* cloudabi_sys_condvar_signal */ case 2: switch(ndx) { case 0: p = "cloudabi_condvar_t *"; break; case 1: - p = "cloudabi_mflags_t"; + p = "cloudabi_scope_t"; break; case 2: p = "cloudabi_nthreads_t"; break; default: break; }; break; /* cloudabi_sys_fd_close */ case 3: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; default: break; }; break; /* cloudabi_sys_fd_create1 */ case 4: switch(ndx) { case 0: p = "cloudabi_filetype_t"; break; default: break; }; break; /* cloudabi_sys_fd_create2 */ case 5: switch(ndx) { case 0: p = "cloudabi_filetype_t"; break; default: break; }; break; /* cloudabi_sys_fd_datasync */ case 6: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; default: break; }; break; /* cloudabi_sys_fd_dup */ case 7: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; default: break; }; break; /* cloudabi64_sys_fd_pread */ case 8: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_iovec_t *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_filesize_t"; break; default: break; }; break; /* cloudabi64_sys_fd_pwrite */ case 9: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_ciovec_t *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_filesize_t"; break; default: break; }; break; /* cloudabi64_sys_fd_read */ case 10: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_iovec_t *"; break; case 2: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_fd_replace */ case 11: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_fd_t"; break; default: break; }; break; /* cloudabi_sys_fd_seek */ case 12: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_filedelta_t"; break; case 2: p = "cloudabi_whence_t"; break; default: break; }; break; /* cloudabi_sys_fd_stat_get */ case 13: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_fdstat_t *"; break; default: break; }; break; /* cloudabi_sys_fd_stat_put */ case 14: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi_fdstat_t *"; break; case 2: p = "cloudabi_fdsflags_t"; break; default: break; }; break; /* cloudabi_sys_fd_sync */ case 15: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; default: break; }; break; /* cloudabi64_sys_fd_write */ case 16: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_ciovec_t *"; break; case 2: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_file_advise */ case 17: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_filesize_t"; break; case 2: p = "cloudabi_filesize_t"; break; case 3: p = "cloudabi_advice_t"; break; default: break; }; break; /* cloudabi_sys_file_allocate */ case 18: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_filesize_t"; break; case 2: p = "cloudabi_filesize_t"; break; default: break; }; break; /* cloudabi_sys_file_create */ case 19: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_filetype_t"; break; default: break; }; break; /* cloudabi_sys_file_link */ case 20: switch(ndx) { case 0: p = "cloudabi_lookup_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_fd_t"; break; case 4: p = "const char *"; break; case 5: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_file_open */ case 21: switch(ndx) { case 0: p = "cloudabi_lookup_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_oflags_t"; break; case 4: p = "const cloudabi_fdstat_t *"; break; default: break; }; break; /* cloudabi_sys_file_readdir */ case 22: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "void *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_dircookie_t"; break; default: break; }; break; /* cloudabi_sys_file_readlink */ case 23: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "char *"; break; case 4: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_file_rename */ case 24: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_fd_t"; break; case 4: p = "const char *"; break; case 5: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_file_stat_fget */ case 25: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_filestat_t *"; break; default: break; }; break; /* cloudabi_sys_file_stat_fput */ case 26: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi_filestat_t *"; break; case 2: p = "cloudabi_fsflags_t"; break; default: break; }; break; /* cloudabi_sys_file_stat_get */ case 27: switch(ndx) { case 0: p = "cloudabi_lookup_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_filestat_t *"; break; default: break; }; break; /* cloudabi_sys_file_stat_put */ case 28: switch(ndx) { case 0: p = "cloudabi_lookup_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "const cloudabi_filestat_t *"; break; case 4: p = "cloudabi_fsflags_t"; break; default: break; }; break; /* cloudabi_sys_file_symlink */ case 29: switch(ndx) { case 0: p = "const char *"; break; case 1: p = "size_t"; break; case 2: p = "cloudabi_fd_t"; break; case 3: p = "const char *"; break; case 4: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_file_unlink */ case 30: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const char *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi_ulflags_t"; break; default: break; }; break; /* cloudabi_sys_lock_unlock */ case 31: switch(ndx) { case 0: p = "cloudabi_lock_t *"; break; case 1: - p = "cloudabi_mflags_t"; + p = "cloudabi_scope_t"; break; default: break; }; break; /* cloudabi_sys_mem_advise */ case 32: switch(ndx) { case 0: p = "void *"; break; case 1: p = "size_t"; break; case 2: p = "cloudabi_advice_t"; break; default: break; }; break; /* cloudabi_sys_mem_lock */ case 33: switch(ndx) { case 0: p = "const void *"; break; case 1: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_mem_map */ case 34: switch(ndx) { case 0: p = "void *"; break; case 1: p = "size_t"; break; case 2: p = "cloudabi_mprot_t"; break; case 3: p = "cloudabi_mflags_t"; break; case 4: p = "cloudabi_fd_t"; break; case 5: p = "cloudabi_filesize_t"; break; default: break; }; break; /* cloudabi_sys_mem_protect */ case 35: switch(ndx) { case 0: p = "void *"; break; case 1: p = "size_t"; break; case 2: p = "cloudabi_mprot_t"; break; default: break; }; break; /* cloudabi_sys_mem_sync */ case 36: switch(ndx) { case 0: p = "void *"; break; case 1: p = "size_t"; break; case 2: p = "cloudabi_msflags_t"; break; default: break; }; break; /* cloudabi_sys_mem_unlock */ case 37: switch(ndx) { case 0: p = "const void *"; break; case 1: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_mem_unmap */ case 38: switch(ndx) { case 0: p = "void *"; break; case 1: p = "size_t"; break; default: break; }; break; /* cloudabi64_sys_poll */ case 39: switch(ndx) { case 0: p = "const cloudabi64_subscription_t *"; break; case 1: p = "cloudabi64_event_t *"; break; case 2: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_proc_exec */ case 40: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const void *"; break; case 2: p = "size_t"; break; case 3: p = "const cloudabi_fd_t *"; break; case 4: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_proc_exit */ case 41: switch(ndx) { case 0: p = "cloudabi_exitcode_t"; break; default: break; }; break; /* cloudabi_sys_proc_fork */ case 42: break; /* cloudabi_sys_proc_raise */ case 43: switch(ndx) { case 0: p = "cloudabi_signal_t"; break; default: break; }; break; /* cloudabi_sys_random_get */ case 44: switch(ndx) { case 0: p = "void *"; break; case 1: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_sock_accept */ case 45: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_sockstat_t *"; break; default: break; }; break; /* cloudabi_sys_sock_bind */ case 46: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_fd_t"; break; case 2: p = "const char *"; break; case 3: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_sock_connect */ case 47: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_fd_t"; break; case 2: p = "const char *"; break; case 3: p = "size_t"; break; default: break; }; break; /* cloudabi_sys_sock_listen */ case 48: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_backlog_t"; break; default: break; }; break; /* cloudabi64_sys_sock_recv */ case 49: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_recv_in_t *"; break; case 2: p = "cloudabi64_recv_out_t *"; break; default: break; }; break; /* cloudabi64_sys_sock_send */ case 50: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_send_in_t *"; break; case 2: p = "cloudabi64_send_out_t *"; break; default: break; }; break; /* cloudabi_sys_sock_shutdown */ case 51: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_sdflags_t"; break; default: break; }; break; /* cloudabi_sys_sock_stat_get */ case 52: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "cloudabi_sockstat_t *"; break; case 2: p = "cloudabi_ssflags_t"; break; default: break; }; break; /* cloudabi64_sys_thread_create */ case 53: switch(ndx) { case 0: p = "cloudabi64_threadattr_t *"; break; default: break; }; break; /* cloudabi_sys_thread_exit */ case 54: switch(ndx) { case 0: p = "cloudabi_lock_t *"; break; case 1: - p = "cloudabi_mflags_t"; + p = "cloudabi_scope_t"; break; default: break; }; break; /* cloudabi_sys_thread_tcb_set */ case 55: switch(ndx) { case 0: p = "void *"; break; default: break; }; break; /* cloudabi_sys_thread_yield */ case 56: break; /* cloudabi64_sys_poll_fd */ case 57: switch(ndx) { case 0: p = "cloudabi_fd_t"; break; case 1: p = "const cloudabi64_subscription_t *"; break; case 2: p = "size_t"; break; case 3: p = "cloudabi64_event_t *"; break; case 4: p = "size_t"; break; case 5: p = "const cloudabi64_subscription_t *"; break; default: break; }; break; default: break; }; if (p != NULL) strlcpy(desc, p, descsz); } static void systrace_return_setargdesc(int sysnum, int ndx, char *desc, size_t descsz) { const char *p = NULL; switch (sysnum) { /* cloudabi_sys_clock_res_get */ case 0: if (ndx == 0 || ndx == 1) p = "cloudabi_timestamp_t"; break; /* cloudabi_sys_clock_time_get */ case 1: if (ndx == 0 || ndx == 1) p = "cloudabi_timestamp_t"; break; /* cloudabi_sys_condvar_signal */ case 2: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_close */ case 3: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_create1 */ case 4: if (ndx == 0 || ndx == 1) p = "cloudabi_fd_t"; break; /* cloudabi_sys_fd_create2 */ case 5: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_datasync */ case 6: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_dup */ case 7: if (ndx == 0 || ndx == 1) p = "cloudabi_fd_t"; break; /* cloudabi64_sys_fd_pread */ case 8: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi64_sys_fd_pwrite */ case 9: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi64_sys_fd_read */ case 10: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi_sys_fd_replace */ case 11: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_seek */ case 12: if (ndx == 0 || ndx == 1) p = "cloudabi_filesize_t"; break; /* cloudabi_sys_fd_stat_get */ case 13: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_stat_put */ case 14: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_fd_sync */ case 15: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_fd_write */ case 16: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi_sys_file_advise */ case 17: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_allocate */ case 18: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_create */ case 19: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_link */ case 20: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_open */ case 21: if (ndx == 0 || ndx == 1) p = "cloudabi_fd_t"; break; /* cloudabi_sys_file_readdir */ case 22: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi_sys_file_readlink */ case 23: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi_sys_file_rename */ case 24: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_stat_fget */ case 25: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_stat_fput */ case 26: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_stat_get */ case 27: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_stat_put */ case 28: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_symlink */ case 29: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_file_unlink */ case 30: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_lock_unlock */ case 31: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_advise */ case 32: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_lock */ case 33: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_map */ case 34: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_protect */ case 35: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_sync */ case 36: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_unlock */ case 37: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_mem_unmap */ case 38: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_poll */ case 39: if (ndx == 0 || ndx == 1) p = "size_t"; break; /* cloudabi_sys_proc_exec */ case 40: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_proc_exit */ case 41: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_proc_fork */ case 42: /* cloudabi_sys_proc_raise */ case 43: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_random_get */ case 44: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_accept */ case 45: if (ndx == 0 || ndx == 1) p = "cloudabi_fd_t"; break; /* cloudabi_sys_sock_bind */ case 46: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_connect */ case 47: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_listen */ case 48: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_sock_recv */ case 49: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_sock_send */ case 50: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_shutdown */ case 51: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_sock_stat_get */ case 52: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi64_sys_thread_create */ case 53: if (ndx == 0 || ndx == 1) p = "cloudabi_tid_t"; break; /* cloudabi_sys_thread_exit */ case 54: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_thread_tcb_set */ case 55: if (ndx == 0 || ndx == 1) p = "void"; break; /* cloudabi_sys_thread_yield */ case 56: /* cloudabi64_sys_poll_fd */ case 57: if (ndx == 0 || ndx == 1) p = "size_t"; break; default: break; }; if (p != NULL) strlcpy(desc, p, descsz); } Index: head/sys/contrib/cloudabi/cloudabi64_types.h =================================================================== --- head/sys/contrib/cloudabi/cloudabi64_types.h (revision 297467) +++ head/sys/contrib/cloudabi/cloudabi64_types.h (revision 297468) @@ -1,222 +1,225 @@ -// Copyright (c) 2016 Nuxi, https://nuxi.nl/ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. - +// // This file is automatically generated. Do not edit. +// // Source: https://github.com/NuxiNL/cloudabi #ifndef CLOUDABI64_TYPES_H #define CLOUDABI64_TYPES_H #include "cloudabi_types_common.h" typedef struct { _Alignas(4) cloudabi_auxtype_t a_type; union { _Alignas(8) uint64_t a_val; _Alignas(8) uint64_t a_ptr; }; } cloudabi64_auxv_t; _Static_assert(offsetof(cloudabi64_auxv_t, a_type) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_auxv_t, a_val) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_auxv_t, a_ptr) == 8, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_auxv_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_auxv_t) == 8, "Incorrect layout"); typedef struct { _Alignas(8) uint64_t iov_base; _Alignas(8) uint64_t iov_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(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 iov_base; _Alignas(8) uint64_t iov_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(sizeof(cloudabi64_iovec_t) == 16, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_iovec_t) == 8, "Incorrect layout"); +typedef void cloudabi64_processentry_t(uint64_t auxv); + typedef struct { _Alignas(8) uint64_t ri_data; _Alignas(8) uint64_t ri_datalen; _Alignas(8) uint64_t ri_fds; _Alignas(8) uint64_t ri_fdslen; _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(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_fds; _Alignas(8) uint64_t si_fdslen; _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(sizeof(cloudabi64_send_in_t) == 40, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_send_in_t) == 8, "Incorrect layout"); typedef struct { _Alignas(8) uint64_t so_datalen; } cloudabi64_send_out_t; _Static_assert(offsetof(cloudabi64_send_out_t, so_datalen) == 0, "Incorrect layout"); _Static_assert(sizeof(cloudabi64_send_out_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_send_out_t) == 8, "Incorrect layout"); typedef struct { _Alignas(8) cloudabi_userdata_t userdata; _Alignas(2) cloudabi_subflags_t flags; _Alignas(1) cloudabi_eventtype_t type; union { struct { _Alignas(8) cloudabi_userdata_t identifier; _Alignas(4) cloudabi_clockid_t clock_id; _Alignas(8) cloudabi_timestamp_t timeout; _Alignas(8) cloudabi_timestamp_t precision; _Alignas(2) cloudabi_subclockflags_t flags; } clock; struct { _Alignas(8) uint64_t condvar; _Alignas(8) uint64_t lock; - _Alignas(1) cloudabi_mflags_t condvar_scope; - _Alignas(1) cloudabi_mflags_t lock_scope; + _Alignas(1) cloudabi_scope_t condvar_scope; + _Alignas(1) cloudabi_scope_t lock_scope; } condvar; struct { _Alignas(4) cloudabi_fd_t fd; _Alignas(2) cloudabi_subrwflags_t flags; } fd_readwrite; struct { _Alignas(8) uint64_t lock; - _Alignas(1) cloudabi_mflags_t lock_scope; + _Alignas(1) cloudabi_scope_t lock_scope; } lock; struct { _Alignas(4) cloudabi_fd_t fd; } proc_terminate; }; } cloudabi64_subscription_t; _Static_assert(offsetof(cloudabi64_subscription_t, userdata) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi64_subscription_t, 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 void cloudabi64_threadentry_t(cloudabi_tid_t tid, uint64_t aux); typedef struct { _Alignas(8) uint64_t ro_datalen; _Alignas(8) uint64_t ro_fdslen; _Alignas(2) cloudabi_sockaddr_t ro_sockname; _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(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 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(sizeof(cloudabi64_threadattr_t) == 32, "Incorrect layout"); _Static_assert(_Alignof(cloudabi64_threadattr_t) == 8, "Incorrect layout"); #endif Index: head/sys/contrib/cloudabi/cloudabi_types_common.h =================================================================== --- head/sys/contrib/cloudabi/cloudabi_types_common.h (revision 297467) +++ head/sys/contrib/cloudabi/cloudabi_types_common.h (revision 297468) @@ -1,457 +1,463 @@ -// Copyright (c) 2016 Nuxi, https://nuxi.nl/ +// Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. - +// // This file is automatically generated. Do not edit. +// // Source: https://github.com/NuxiNL/cloudabi #ifndef CLOUDABI_TYPES_COMMON_H #define CLOUDABI_TYPES_COMMON_H #if defined(__FreeBSD__) && defined(_KERNEL) #include #elif defined(__linux__) && defined(__KERNEL__) #include #else #include #include #endif typedef uint8_t cloudabi_advice_t; #define CLOUDABI_ADVICE_DONTNEED 1 #define CLOUDABI_ADVICE_NOREUSE 2 #define CLOUDABI_ADVICE_NORMAL 3 #define CLOUDABI_ADVICE_RANDOM 4 #define CLOUDABI_ADVICE_SEQUENTIAL 5 #define CLOUDABI_ADVICE_WILLNEED 6 typedef uint32_t cloudabi_auxtype_t; #define CLOUDABI_AT_ARGDATA 256 #define CLOUDABI_AT_ARGDATALEN 257 +#define CLOUDABI_AT_BASE 7 #define CLOUDABI_AT_CANARY 258 #define CLOUDABI_AT_CANARYLEN 259 #define CLOUDABI_AT_NCPUS 260 #define CLOUDABI_AT_NULL 0 #define CLOUDABI_AT_PAGESZ 6 #define CLOUDABI_AT_PHDR 3 #define CLOUDABI_AT_PHNUM 4 #define CLOUDABI_AT_TID 261 typedef uint32_t cloudabi_backlog_t; typedef uint32_t cloudabi_clockid_t; #define CLOUDABI_CLOCK_MONOTONIC 1 #define CLOUDABI_CLOCK_PROCESS_CPUTIME_ID 2 #define CLOUDABI_CLOCK_REALTIME 3 #define CLOUDABI_CLOCK_THREAD_CPUTIME_ID 4 typedef uint32_t cloudabi_condvar_t; #define CLOUDABI_CONDVAR_HAS_NO_WAITERS 0 typedef uint64_t cloudabi_device_t; typedef uint64_t cloudabi_dircookie_t; #define CLOUDABI_DIRCOOKIE_START 0 typedef uint16_t cloudabi_errno_t; #define CLOUDABI_E2BIG 1 #define CLOUDABI_EACCES 2 #define CLOUDABI_EADDRINUSE 3 #define CLOUDABI_EADDRNOTAVAIL 4 #define CLOUDABI_EAFNOSUPPORT 5 #define CLOUDABI_EAGAIN 6 #define CLOUDABI_EALREADY 7 #define CLOUDABI_EBADF 8 #define CLOUDABI_EBADMSG 9 #define CLOUDABI_EBUSY 10 #define CLOUDABI_ECANCELED 11 #define CLOUDABI_ECHILD 12 #define CLOUDABI_ECONNABORTED 13 #define CLOUDABI_ECONNREFUSED 14 #define CLOUDABI_ECONNRESET 15 #define CLOUDABI_EDEADLK 16 #define CLOUDABI_EDESTADDRREQ 17 #define CLOUDABI_EDOM 18 #define CLOUDABI_EDQUOT 19 #define CLOUDABI_EEXIST 20 #define CLOUDABI_EFAULT 21 #define CLOUDABI_EFBIG 22 #define CLOUDABI_EHOSTUNREACH 23 #define CLOUDABI_EIDRM 24 #define CLOUDABI_EILSEQ 25 #define CLOUDABI_EINPROGRESS 26 #define CLOUDABI_EINTR 27 #define CLOUDABI_EINVAL 28 #define CLOUDABI_EIO 29 #define CLOUDABI_EISCONN 30 #define CLOUDABI_EISDIR 31 #define CLOUDABI_ELOOP 32 #define CLOUDABI_EMFILE 33 #define CLOUDABI_EMLINK 34 #define CLOUDABI_EMSGSIZE 35 #define CLOUDABI_EMULTIHOP 36 #define CLOUDABI_ENAMETOOLONG 37 #define CLOUDABI_ENETDOWN 38 #define CLOUDABI_ENETRESET 39 #define CLOUDABI_ENETUNREACH 40 #define CLOUDABI_ENFILE 41 #define CLOUDABI_ENOBUFS 42 #define CLOUDABI_ENODEV 43 #define CLOUDABI_ENOENT 44 #define CLOUDABI_ENOEXEC 45 #define CLOUDABI_ENOLCK 46 #define CLOUDABI_ENOLINK 47 #define CLOUDABI_ENOMEM 48 #define CLOUDABI_ENOMSG 49 #define CLOUDABI_ENOPROTOOPT 50 #define CLOUDABI_ENOSPC 51 #define CLOUDABI_ENOSYS 52 #define CLOUDABI_ENOTCONN 53 #define CLOUDABI_ENOTDIR 54 #define CLOUDABI_ENOTEMPTY 55 #define CLOUDABI_ENOTRECOVERABLE 56 #define CLOUDABI_ENOTSOCK 57 #define CLOUDABI_ENOTSUP 58 #define CLOUDABI_ENOTTY 59 #define CLOUDABI_ENXIO 60 #define CLOUDABI_EOVERFLOW 61 #define CLOUDABI_EOWNERDEAD 62 #define CLOUDABI_EPERM 63 #define CLOUDABI_EPIPE 64 #define CLOUDABI_EPROTO 65 #define CLOUDABI_EPROTONOSUPPORT 66 #define CLOUDABI_EPROTOTYPE 67 #define CLOUDABI_ERANGE 68 #define CLOUDABI_EROFS 69 #define CLOUDABI_ESPIPE 70 #define CLOUDABI_ESRCH 71 #define CLOUDABI_ESTALE 72 #define CLOUDABI_ETIMEDOUT 73 #define CLOUDABI_ETXTBSY 74 #define CLOUDABI_EXDEV 75 #define CLOUDABI_ENOTCAPABLE 76 typedef uint16_t cloudabi_eventrwflags_t; #define CLOUDABI_EVENT_FD_READWRITE_HANGUP 0x0001 typedef uint8_t cloudabi_eventtype_t; #define CLOUDABI_EVENTTYPE_CLOCK 1 #define CLOUDABI_EVENTTYPE_CONDVAR 2 #define CLOUDABI_EVENTTYPE_FD_READ 3 #define CLOUDABI_EVENTTYPE_FD_WRITE 4 #define CLOUDABI_EVENTTYPE_LOCK_RDLOCK 5 #define CLOUDABI_EVENTTYPE_LOCK_WRLOCK 6 #define CLOUDABI_EVENTTYPE_PROC_TERMINATE 7 typedef uint32_t cloudabi_exitcode_t; typedef uint32_t cloudabi_fd_t; #define CLOUDABI_PROCESS_CHILD 0xffffffff #define CLOUDABI_MAP_ANON_FD 0xffffffff typedef uint16_t cloudabi_fdflags_t; #define CLOUDABI_FDFLAG_APPEND 0x0001 #define CLOUDABI_FDFLAG_DSYNC 0x0002 #define CLOUDABI_FDFLAG_NONBLOCK 0x0004 #define CLOUDABI_FDFLAG_RSYNC 0x0008 #define CLOUDABI_FDFLAG_SYNC 0x0010 typedef uint16_t cloudabi_fdsflags_t; #define CLOUDABI_FDSTAT_FLAGS 0x0001 #define CLOUDABI_FDSTAT_RIGHTS 0x0002 typedef int64_t cloudabi_filedelta_t; typedef uint64_t cloudabi_filesize_t; typedef uint8_t cloudabi_filetype_t; #define CLOUDABI_FILETYPE_UNKNOWN 0 #define CLOUDABI_FILETYPE_BLOCK_DEVICE 16 #define CLOUDABI_FILETYPE_CHARACTER_DEVICE 17 #define CLOUDABI_FILETYPE_DIRECTORY 32 #define CLOUDABI_FILETYPE_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 typedef uint16_t cloudabi_fsflags_t; #define CLOUDABI_FILESTAT_ATIM 0x0001 #define CLOUDABI_FILESTAT_ATIM_NOW 0x0002 #define CLOUDABI_FILESTAT_MTIM 0x0004 #define CLOUDABI_FILESTAT_MTIM_NOW 0x0008 #define CLOUDABI_FILESTAT_SIZE 0x0010 typedef uint64_t cloudabi_inode_t; typedef uint32_t cloudabi_linkcount_t; typedef uint32_t cloudabi_lock_t; #define CLOUDABI_LOCK_UNLOCKED 0x00000000 #define CLOUDABI_LOCK_WRLOCKED 0x40000000 #define CLOUDABI_LOCK_KERNEL_MANAGED 0x80000000 #define CLOUDABI_LOCK_BOGUS 0x80000000 typedef uint32_t cloudabi_lookupflags_t; #define CLOUDABI_LOOKUP_SYMLINK_FOLLOW 0x00000001 typedef uint8_t cloudabi_mflags_t; #define CLOUDABI_MAP_ANON 0x01 #define CLOUDABI_MAP_FIXED 0x02 #define CLOUDABI_MAP_PRIVATE 0x04 #define CLOUDABI_MAP_SHARED 0x08 typedef uint8_t cloudabi_mprot_t; #define CLOUDABI_PROT_EXEC 0x01 #define CLOUDABI_PROT_WRITE 0x02 #define CLOUDABI_PROT_READ 0x04 typedef uint8_t cloudabi_msflags_t; #define CLOUDABI_MS_ASYNC 0x01 #define CLOUDABI_MS_INVALIDATE 0x02 #define CLOUDABI_MS_SYNC 0x04 typedef 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_WAITALL 0x0010 typedef uint32_t cloudabi_nthreads_t; typedef uint16_t cloudabi_oflags_t; #define CLOUDABI_O_CREAT 0x0001 #define CLOUDABI_O_DIRECTORY 0x0002 #define CLOUDABI_O_EXCL 0x0004 #define CLOUDABI_O_TRUNC 0x0008 typedef 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_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 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 + +typedef uint8_t cloudabi_scope_t; +#define CLOUDABI_SCOPE_PRIVATE 4 +#define CLOUDABI_SCOPE_SHARED 8 typedef uint8_t cloudabi_sdflags_t; #define CLOUDABI_SHUT_RD 0x01 #define CLOUDABI_SHUT_WR 0x02 typedef uint8_t cloudabi_signal_t; #define CLOUDABI_SIGABRT 1 #define CLOUDABI_SIGALRM 2 #define CLOUDABI_SIGBUS 3 #define CLOUDABI_SIGCHLD 4 #define CLOUDABI_SIGCONT 5 #define CLOUDABI_SIGFPE 6 #define CLOUDABI_SIGHUP 7 #define CLOUDABI_SIGILL 8 #define CLOUDABI_SIGINT 9 #define CLOUDABI_SIGKILL 10 #define CLOUDABI_SIGPIPE 11 #define CLOUDABI_SIGQUIT 12 #define CLOUDABI_SIGSEGV 13 #define CLOUDABI_SIGSTOP 14 #define CLOUDABI_SIGSYS 15 #define CLOUDABI_SIGTERM 16 #define CLOUDABI_SIGTRAP 17 #define CLOUDABI_SIGTSTP 18 #define CLOUDABI_SIGTTIN 19 #define CLOUDABI_SIGTTOU 20 #define CLOUDABI_SIGURG 21 #define CLOUDABI_SIGUSR1 22 #define CLOUDABI_SIGUSR2 23 #define CLOUDABI_SIGVTALRM 24 #define CLOUDABI_SIGXCPU 25 #define CLOUDABI_SIGXFSZ 26 typedef uint8_t cloudabi_ssflags_t; #define CLOUDABI_SOCKSTAT_CLEAR_ERROR 0x01 typedef uint32_t cloudabi_sstate_t; #define CLOUDABI_SOCKSTATE_ACCEPTCONN 0x00000001 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_DISABLE 0x0008 #define CLOUDABI_SUBSCRIPTION_ENABLE 0x0010 #define CLOUDABI_SUBSCRIPTION_ONESHOT 0x0020 typedef uint16_t cloudabi_subrwflags_t; #define CLOUDABI_SUBSCRIPTION_FD_READWRITE_POLL 0x0001 typedef uint32_t cloudabi_tid_t; typedef uint64_t cloudabi_timestamp_t; typedef uint8_t cloudabi_ulflags_t; #define CLOUDABI_UNLINK_REMOVEDIR 0x01 typedef uint64_t cloudabi_userdata_t; typedef uint8_t cloudabi_whence_t; #define CLOUDABI_WHENCE_CUR 1 #define CLOUDABI_WHENCE_END 2 #define CLOUDABI_WHENCE_SET 3 typedef struct { _Alignas(8) cloudabi_dircookie_t d_next; _Alignas(8) cloudabi_inode_t d_ino; _Alignas(4) uint32_t d_namlen; _Alignas(1) cloudabi_filetype_t d_type; } cloudabi_dirent_t; _Static_assert(offsetof(cloudabi_dirent_t, d_next) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_dirent_t, d_ino) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi_dirent_t, d_namlen) == 16, "Incorrect layout"); _Static_assert(offsetof(cloudabi_dirent_t, d_type) == 20, "Incorrect layout"); _Static_assert(sizeof(cloudabi_dirent_t) == 24, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_dirent_t) == 8, "Incorrect layout"); typedef struct { _Alignas(1) cloudabi_filetype_t fs_filetype; _Alignas(2) cloudabi_fdflags_t fs_flags; _Alignas(8) cloudabi_rights_t fs_rights_base; _Alignas(8) cloudabi_rights_t fs_rights_inheriting; } cloudabi_fdstat_t; _Static_assert(offsetof(cloudabi_fdstat_t, fs_filetype) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_fdstat_t, fs_flags) == 2, "Incorrect layout"); _Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_base) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi_fdstat_t, fs_rights_inheriting) == 16, "Incorrect layout"); _Static_assert(sizeof(cloudabi_fdstat_t) == 24, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_fdstat_t) == 8, "Incorrect layout"); typedef struct { _Alignas(8) cloudabi_device_t st_dev; _Alignas(8) cloudabi_inode_t st_ino; _Alignas(1) cloudabi_filetype_t st_filetype; _Alignas(4) cloudabi_linkcount_t st_nlink; _Alignas(8) cloudabi_filesize_t st_size; _Alignas(8) cloudabi_timestamp_t st_atim; _Alignas(8) cloudabi_timestamp_t st_mtim; _Alignas(8) cloudabi_timestamp_t st_ctim; } cloudabi_filestat_t; _Static_assert(offsetof(cloudabi_filestat_t, st_dev) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_ino) == 8, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_filetype) == 16, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_nlink) == 20, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_size) == 24, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_atim) == 32, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_mtim) == 40, "Incorrect layout"); _Static_assert(offsetof(cloudabi_filestat_t, st_ctim) == 48, "Incorrect layout"); _Static_assert(sizeof(cloudabi_filestat_t) == 56, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_filestat_t) == 8, "Incorrect layout"); typedef struct { _Alignas(4) cloudabi_fd_t fd; _Alignas(4) cloudabi_lookupflags_t flags; } cloudabi_lookup_t; _Static_assert(offsetof(cloudabi_lookup_t, fd) == 0, "Incorrect layout"); _Static_assert(offsetof(cloudabi_lookup_t, flags) == 4, "Incorrect layout"); _Static_assert(sizeof(cloudabi_lookup_t) == 8, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_lookup_t) == 4, "Incorrect layout"); typedef struct { _Alignas(1) cloudabi_sa_family_t sa_family; union { struct { _Alignas(1) uint8_t addr[4]; _Alignas(2) uint16_t port; } sa_inet; struct { _Alignas(1) uint8_t addr[16]; _Alignas(2) uint16_t port; } 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(sizeof(cloudabi_sockaddr_t) == 20, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_sockaddr_t) == 2, "Incorrect layout"); typedef struct { _Alignas(2) cloudabi_sockaddr_t ss_sockname; _Alignas(2) cloudabi_sockaddr_t ss_peername; _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(sizeof(cloudabi_sockstat_t) == 48, "Incorrect layout"); _Static_assert(_Alignof(cloudabi_sockstat_t) == 4, "Incorrect layout"); #endif Index: head/sys/contrib/cloudabi/syscalls.master =================================================================== --- head/sys/contrib/cloudabi/syscalls.master (revision 297467) +++ head/sys/contrib/cloudabi/syscalls.master (revision 297468) @@ -1,317 +1,318 @@ $FreeBSD$ -; Copyright (c) 2016 Nuxi, https://nuxi.nl/ +; Copyright (c) 2016 Nuxi (https://nuxi.nl/) and contributors. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; 1. Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; 2. Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ; SUCH DAMAGE. - +; ; This file is automatically generated. Do not edit. +; ; Source: https://github.com/NuxiNL/cloudabi #include #include #include #include 0 AUE_NULL STD { cloudabi_timestamp_t \ cloudabi_sys_clock_res_get( \ cloudabi_clockid_t clock_id); } 1 AUE_NULL STD { cloudabi_timestamp_t \ cloudabi_sys_clock_time_get( \ cloudabi_clockid_t clock_id, \ cloudabi_timestamp_t precision); } 2 AUE_NULL STD { void cloudabi_sys_condvar_signal( \ cloudabi_condvar_t *condvar, \ - cloudabi_mflags_t scope, \ + cloudabi_scope_t scope, \ cloudabi_nthreads_t nwaiters); } 3 AUE_NULL STD { void cloudabi_sys_fd_close( \ cloudabi_fd_t fd); } 4 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_create1( \ cloudabi_filetype_t type); } 5 AUE_NULL STD { void cloudabi_sys_fd_create2( \ cloudabi_filetype_t type); } 6 AUE_NULL STD { void cloudabi_sys_fd_datasync( \ cloudabi_fd_t fd); } 7 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_fd_dup( \ cloudabi_fd_t from); } 8 AUE_NULL STD { size_t cloudabi64_sys_fd_pread( \ cloudabi_fd_t fd, \ const cloudabi64_iovec_t *iov, \ size_t iovcnt, \ 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, \ 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); } 11 AUE_NULL STD { void cloudabi_sys_fd_replace( \ cloudabi_fd_t from, \ cloudabi_fd_t to); } 12 AUE_NULL STD { cloudabi_filesize_t \ cloudabi_sys_fd_seek( \ cloudabi_fd_t fd, \ cloudabi_filedelta_t offset, \ cloudabi_whence_t whence); } 13 AUE_NULL STD { void cloudabi_sys_fd_stat_get( \ cloudabi_fd_t fd, \ cloudabi_fdstat_t *buf); } 14 AUE_NULL STD { void cloudabi_sys_fd_stat_put( \ cloudabi_fd_t fd, \ const cloudabi_fdstat_t *buf, \ cloudabi_fdsflags_t flags); } 15 AUE_NULL STD { void cloudabi_sys_fd_sync( \ cloudabi_fd_t fd); } 16 AUE_NULL STD { size_t cloudabi64_sys_fd_write( \ cloudabi_fd_t fd, \ const cloudabi64_ciovec_t *iov, \ size_t iovcnt); } 17 AUE_NULL STD { void cloudabi_sys_file_advise( \ cloudabi_fd_t fd, \ cloudabi_filesize_t offset, \ cloudabi_filesize_t len, \ cloudabi_advice_t advice); } 18 AUE_NULL STD { void cloudabi_sys_file_allocate( \ cloudabi_fd_t fd, \ cloudabi_filesize_t offset, \ cloudabi_filesize_t len); } 19 AUE_NULL STD { void cloudabi_sys_file_create( \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen, \ cloudabi_filetype_t type); } 20 AUE_NULL STD { void cloudabi_sys_file_link( \ cloudabi_lookup_t fd1, \ const char *path1, \ size_t path1len, \ cloudabi_fd_t fd2, \ const char *path2, \ size_t path2len); } 21 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_file_open( \ cloudabi_lookup_t dirfd, \ const char *path, \ size_t pathlen, \ 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, \ cloudabi_dircookie_t cookie); } 23 AUE_NULL STD { size_t cloudabi_sys_file_readlink( \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen, \ char *buf, \ size_t bufsize); } 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); } 25 AUE_NULL STD { void cloudabi_sys_file_stat_fget( \ cloudabi_fd_t fd, \ cloudabi_filestat_t *buf); } 26 AUE_NULL STD { void cloudabi_sys_file_stat_fput( \ cloudabi_fd_t fd, \ const cloudabi_filestat_t *buf, \ cloudabi_fsflags_t flags); } 27 AUE_NULL STD { void cloudabi_sys_file_stat_get( \ cloudabi_lookup_t fd, \ const char *path, \ size_t pathlen, \ cloudabi_filestat_t *buf); } 28 AUE_NULL STD { void cloudabi_sys_file_stat_put( \ cloudabi_lookup_t fd, \ const char *path, \ size_t pathlen, \ const cloudabi_filestat_t *buf, \ cloudabi_fsflags_t flags); } 29 AUE_NULL STD { void cloudabi_sys_file_symlink( \ const char *path1, \ size_t path1len, \ cloudabi_fd_t fd, \ const char *path2, \ size_t path2len); } 30 AUE_NULL STD { void cloudabi_sys_file_unlink( \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen, \ cloudabi_ulflags_t flags); } 31 AUE_NULL STD { void cloudabi_sys_lock_unlock( \ cloudabi_lock_t *lock, \ - cloudabi_mflags_t scope); } + cloudabi_scope_t scope); } 32 AUE_NULL STD { void cloudabi_sys_mem_advise( \ void *addr, \ size_t len, \ cloudabi_advice_t advice); } 33 AUE_NULL STD { void cloudabi_sys_mem_lock( \ const void *addr, \ size_t len); } 34 AUE_NULL STD { void cloudabi_sys_mem_map( \ void *addr, \ size_t len, \ cloudabi_mprot_t prot, \ cloudabi_mflags_t flags, \ cloudabi_fd_t fd, \ cloudabi_filesize_t off); } 35 AUE_NULL STD { void cloudabi_sys_mem_protect( \ void *addr, \ size_t len, \ cloudabi_mprot_t prot); } 36 AUE_NULL STD { void cloudabi_sys_mem_sync( \ void *addr, \ size_t len, \ cloudabi_msflags_t flags); } 37 AUE_NULL STD { void cloudabi_sys_mem_unlock( \ const void *addr, \ size_t len); } 38 AUE_NULL STD { void cloudabi_sys_mem_unmap( \ void *addr, \ size_t len); } 39 AUE_NULL STD { size_t cloudabi64_sys_poll( \ const cloudabi64_subscription_t *in, \ cloudabi64_event_t *out, \ size_t nsubscriptions); } 40 AUE_NULL STD { void cloudabi_sys_proc_exec( \ cloudabi_fd_t fd, \ const void *data, \ size_t datalen, \ const cloudabi_fd_t *fds, \ size_t fdslen); } 41 AUE_NULL STD { void cloudabi_sys_proc_exit( \ cloudabi_exitcode_t rval); } 42 AUE_NULL STD { void cloudabi_sys_proc_fork(); } 43 AUE_NULL STD { void cloudabi_sys_proc_raise( \ cloudabi_signal_t sig); } 44 AUE_NULL STD { void cloudabi_sys_random_get( \ void *buf, \ size_t nbyte); } 45 AUE_NULL STD { cloudabi_fd_t cloudabi_sys_sock_accept( \ cloudabi_fd_t sock, \ cloudabi_sockstat_t *buf); } 46 AUE_NULL STD { void cloudabi_sys_sock_bind( \ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen); } 47 AUE_NULL STD { void cloudabi_sys_sock_connect( \ cloudabi_fd_t sock, \ cloudabi_fd_t fd, \ const char *path, \ size_t pathlen); } 48 AUE_NULL STD { void cloudabi_sys_sock_listen( \ cloudabi_fd_t sock, \ cloudabi_backlog_t backlog); } 49 AUE_NULL STD { void cloudabi64_sys_sock_recv( \ cloudabi_fd_t sock, \ const cloudabi64_recv_in_t *in, \ cloudabi64_recv_out_t *out); } 50 AUE_NULL STD { void cloudabi64_sys_sock_send( \ cloudabi_fd_t sock, \ const cloudabi64_send_in_t *in, \ cloudabi64_send_out_t *out); } 51 AUE_NULL STD { void cloudabi_sys_sock_shutdown( \ cloudabi_fd_t sock, \ cloudabi_sdflags_t how); } 52 AUE_NULL STD { void cloudabi_sys_sock_stat_get( \ cloudabi_fd_t sock, \ cloudabi_sockstat_t *buf, \ cloudabi_ssflags_t flags); } 53 AUE_NULL STD { cloudabi_tid_t cloudabi64_sys_thread_create( \ cloudabi64_threadattr_t *attr); } 54 AUE_NULL STD { void cloudabi_sys_thread_exit( \ cloudabi_lock_t *lock, \ - cloudabi_mflags_t scope); } + cloudabi_scope_t scope); } 55 AUE_NULL STD { void cloudabi_sys_thread_tcb_set( \ void *tcb); } 56 AUE_NULL STD { void cloudabi_sys_thread_yield(); } 57 AUE_NULL STD { size_t cloudabi64_sys_poll_fd( \ cloudabi_fd_t fd, \ const cloudabi64_subscription_t *in, \ size_t nin, \ cloudabi64_event_t *out, \ size_t nout, \ const cloudabi64_subscription_t *timeout); }