treewide: API update

Improve consistency in naming and disambiguate some calls.
This commit is contained in:
Philippe Gerum 2019-06-12 20:59:49 +02:00
parent 90cacf8f0b
commit f0d37f4730
26 changed files with 230 additions and 230 deletions

View File

@ -1,72 +0,0 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019 Philippe Gerum <rpm@xenomai.org>
*/
#ifndef _EVL_CONDVAR_H
#define _EVL_CONDVAR_H
#include <time.h>
#include <linux/types.h>
#include <evl/atomic.h>
#include <uapi/evl/types.h>
#include <uapi/evl/monitor.h>
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 */

72
include/evl/event.h Normal file
View File

@ -0,0 +1,72 @@
/*
* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019 Philippe Gerum <rpm@xenomai.org>
*/
#ifndef _EVL_EVENT_H
#define _EVL_EVENT_H
#include <time.h>
#include <linux/types.h>
#include <evl/atomic.h>
#include <uapi/evl/types.h>
#include <uapi/evl/monitor.h>
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 */

View File

@ -10,7 +10,7 @@
#include <signal.h>
#include <evl/clock.h>
#include <evl/mutex.h>
#include <evl/condvar.h>
#include <evl/event.h>
#include <evl/sem.h>
#include <evl/syscall.h>
#include <evl/thread.h>
@ -19,7 +19,7 @@
#include <evl/proxy.h>
#include <evl/utils.h>
#define __EVL__ 0 /* API revision */
#define __EVL__ 1 /* API revision */
#ifdef __cplusplus
extern "C" {

View File

@ -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);

View File

@ -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);

View File

@ -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
}

View File

@ -18,7 +18,7 @@
#include <sched.h>
#include <evl/evl.h>
#include <evl/mutex.h>
#include <evl/condvar.h>
#include <evl/event.h>
#include <evl/thread.h>
#include <evl/syscall.h>
#include <linux/types.h>
@ -26,10 +26,10 @@
#include <uapi/evl/mutex.h>
#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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);