rt 0.17.0

A real-time operating system capable of full preemption
Documentation
#include <rt/notify.h>

void rt_notify_post(struct rt_notify *note)
{
    rt_sem_post(&note->sem);
}

void rt_notify_or(struct rt_notify *note, uint32_t value)
{
    rt_atomic_fetch_or(&note->value, value, RT_ATOMIC_RELAXED);
    rt_notify_post(note);
}

void rt_notify_add(struct rt_notify *note, uint32_t value)
{
    rt_atomic_fetch_add(&note->value, value, RT_ATOMIC_RELAXED);
    rt_notify_post(note);
}

void rt_notify_set(struct rt_notify *note, uint32_t value)
{
    rt_atomic_store(&note->value, value, RT_ATOMIC_RELAXED);
    rt_notify_post(note);
}

uint32_t rt_notify_wait(struct rt_notify *note)
{
    rt_sem_wait(&note->sem);
    return rt_atomic_load(&note->value, RT_ATOMIC_RELAXED);
}

uint32_t rt_notify_wait_clear(struct rt_notify *note, uint32_t clear)
{
    rt_sem_wait(&note->sem);
    return rt_atomic_fetch_and(&note->value, ~clear, RT_ATOMIC_RELAXED);
}

bool rt_notify_trywait(struct rt_notify *note, uint32_t *value)
{
    if (!rt_sem_trywait(&note->sem))
    {
        return false;
    }
    *value = rt_atomic_load(&note->value, RT_ATOMIC_RELAXED);
    return true;
}

bool rt_notify_trywait_clear(struct rt_notify *note, uint32_t *value,
                             uint32_t clear)
{
    if (!rt_sem_trywait(&note->sem))
    {
        return false;
    }
    *value = rt_atomic_fetch_and(&note->value, ~clear, RT_ATOMIC_RELAXED);
    return true;
}

bool rt_notify_timedwait(struct rt_notify *note, uint32_t *value,
                         unsigned long ticks)
{
    if (!rt_sem_timedwait(&note->sem, ticks))
    {
        return false;
    }
    *value = rt_atomic_load(&note->value, RT_ATOMIC_RELAXED);
    return true;
}

bool rt_notify_timedwait_clear(struct rt_notify *note, uint32_t *value,
                               uint32_t clear, unsigned long ticks)
{
    if (!rt_sem_timedwait(&note->sem, ticks))
    {
        return false;
    }
    *value = rt_atomic_fetch_and(&note->value, ~clear, RT_ATOMIC_RELAXED);
    return true;
}