From f0d37f4730e58bc9e288c20219151859719613a3 Mon Sep 17 00:00:00 2001 From: Philippe Gerum Date: Wed, 12 Jun 2019 20:59:49 +0200 Subject: [PATCH] treewide: API update Improve consistency in naming and disambiguate some calls. --- include/evl/condvar.h | 72 ---------------------- include/evl/event.h | 72 ++++++++++++++++++++++ include/evl/evl.h | 4 +- include/evl/flags.h | 2 +- include/evl/mutex.h | 10 +-- include/evl/sem.h | 10 +-- lib/{condvar.c => event.c} | 120 ++++++++++++++++++------------------ lib/flags.c | 6 +- lib/init.c | 6 +- lib/internal.c | 2 +- lib/mutex.c | 18 +++--- lib/sem.c | 18 +++--- lib/xbuf.c | 2 +- tests/monitor-flags.c | 16 ++--- tests/monitor-pi.c | 14 ++--- tests/monitor-pp-dynamic.c | 8 +-- tests/monitor-pp-lower.c | 4 +- tests/monitor-pp-nested.c | 8 +-- tests/monitor-pp-pi.c | 18 +++--- tests/monitor-pp-raise.c | 4 +- tests/monitor-pp-tryenter.c | 10 +-- tests/monitor-pp-weak.c | 4 +- tests/monitor-steal.c | 18 +++--- tests/sem-close-unblock.c | 8 +-- tests/sem-timedwait.c | 2 +- tests/sem-wait.c | 4 +- 26 files changed, 230 insertions(+), 230 deletions(-) delete mode 100644 include/evl/condvar.h create mode 100644 include/evl/event.h rename lib/{condvar.c => event.c} (59%) diff --git a/include/evl/condvar.h b/include/evl/condvar.h deleted file mode 100644 index 36abaf7..0000000 --- a/include/evl/condvar.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright (C) 2019 Philippe Gerum - */ - -#ifndef _EVL_CONDVAR_H -#define _EVL_CONDVAR_H - -#include -#include -#include -#include -#include - -struct evl_condvar { - unsigned int magic; - union { - struct { - fundle_t fundle; - struct evl_monitor_state *state; - int efd; - } active; - struct { - const char *name; - int clockfd; - } uninit; - }; -}; - -#define __CONDVAR_UNINIT_MAGIC 0x01770177 - -#define EVL_CONDVAR_INITIALIZER(__name, __clock) { \ - .magic = __CONDVAR_UNINIT_MAGIC, \ - .uninit = { \ - .name = (__name), \ - .clockfd = (__clock), \ - } \ - } - -#ifdef __cplusplus -extern "C" { -#endif - -int evl_new_condvar(struct evl_condvar *cv, - int clockfd, - const char *fmt, ...); - -int evl_open_condvar(struct evl_condvar *cv, - const char *fmt, ...); - -int evl_wait(struct evl_condvar *cv, - struct evl_mutex *mutex); - -int evl_timedwait(struct evl_condvar *cv, - struct evl_mutex *mutex, - const struct timespec *timeout); - -int evl_signal(struct evl_condvar *cv); - -int evl_signal_thread(struct evl_condvar *cv, - int thrfd); - -int evl_broadcast(struct evl_condvar *cv); - -int evl_close_condvar(struct evl_condvar *cv); - -#ifdef __cplusplus -} -#endif - -#endif /* _EVL_CONDVAR_H */ diff --git a/include/evl/event.h b/include/evl/event.h new file mode 100644 index 0000000..4ccfae9 --- /dev/null +++ b/include/evl/event.h @@ -0,0 +1,72 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (C) 2019 Philippe Gerum + */ + +#ifndef _EVL_EVENT_H +#define _EVL_EVENT_H + +#include +#include +#include +#include +#include + +struct evl_event { + unsigned int magic; + union { + struct { + fundle_t fundle; + struct evl_monitor_state *state; + int efd; + } active; + struct { + const char *name; + int clockfd; + } uninit; + }; +}; + +#define __EVENT_UNINIT_MAGIC 0x01770177 + +#define EVL_EVENT_INITIALIZER(__name, __clock) { \ + .magic = __EVENT_UNINIT_MAGIC, \ + .uninit = { \ + .name = (__name), \ + .clockfd = (__clock), \ + } \ + } + +#ifdef __cplusplus +extern "C" { +#endif + +int evl_new_event(struct evl_event *evt, + int clockfd, + const char *fmt, ...); + +int evl_open_event(struct evl_event *evt, + const char *fmt, ...); + +int evl_wait_event(struct evl_event *evt, + struct evl_mutex *mutex); + +int evl_timedwait_event(struct evl_event *evt, + struct evl_mutex *mutex, + const struct timespec *timeout); + +int evl_signal_event(struct evl_event *evt); + +int evl_signal_thread(struct evl_event *evt, + int thrfd); + +int evl_broadcast_event(struct evl_event *evt); + +int evl_close_event(struct evl_event *evt); + +#ifdef __cplusplus +} +#endif + +#endif /* _EVL_EVENT_H */ diff --git a/include/evl/evl.h b/include/evl/evl.h index 0afb0f7..4d9521f 100644 --- a/include/evl/evl.h +++ b/include/evl/evl.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -19,7 +19,7 @@ #include #include -#define __EVL__ 0 /* API revision */ +#define __EVL__ 1 /* API revision */ #ifdef __cplusplus extern "C" { diff --git a/include/evl/flags.h b/include/evl/flags.h index 942b277..c0ab02e 100644 --- a/include/evl/flags.h +++ b/include/evl/flags.h @@ -51,7 +51,7 @@ int evl_new_flags(struct evl_flags *flg, const char *fmt, ...); int evl_open_flags(struct evl_flags *flg, - const char *fmt, ...); + const char *fmt, ...); int evl_close_flags(struct evl_flags *flg); diff --git a/include/evl/mutex.h b/include/evl/mutex.h index 04784fb..5219717 100644 --- a/include/evl/mutex.h +++ b/include/evl/mutex.h @@ -71,14 +71,14 @@ int evl_new_mutex_ceiling(struct evl_mutex *mutex, int evl_open_mutex(struct evl_mutex *mutex, const char *fmt, ...); -int evl_lock(struct evl_mutex *mutex); +int evl_lock_mutex(struct evl_mutex *mutex); -int evl_timedlock(struct evl_mutex *mutex, - const struct timespec *timeout); +int evl_timedlock_mutex(struct evl_mutex *mutex, + const struct timespec *timeout); -int evl_trylock(struct evl_mutex *mutex); +int evl_trylock_mutex(struct evl_mutex *mutex); -int evl_unlock(struct evl_mutex *mutex); +int evl_unlock_mutex(struct evl_mutex *mutex); int evl_set_mutex_ceiling(struct evl_mutex *mutex, unsigned int ceiling); diff --git a/include/evl/sem.h b/include/evl/sem.h index 1209538..06b322d 100644 --- a/include/evl/sem.h +++ b/include/evl/sem.h @@ -55,16 +55,16 @@ int evl_open_sem(struct evl_sem *sem, int evl_close_sem(struct evl_sem *sem); -int evl_get(struct evl_sem *sem); +int evl_get_sem(struct evl_sem *sem); -int evl_timedget(struct evl_sem *sem, +int evl_timedget_sem(struct evl_sem *sem, const struct timespec *timeout); -int evl_put(struct evl_sem *sem); +int evl_put_sem(struct evl_sem *sem); -int evl_tryget(struct evl_sem *sem); +int evl_tryget_sem(struct evl_sem *sem); -int evl_getval(struct evl_sem *sem); +int evl_peek_sem(struct evl_sem *sem); #ifdef __cplusplus } diff --git a/lib/condvar.c b/lib/event.c similarity index 59% rename from lib/condvar.c rename to lib/event.c index 5bf8554..b5c356b 100644 --- a/lib/condvar.c +++ b/lib/event.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -26,10 +26,10 @@ #include #include "internal.h" -#define __CONDVAR_ACTIVE_MAGIC 0xef55ef55 -#define __CONDVAR_DEAD_MAGIC 0 +#define __EVENT_ACTIVE_MAGIC 0xef55ef55 +#define __EVENT_DEAD_MAGIC 0 -static int init_condvar_vargs(struct evl_condvar *cv, +static int init_event_vargs(struct evl_event *evt, int clockfd, const char *fmt, va_list ap) { struct evl_monitor_attrs attrs; @@ -53,28 +53,28 @@ static int init_condvar_vargs(struct evl_condvar *cv, if (efd < 0) return efd; - cv->active.state = evl_shared_memory + eids.state_offset; - cv->active.fundle = eids.fundle; - cv->active.efd = efd; - cv->magic = __CONDVAR_ACTIVE_MAGIC; + evt->active.state = evl_shared_memory + eids.state_offset; + evt->active.fundle = eids.fundle; + evt->active.efd = efd; + evt->magic = __EVENT_ACTIVE_MAGIC; return 0; } -static int init_condvar(struct evl_condvar *cv, - int clockfd, const char *fmt, ...) +static int init_event(struct evl_event *evt, + int clockfd, const char *fmt, ...) { va_list ap; int ret; va_start(ap, fmt); - ret = init_condvar_vargs(cv, clockfd, fmt, ap); + ret = init_event_vargs(evt, clockfd, fmt, ap); va_end(ap); return ret; } -static int open_condvar_vargs(struct evl_condvar *cv, +static int open_event_vargs(struct evl_event *evt, const char *fmt, va_list ap) { struct evl_monitor_binding bind; @@ -96,10 +96,10 @@ static int open_condvar_vargs(struct evl_condvar *cv, goto fail; } - cv->active.state = evl_shared_memory + bind.eids.state_offset; - cv->active.fundle = bind.eids.fundle; - cv->active.efd = efd; - cv->magic = __CONDVAR_ACTIVE_MAGIC; + evt->active.state = evl_shared_memory + bind.eids.state_offset; + evt->active.fundle = bind.eids.fundle; + evt->active.efd = efd; + evt->magic = __EVENT_ACTIVE_MAGIC; return 0; fail: @@ -108,73 +108,73 @@ fail: return ret; } -int evl_new_condvar(struct evl_condvar *cv, +int evl_new_event(struct evl_event *evt, int clockfd, const char *fmt, ...) { va_list ap; int ret; va_start(ap, fmt); - ret = init_condvar_vargs(cv, clockfd, fmt, ap); + ret = init_event_vargs(evt, clockfd, fmt, ap); va_end(ap); return ret; } -int evl_open_condvar(struct evl_condvar *cv, const char *fmt, ...) +int evl_open_event(struct evl_event *evt, const char *fmt, ...) { va_list ap; int efd; va_start(ap, fmt); - efd = open_condvar_vargs(cv, fmt, ap); + efd = open_event_vargs(evt, fmt, ap); va_end(ap); return efd; } -int evl_close_condvar(struct evl_condvar *cv) +int evl_close_event(struct evl_event *evt) { int efd; - if (cv->magic == __CONDVAR_UNINIT_MAGIC) + if (evt->magic == __EVENT_UNINIT_MAGIC) return 0; - if (cv->magic != __CONDVAR_ACTIVE_MAGIC) + if (evt->magic != __EVENT_ACTIVE_MAGIC) return -EINVAL; - efd = cv->active.efd; - cv->active.efd = -1; + efd = evt->active.efd; + evt->active.efd = -1; compiler_barrier(); close(efd); - cv->active.fundle = EVL_NO_HANDLE; - cv->active.state = NULL; - cv->magic = __CONDVAR_DEAD_MAGIC; + evt->active.fundle = EVL_NO_HANDLE; + evt->active.state = NULL; + evt->magic = __EVENT_DEAD_MAGIC; return 0; } -static int check_condvar_sanity(struct evl_condvar *cv) +static int check_event_sanity(struct evl_event *evt) { int ret; - if (cv->magic == __CONDVAR_UNINIT_MAGIC) { - ret = init_condvar(cv, cv->uninit.clockfd, cv->uninit.name); + if (evt->magic == __EVENT_UNINIT_MAGIC) { + ret = init_event(evt, evt->uninit.clockfd, evt->uninit.name); if (ret) return ret; - } else if (cv->magic != __CONDVAR_ACTIVE_MAGIC) + } else if (evt->magic != __EVENT_ACTIVE_MAGIC) return -EINVAL; return 0; } -static struct evl_monitor_state *get_lock_state(struct evl_condvar *cv) +static struct evl_monitor_state *get_lock_state(struct evl_event *evt) { - struct evl_monitor_state *est = cv->active.state; + struct evl_monitor_state *est = evt->active.state; if (est->u.event.gate_offset == EVL_MONITOR_NOGATE) - return NULL; /* Nobody waits on @cv */ + return NULL; /* Nobody waits on @evt */ return evl_shared_memory + est->u.event.gate_offset; } @@ -184,7 +184,7 @@ struct unwait_data { int efd; }; -static void unwait_condvar(void *data) +static void unwait_event(void *data) { struct unwait_data *unwait = data; int ret; @@ -195,15 +195,15 @@ static void unwait_condvar(void *data) while (ret && errno == EINTR); } -int evl_timedwait(struct evl_condvar *cv, - struct evl_mutex *mutex, - const struct timespec *timeout) +int evl_timedwait_event(struct evl_event *evt, + struct evl_mutex *mutex, + const struct timespec *timeout) { struct evl_monitor_waitreq req; struct unwait_data unwait; int ret, old_type; - ret = check_condvar_sanity(cv); + ret = check_event_sanity(evt); if (ret) return ret; @@ -212,89 +212,89 @@ int evl_timedwait(struct evl_condvar *cv, req.status = -EINVAL; req.value = 0; /* dummy */ unwait.ureq.gatefd = req.gatefd; - unwait.efd = cv->active.efd; + unwait.efd = evt->active.efd; - pthread_cleanup_push(unwait_condvar, &unwait); + pthread_cleanup_push(unwait_event, &unwait); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old_type); - ret = oob_ioctl(cv->active.efd, EVL_MONIOC_WAIT, &req); + ret = oob_ioctl(evt->active.efd, EVL_MONIOC_WAIT, &req); pthread_setcanceltype(old_type, NULL); pthread_cleanup_pop(0); /* * If oob_ioctl() failed with EINTR, we got forcibly unblocked - * while waiting for the condvar or trying to reacquire the lock + * while waiting for the event or trying to reacquire the lock * afterwards, in which case the mutex was left * unlocked. Issue UNWAIT to recover from that situation. */ if (ret && errno == EINTR) { - unwait_condvar(&unwait); + unwait_event(&unwait); pthread_testcancel(); } return ret ? -errno : req.status; } -int evl_wait(struct evl_condvar *cv, struct evl_mutex *mutex) +int evl_wait_event(struct evl_event *evt, struct evl_mutex *mutex) { struct timespec timeout = { .tv_sec = 0, .tv_nsec = 0 }; - return evl_timedwait(cv, mutex, &timeout); + return evl_timedwait_event(evt, mutex, &timeout); } -int evl_signal(struct evl_condvar *cv) +int evl_signal_event(struct evl_event *evt) { struct evl_monitor_state *est, *gst; int ret; - ret = check_condvar_sanity(cv); + ret = check_event_sanity(evt); if (ret) return ret; - gst = get_lock_state(cv); + gst = get_lock_state(evt); if (gst) { gst->flags |= EVL_MONITOR_SIGNALED; - est = cv->active.state; + est = evt->active.state; est->flags |= EVL_MONITOR_SIGNALED; } return 0; } -int evl_signal_thread(struct evl_condvar *cv, int thrfd) +int evl_signal_thread(struct evl_event *evt, int thrfd) { struct evl_monitor_state *gst; __u32 efd; int ret; - ret = check_condvar_sanity(cv); + ret = check_event_sanity(evt); if (ret) return ret; - gst = get_lock_state(cv); + gst = get_lock_state(evt); if (gst) { gst->flags |= EVL_MONITOR_SIGNALED; - efd = cv->active.efd; + efd = evt->active.efd; return oob_ioctl(thrfd, EVL_THRIOC_SIGNAL, &efd) ? -errno : 0; } - /* No thread waits on @cv, so @thrfd neither => nop. */ + /* No thread waits on @evt, so @thrfd neither => nop. */ return 0; } -int evl_broadcast(struct evl_condvar *cv) +int evl_broadcast_event(struct evl_event *evt) { struct evl_monitor_state *est, *gst; int ret; - ret = check_condvar_sanity(cv); + ret = check_event_sanity(evt); if (ret) return ret; - gst = get_lock_state(cv); + gst = get_lock_state(evt); if (gst) { gst->flags |= EVL_MONITOR_SIGNALED; - est = cv->active.state; + est = evt->active.state; est->flags |= EVL_MONITOR_SIGNALED|EVL_MONITOR_BROADCAST; } diff --git a/lib/flags.c b/lib/flags.c index 57bd333..34dfd2c 100644 --- a/lib/flags.c +++ b/lib/flags.c @@ -122,9 +122,9 @@ static int check_sanity(struct evl_flags *flg) { if (flg->magic == __FLAGS_UNINIT_MAGIC) return evl_new_flags(flg, - flg->uninit.clockfd, - flg->uninit.initval, - flg->uninit.name); + flg->uninit.clockfd, + flg->uninit.initval, + flg->uninit.name); return flg->magic != __FLAGS_ACTIVE_MAGIC ? -EINVAL : 0; } diff --git a/lib/init.c b/lib/init.c index 6fa5835..8312870 100644 --- a/lib/init.c +++ b/lib/init.c @@ -96,7 +96,7 @@ static inline int generic_init(void) goto fail; shmem = mmap(NULL, core_info.shm_size, PROT_READ|PROT_WRITE, - MAP_SHARED, ctlfd, 0); + MAP_SHARED, ctlfd, 0); if (shmem == MAP_FAILED) { ret = -errno; goto fail; @@ -115,7 +115,7 @@ fail: int evl_sigevl_handler(int sig, siginfo_t *si, void *ctxt) { if (si->si_code == SI_QUEUE && - sigevl_action(si->si_int) == SIGEVL_ACTION_HOME) { + sigevl_action(si->si_int) == SIGEVL_ACTION_HOME) { oob_ioctl(evl_efd, EVL_THRIOC_SWITCH_OOB); return 1; } @@ -170,7 +170,7 @@ static void sigevl_handler(int sig, siginfo_t *si, void *ctxt) return; if ((!(sa->sa_flags & SA_SIGINFO) && sa->sa_handler == NULL) || - ((sa->sa_flags & SA_SIGINFO) && sa->sa_sigaction == NULL)) + ((sa->sa_flags & SA_SIGINFO) && sa->sa_sigaction == NULL)) return; /* Not sent by the EVL core */ pthread_sigmask(SIG_SETMASK, &sa->sa_mask, &omask); diff --git a/lib/internal.c b/lib/internal.c index 63289c1..57e8679 100644 --- a/lib/internal.c +++ b/lib/internal.c @@ -30,7 +30,7 @@ * an element causes its automatic deletion. */ int create_evl_element(const char *type, const char *name, - void *attrs, struct evl_element_ids *eids) + void *attrs, struct evl_element_ids *eids) { struct evl_clone_req clone; char *fdevname, *edevname; diff --git a/lib/mutex.c b/lib/mutex.c index 42aa6f0..605b8fa 100644 --- a/lib/mutex.c +++ b/lib/mutex.c @@ -79,8 +79,8 @@ static int init_mutex_vargs(struct evl_mutex *mutex, } static int init_mutex(struct evl_mutex *mutex, - int protocol, int clockfd, unsigned int ceiling, - const char *fmt, ...) + int protocol, int clockfd, unsigned int ceiling, + const char *fmt, ...) { va_list ap; int ret; @@ -253,8 +253,8 @@ static int try_lock(struct evl_mutex *mutex) return -ENODATA; } -int evl_timedlock(struct evl_mutex *mutex, - const struct timespec *timeout) +int evl_timedlock_mutex(struct evl_mutex *mutex, + const struct timespec *timeout) { struct evl_monitor_lockreq lreq; int ret, cancel_type; @@ -276,14 +276,14 @@ int evl_timedlock(struct evl_mutex *mutex, return ret ? -errno : 0; } -int evl_lock(struct evl_mutex *mutex) +int evl_lock_mutex(struct evl_mutex *mutex) { struct timespec timeout = { .tv_sec = 0, .tv_nsec = 0 }; - return evl_timedlock(mutex, &timeout); + return evl_timedlock_mutex(mutex, &timeout); } -int evl_trylock(struct evl_mutex *mutex) +int evl_trylock_mutex(struct evl_mutex *mutex) { int ret; @@ -298,7 +298,7 @@ int evl_trylock(struct evl_mutex *mutex) return ret ? -errno : 0; } -int evl_unlock(struct evl_mutex *mutex) +int evl_unlock_mutex(struct evl_mutex *mutex) { struct evl_user_window *u_window; struct evl_monitor_state *gst; @@ -313,7 +313,7 @@ int evl_unlock(struct evl_mutex *mutex) if (!evl_is_mutex_owner(&gst->u.gate.owner, current)) return -EPERM; - /* Do we have waiters on a signaled condvar we are gating? */ + /* Do we have waiters on a signaled event we are gating? */ if (gst->flags & EVL_MONITOR_SIGNALED) goto slow_path; diff --git a/lib/sem.c b/lib/sem.c index 6e17938..99a61ac 100644 --- a/lib/sem.c +++ b/lib/sem.c @@ -122,9 +122,9 @@ static int check_sanity(struct evl_sem *sem) { if (sem->magic == __SEM_UNINIT_MAGIC) return evl_new_sem(sem, - sem->uninit.clockfd, - sem->uninit.initval, - sem->uninit.name); + sem->uninit.clockfd, + sem->uninit.initval, + sem->uninit.name); return sem->magic != __SEM_ACTIVE_MAGIC ? -EINVAL : 0; } @@ -160,7 +160,7 @@ static int try_get(struct evl_monitor_state *state) return 0; } -int evl_timedget(struct evl_sem *sem, const struct timespec *timeout) +int evl_timedget_sem(struct evl_sem *sem, const struct timespec *timeout) { struct evl_monitor_state *state; struct evl_monitor_waitreq req; @@ -199,14 +199,14 @@ int evl_timedget(struct evl_sem *sem, const struct timespec *timeout) return ret ? -errno : req.status; } -int evl_get(struct evl_sem *sem) +int evl_get_sem(struct evl_sem *sem) { struct timespec timeout = { .tv_sec = 0, .tv_nsec = 0 }; - return evl_timedget(sem, &timeout); + return evl_timedget_sem(sem, &timeout); } -int evl_tryget(struct evl_sem *sem) +int evl_tryget_sem(struct evl_sem *sem) { int ret; @@ -217,7 +217,7 @@ int evl_tryget(struct evl_sem *sem) return try_get(sem->active.state); } -int evl_put(struct evl_sem *sem) +int evl_put_sem(struct evl_sem *sem) { struct evl_monitor_state *state; int val, prev, next, ret; @@ -250,7 +250,7 @@ int evl_put(struct evl_sem *sem) return 0; } -int evl_getval(struct evl_sem *sem) +int evl_peek_sem(struct evl_sem *sem) { if (sem->magic != __SEM_ACTIVE_MAGIC) return -EINVAL; diff --git a/lib/xbuf.c b/lib/xbuf.c index f50029f..d6554dd 100644 --- a/lib/xbuf.c +++ b/lib/xbuf.c @@ -12,7 +12,7 @@ #include "internal.h" int evl_new_xbuf(size_t i_bufsz, size_t o_bufsz, - const char *fmt, ...) + const char *fmt, ...) { struct evl_xbuf_attrs attrs; int ret, efd; diff --git a/tests/monitor-flags.c b/tests/monitor-flags.c index 5b8d33f..fbdd68f 100644 --- a/tests/monitor-flags.c +++ b/tests/monitor-flags.c @@ -30,7 +30,7 @@ static void *flags_receiver(void *arg) int ret, tfd, bits; __Tcall_assert(tfd, evl_attach_self("monitor-flags-receiver:%d", getpid())); - __Tcall_assert(ret, evl_get(&p->start)); + __Tcall_assert(ret, evl_get_sem(&p->start)); evl_read_clock(EVL_CLOCK_MONOTONIC, &now); timespec_add_ns(&timeout, &now, 200000000); /* 200ms */ @@ -39,7 +39,7 @@ static void *flags_receiver(void *arg) !__Texpr(ret == -ETIMEDOUT)) goto fail; - __Tcall_assert(ret, evl_put(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->sem)); /* Sender should have sent 0x12121212. */ if (!__Tcall(ret, evl_timedwait_flags(&p->flags, &timeout, &bits))) @@ -62,7 +62,7 @@ static void *flags_receiver(void *arg) if (!__Texpr(ret == -EAGAIN)) goto fail; - __Tcall_assert(ret, evl_put(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->sem)); /* Sender should send 0x76767676 in a moment. */ if (!__Tcall(ret, evl_wait_flags(&p->flags, &bits))) @@ -71,7 +71,7 @@ static void *flags_receiver(void *arg) if (!__Texpr(bits == 0x76767676)) goto fail; - __Tcall_assert(ret, evl_put(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->sem)); return NULL; fail: @@ -106,15 +106,15 @@ int main(int argc, char *argv[]) new_thread(&receiver, SCHED_FIFO, LOW_PRIO, flags_receiver, &c); - __Tcall_assert(ret, evl_put(&c.start)); - __Tcall_assert(ret, evl_get(&c.sem)); + __Tcall_assert(ret, evl_put_sem(&c.start)); + __Tcall_assert(ret, evl_get_sem(&c.sem)); __Tcall_assert(ret, evl_post_flags(&c.flags, 0x12121212)); __Tcall_assert(ret, evl_peek_flags(&c.flags, &bits)); __Texpr_assert(bits == 0x12121212); - __Tcall_assert(ret, evl_get(&c.sem)); + __Tcall_assert(ret, evl_get_sem(&c.sem)); __Tcall_assert(ret, evl_udelay(1000)); __Tcall_assert(ret, evl_post_flags(&c.flags, 0x76767676)); - __Tcall_assert(ret, evl_get(&c.sem)); + __Tcall_assert(ret, evl_get_sem(&c.sem)); __Texpr_assert(pthread_join(receiver, &status) == 0); __Texpr_assert(status == NULL); diff --git a/tests/monitor-pi.c b/tests/monitor-pi.c index 13bf058..3dd0adc 100644 --- a/tests/monitor-pi.c +++ b/tests/monitor-pi.c @@ -30,14 +30,14 @@ static void *pi_contend_timeout(void *arg) int ret, tfd; __Tcall_assert(tfd, evl_attach_self("monitor-pi-contend:%d", getpid())); - __Tcall_assert(ret, evl_get(&p->start)); + __Tcall_assert(ret, evl_get_sem(&p->start)); evl_read_clock(EVL_CLOCK_MONOTONIC, &now); timespec_add_ns(&timeout, &now, 200000000); /* 200ms */ - __Tcall_assert(ret, evl_put(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->sem)); - if (__Fcall(ret, evl_timedlock(&p->lock, &timeout)) && + if (__Fcall(ret, evl_timedlock_mutex(&p->lock, &timeout)) && __Texpr(ret == -ETIMEDOUT)) return (void *)1; @@ -83,12 +83,12 @@ int main(int argc, char *argv[]) new_thread(&contender, SCHED_FIFO, HIGH_PRIO, pi_contend_timeout, &c); - __Tcall_assert(ret, evl_lock(&c.lock)); - __Tcall_assert(ret, evl_put(&c.start)); - __Tcall_assert(ret, evl_get(&c.sem)); + __Tcall_assert(ret, evl_lock_mutex(&c.lock)); + __Tcall_assert(ret, evl_put_sem(&c.start)); + __Tcall_assert(ret, evl_get_sem(&c.sem)); __Texpr_assert(check_priority(tfd, HIGH_PRIO)); __Texpr_assert(pthread_join(contender, &status) == 0); - __Tcall_assert(ret, evl_unlock(&c.lock)); + __Tcall_assert(ret, evl_unlock_mutex(&c.lock)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); __Fexpr_assert(status == NULL); diff --git a/tests/monitor-pp-dynamic.c b/tests/monitor-pp-dynamic.c index 314ef65..86dc498 100644 --- a/tests/monitor-pp-dynamic.c +++ b/tests/monitor-pp-dynamic.c @@ -45,17 +45,17 @@ int main(int argc, char *argv[]) name = get_unique_name(EVL_MONITOR_DEV, 0); __Tcall_assert(gfd, evl_new_mutex_ceiling(&lock, EVL_CLOCK_MONOTONIC, LOW_PRIO, name)); - __Tcall_assert(ret, evl_lock(&lock)); + __Tcall_assert(ret, evl_lock_mutex(&lock)); /* Commit PP boost, no priority change expected. */ __Tcall_assert(ret, evl_udelay(1000)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); __Tcall_assert(ret, evl_set_mutex_ceiling(&lock, HIGH_PRIO)); - __Tcall_assert(ret, evl_lock(&lock)); + __Tcall_assert(ret, evl_lock_mutex(&lock)); /* Commit PP boost, should be boosted to HIGH_PRIO. */ __Tcall_assert(ret, evl_udelay(1000)); __Texpr_assert(check_priority(tfd, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); evl_close_mutex(&lock); diff --git a/tests/monitor-pp-lower.c b/tests/monitor-pp-lower.c index 7c05e93..3572f72 100644 --- a/tests/monitor-pp-lower.c +++ b/tests/monitor-pp-lower.c @@ -45,11 +45,11 @@ int main(int argc, char *argv[]) name = get_unique_name(EVL_MONITOR_DEV, 0); __Tcall_assert(gfd, evl_new_mutex_ceiling(&lock, EVL_CLOCK_MONOTONIC, LOW_PRIO, name)); - __Tcall_assert(ret, evl_lock(&lock)); + __Tcall_assert(ret, evl_lock_mutex(&lock)); /* Commit PP, no priority change expected. */ __Tcall_assert(ret, evl_udelay(1000)); __Texpr_assert(check_priority(tfd, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); __Texpr_assert(check_priority(tfd, HIGH_PRIO)); evl_close_mutex(&lock); diff --git a/tests/monitor-pp-nested.c b/tests/monitor-pp-nested.c index 468ae59..cedfe55 100644 --- a/tests/monitor-pp-nested.c +++ b/tests/monitor-pp-nested.c @@ -51,17 +51,17 @@ int main(int argc, char *argv[]) __Tcall_assert(gfd, evl_new_mutex_ceiling(&lock_high, EVL_CLOCK_MONOTONIC, HIGH_PRIO, name)); - __Tcall_assert(ret, evl_lock(&lock_medium)); + __Tcall_assert(ret, evl_lock_mutex(&lock_medium)); /* Commit PP, expected switch to medium priority. */ __Tcall_assert(ret, evl_udelay(1000)); __Texpr_assert(check_priority(tfd, MEDIUM_PRIO)); - __Tcall_assert(ret, evl_lock(&lock_high)); + __Tcall_assert(ret, evl_lock_mutex(&lock_high)); /* Commit PP, expected switch to high priority. */ __Tcall_assert(ret, evl_udelay(1000)); __Texpr_assert(check_priority(tfd, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock_high)); + __Tcall_assert(ret, evl_unlock_mutex(&lock_high)); __Texpr_assert(check_priority(tfd, MEDIUM_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock_medium)); + __Tcall_assert(ret, evl_unlock_mutex(&lock_medium)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); evl_close_mutex(&lock_high); diff --git a/tests/monitor-pp-pi.c b/tests/monitor-pp-pi.c index 9643bbd..f2d2768 100644 --- a/tests/monitor-pp-pi.c +++ b/tests/monitor-pp-pi.c @@ -31,14 +31,14 @@ static void *pi_contend_timeout(void *arg) int ret, tfd; __Tcall_assert(tfd, evl_attach_self("monitor-pi-contend:%d", getpid())); - __Tcall_assert(ret, evl_get(&p->start)); + __Tcall_assert(ret, evl_get_sem(&p->start)); evl_read_clock(EVL_CLOCK_MONOTONIC, &now); timespec_add_ns(&timeout, &now, 10000000); /* 10ms */ - __Tcall_assert(ret, evl_put(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->sem)); - if (__Fcall(ret, evl_timedlock(&p->lock, &timeout)) && + if (__Fcall(ret, evl_timedlock_mutex(&p->lock, &timeout)) && __Texpr(ret == -ETIMEDOUT)) return (void *)1; @@ -89,18 +89,18 @@ int main(int argc, char *argv[]) new_thread(&contender, SCHED_FIFO, HIGH_PRIO, pi_contend_timeout, &c); - __Tcall_assert(ret, evl_lock(&lock_pp)); + __Tcall_assert(ret, evl_lock_mutex(&lock_pp)); __Tcall_assert(ret, evl_udelay(1000)); /* Commit PP boost. */ __Texpr_assert(check_priority(tfd, MEDIUM_PRIO)); - __Tcall_assert(ret, evl_lock(&c.lock)); - __Tcall_assert(ret, evl_put(&c.start)); - __Tcall_assert(ret, evl_get(&c.sem)); + __Tcall_assert(ret, evl_lock_mutex(&c.lock)); + __Tcall_assert(ret, evl_put_sem(&c.start)); + __Tcall_assert(ret, evl_get_sem(&c.sem)); __Texpr_assert(check_priority(tfd, HIGH_PRIO)); __Texpr_assert(pthread_join(contender, &status) == 0); - __Tcall_assert(ret, evl_unlock(&c.lock)); + __Tcall_assert(ret, evl_unlock_mutex(&c.lock)); __Texpr_assert(check_priority(tfd, MEDIUM_PRIO)); __Fexpr_assert(status == NULL); - __Tcall_assert(ret, evl_unlock(&lock_pp)); + __Tcall_assert(ret, evl_unlock_mutex(&lock_pp)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); evl_close_sem(&c.start); diff --git a/tests/monitor-pp-raise.c b/tests/monitor-pp-raise.c index 0ef4f6a..4ab3617 100644 --- a/tests/monitor-pp-raise.c +++ b/tests/monitor-pp-raise.c @@ -46,10 +46,10 @@ int main(int argc, char *argv[]) __Tcall_assert(gfd, evl_new_mutex_ceiling(&lock, EVL_CLOCK_MONOTONIC, HIGH_PRIO, name)); - __Tcall_assert(ret, evl_lock(&lock)); + __Tcall_assert(ret, evl_lock_mutex(&lock)); __Tcall_assert(ret, evl_udelay(1000)); /* Commit PP boost. */ __Texpr_assert(check_priority(tfd, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); evl_close_mutex(&lock); diff --git a/tests/monitor-pp-tryenter.c b/tests/monitor-pp-tryenter.c index a181efb..cf7c64d 100644 --- a/tests/monitor-pp-tryenter.c +++ b/tests/monitor-pp-tryenter.c @@ -48,18 +48,18 @@ int main(int argc, char *argv[]) /* Taking the fast locking path requires running OOB. */ __Tcall_assert(ret, evl_switch_oob()); - __Tcall_assert(ret, evl_lock(&lock)); - __Texpr_assert(evl_trylock(&lock) == -EDEADLK); + __Tcall_assert(ret, evl_lock_mutex(&lock)); + __Texpr_assert(evl_trylock_mutex(&lock) == -EDEADLK); __Tcall_assert(ret, evl_udelay(1000)); /* Commit PP boost. */ __Texpr_assert(check_priority(tfd, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); /* Force inband in order to skip the fast locking path. */ __Tcall_assert(ret, evl_switch_inband()); - __Tcall_assert(ret, evl_trylock(&lock)); + __Tcall_assert(ret, evl_trylock_mutex(&lock)); /* The slow path must have enforced the ceiling. */ __Texpr_assert(check_priority(tfd, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); __Texpr_assert(check_priority(tfd, LOW_PRIO)); evl_close_mutex(&lock); diff --git a/tests/monitor-pp-weak.c b/tests/monitor-pp-weak.c index 4309870..89444e4 100644 --- a/tests/monitor-pp-weak.c +++ b/tests/monitor-pp-weak.c @@ -45,11 +45,11 @@ int main(int argc, char *argv[]) __Tcall_assert(gfd, evl_new_mutex_ceiling(&lock, EVL_CLOCK_MONOTONIC, HIGH_PRIO, name)); - __Tcall_assert(ret, evl_lock(&lock)); + __Tcall_assert(ret, evl_lock_mutex(&lock)); /* Commit PP, we should have inherited SCHED_FIFO, HIGH_PRIO. */ __Tcall_assert(ret, evl_udelay(1000)); __Texpr_assert(check_priority(tfd, SCHED_FIFO, HIGH_PRIO)); - __Tcall_assert(ret, evl_unlock(&lock)); + __Tcall_assert(ret, evl_unlock_mutex(&lock)); __Texpr_assert(check_priority(tfd, SCHED_WEAK, LOW_PRIO)); evl_close_mutex(&lock); diff --git a/tests/monitor-steal.c b/tests/monitor-steal.c index 95cbea5..04486f9 100644 --- a/tests/monitor-steal.c +++ b/tests/monitor-steal.c @@ -37,15 +37,15 @@ static void *victim(void *arg) */ close(tfd); - if (!__Tcall(ret, evl_get(&p->start))) + if (!__Tcall(ret, evl_get_sem(&p->start))) return (void *)(long)ret; - if (!__Tcall(ret, evl_lock(&p->lock))) + if (!__Tcall(ret, evl_lock_mutex(&p->lock))) return (void *)(long)ret; p->acquired = true; - if (!__Tcall(ret, evl_unlock(&p->lock))) + if (!__Tcall(ret, evl_unlock_mutex(&p->lock))) return (void *)(long)ret; return NULL; @@ -68,9 +68,9 @@ static void test_steal(bool do_steal) new_thread(&contender, SCHED_FIFO, LOW_PRIO, victim, &c); - __Tcall_assert(ret, evl_lock(&c.lock)); + __Tcall_assert(ret, evl_lock_mutex(&c.lock)); - __Tcall_assert(ret, evl_put(&c.start)); + __Tcall_assert(ret, evl_put_sem(&c.start)); /* * Wait for the victim to block on the lock. Sleep for 200ms @@ -83,18 +83,18 @@ static void test_steal(bool do_steal) * priority so it can't resume just yet. If @do_steal is true, * we should be able to steal the lock from it. */ - __Tcall_assert(ret, evl_unlock(&c.lock)); + __Tcall_assert(ret, evl_unlock_mutex(&c.lock)); if (do_steal) { - __Tcall_assert(ret, evl_lock(&c.lock)); /* Steal it. */ + __Tcall_assert(ret, evl_lock_mutex(&c.lock)); /* Steal it. */ __Fexpr_assert(c.acquired); } else { evl_udelay(200000); - __Tcall_assert(ret, evl_lock(&c.lock)); + __Tcall_assert(ret, evl_lock_mutex(&c.lock)); __Texpr_assert(c.acquired); } - __Tcall_assert(ret, evl_unlock(&c.lock)); + __Tcall_assert(ret, evl_unlock_mutex(&c.lock)); __Texpr_assert(pthread_join(contender, &status) == 0); __Texpr_assert(status == NULL); diff --git a/tests/sem-close-unblock.c b/tests/sem-close-unblock.c index 94d8c7e..6c5813d 100644 --- a/tests/sem-close-unblock.c +++ b/tests/sem-close-unblock.c @@ -24,10 +24,10 @@ static void *sem_contend(void *arg) int ret, tfd; __Tcall_assert(tfd, evl_attach_self("sem-unblock-contend:%d", getpid())); - __Tcall_assert(ret, evl_put(&p->start)); - __Fcall_assert(ret, evl_get(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->start)); + __Fcall_assert(ret, evl_get_sem(&p->sem)); __Texpr_assert(ret == -EIDRM); - __Fcall_assert(ret, evl_get(&p->sem)); + __Fcall_assert(ret, evl_get_sem(&p->sem)); __Texpr_assert(ret == -EBADF); return NULL; @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) __Tcall_assert(sfd, evl_new_sem(&c.start, EVL_CLOCK_MONOTONIC, 0, name)); new_thread(&contender, SCHED_FIFO, 1, sem_contend, &c); - __Tcall_assert(ret, evl_get(&c.start)); + __Tcall_assert(ret, evl_get_sem(&c.start)); __Tcall_assert(ret, evl_close_sem(&c.sem)); pthread_join(contender, NULL); diff --git a/tests/sem-timedwait.c b/tests/sem-timedwait.c index 6a941ea..aa16ab4 100644 --- a/tests/sem-timedwait.c +++ b/tests/sem-timedwait.c @@ -26,7 +26,7 @@ static void *sem_contend(void *arg) __Tcall_assert(tfd, evl_attach_self("sem-wait-contend:%d", getpid())); __Tcall_assert(ret, evl_read_clock(EVL_CLOCK_MONOTONIC, &now)); timespec_add_ns(&timeout, &now, 10000000); /* 10ms */ - __Fcall_assert(ret, evl_timedget(&p->sem, &timeout)); + __Fcall_assert(ret, evl_timedget_sem(&p->sem, &timeout)); __Texpr_assert(ret == -ETIMEDOUT); return NULL; diff --git a/tests/sem-wait.c b/tests/sem-wait.c index b65272c..abd2e05 100644 --- a/tests/sem-wait.c +++ b/tests/sem-wait.c @@ -23,7 +23,7 @@ static void *sem_contend(void *arg) int ret, tfd; __Tcall_assert(tfd, evl_attach_self("sem-wait-contend:%d", getpid())); - __Tcall_assert(ret, evl_put(&p->sem)); + __Tcall_assert(ret, evl_put_sem(&p->sem)); return NULL; } @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) __Tcall_assert(sfd, evl_new_sem(&c.sem, EVL_CLOCK_MONOTONIC, 0, name)); new_thread(&contender, SCHED_FIFO, 1, sem_contend, &c); - __Tcall_assert(ret, evl_get(&c.sem)); + __Tcall_assert(ret, evl_get_sem(&c.sem)); pthread_join(contender, NULL); evl_close_sem(&c.sem);