oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Macros
OVE_*_DEFINE_STATIC Macros

One-step static primitive declaration with automatic initialisation. More...

Collaboration diagram for OVE_*_DEFINE_STATIC Macros:

Macros

#define OVE_MUTEX_DEFINE_STATIC(name)
 Declare and auto-initialise a static mutex (heap mode).
 
#define OVE_RECURSIVE_MUTEX_DEFINE_STATIC(name)
 Declare and auto-initialise a static recursive mutex (heap mode).
 
#define OVE_SEM_DEFINE_STATIC(name, initial, max)
 Declare and auto-initialise a static semaphore (heap mode).
 
#define OVE_EVENT_DEFINE_STATIC(name)
 Declare and auto-initialise a static event object (heap mode).
 
#define OVE_CONDVAR_DEFINE_STATIC(name)
 Declare and auto-initialise a static condition variable (heap mode).
 
#define OVE_THREAD_DEFINE_STATIC(hname, stack_sz, fn, ctx, prio, tname)
 Declare and auto-initialise a static thread (heap mode).
 
#define OVE_QUEUE_DEFINE_STATIC(name, item_sz, max)
 Declare and auto-initialise a static message queue (heap mode).
 
#define OVE_TIMER_DEFINE_STATIC(name, cb, user_data, period_ms, one_shot)
 Declare and auto-initialise a static timer (heap mode).
 
#define OVE_EVENTGROUP_DEFINE_STATIC(name)
 Declare and auto-initialise a static event group (heap mode).
 
#define OVE_WORKQUEUE_DEFINE_STATIC(name, stack_sz, wq_name, prio)
 Declare and auto-initialise a static work queue (heap mode).
 
#define OVE_WORK_DEFINE_STATIC(name, handler)
 Declare and auto-initialise a static work item (heap mode).
 
#define OVE_STREAM_DEFINE_STATIC(name, buf_sz, trigger)
 Declare and auto-initialise a static stream buffer (heap mode).
 
#define OVE_WATCHDOG_DEFINE_STATIC(name, timeout_ms)
 Declare and auto-initialise a static watchdog timer (heap mode).
 

Detailed Description

One-step static primitive declaration with automatic initialisation.

Each macro declares a handle and a C constructor (__attribute__((constructor))) that initialises the handle before main(). No runtime init boilerplate or #ifdef guards are needed.

Usage:

OVE_QUEUE_DEFINE_STATIC(my_q, sizeof(int), 8);
// my_q is ready to use in any function.
#define OVE_QUEUE_DEFINE_STATIC(name, item_sz, max)
Declare and auto-initialise a static message queue (heap mode).
Definition storage.h:839

Macro Definition Documentation

◆ OVE_MUTEX_DEFINE_STATIC

#define OVE_MUTEX_DEFINE_STATIC (   name)
Value:
static ove_mutex_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_mutex_create(&name); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_mutex * ove_mutex_t
Opaque handle for a mutex object.
Definition types.h:85

Declare and auto-initialise a static mutex (heap mode).

Parameters
nameVariable name for the resulting ove_mutex_t handle.

◆ OVE_RECURSIVE_MUTEX_DEFINE_STATIC

#define OVE_RECURSIVE_MUTEX_DEFINE_STATIC (   name)
Value:
static ove_mutex_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_recursive_mutex_create(&name); \
OVE_DEFINE_STATIC_CTOR_END_(name)

Declare and auto-initialise a static recursive mutex (heap mode).

Parameters
nameVariable name for the resulting ove_mutex_t handle.

◆ OVE_SEM_DEFINE_STATIC

#define OVE_SEM_DEFINE_STATIC (   name,
  initial,
  max 
)
Value:
static ove_sem_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_sem_create(&name, (initial), (max)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_sem * ove_sem_t
Opaque handle for a counting semaphore object.
Definition types.h:88

Declare and auto-initialise a static semaphore (heap mode).

Parameters
nameVariable name for the resulting ove_sem_t handle.
initialInitial semaphore count.
maxMaximum semaphore count.

◆ OVE_EVENT_DEFINE_STATIC

#define OVE_EVENT_DEFINE_STATIC (   name)
Value:
static ove_event_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_event_create(&name); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_event * ove_event_t
Opaque handle for a binary event (signal/wait) object.
Definition types.h:91

Declare and auto-initialise a static event object (heap mode).

Parameters
nameVariable name for the resulting ove_event_t handle.

◆ OVE_CONDVAR_DEFINE_STATIC

#define OVE_CONDVAR_DEFINE_STATIC (   name)
Value:
static ove_condvar_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_condvar_create(&name); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_condvar * ove_condvar_t
Opaque handle for a condition variable object.
Definition types.h:94

Declare and auto-initialise a static condition variable (heap mode).

Parameters
nameVariable name for the resulting ove_condvar_t handle.

◆ OVE_THREAD_DEFINE_STATIC

#define OVE_THREAD_DEFINE_STATIC (   hname,
  stack_sz,
  fn,
  ctx,
  prio,
  tname 
)
Value:
static ove_thread_t hname; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(hname) \
struct ove_thread_desc _desc = { \
.name = (tname), \
.entry = (fn), \
.arg = (ctx), \
.priority = (prio), \
.stack_size = (stack_sz), \
}; \
int _err = ove_thread_create_(&hname, &_desc); \
OVE_DEFINE_STATIC_CTOR_END_(hname)
int ove_thread_create_(ove_thread_t *handle, const struct ove_thread_desc *desc)
Internal heap-backed thread creation function.
struct ove_thread * ove_thread_t
Opaque handle for a thread object.
Definition types.h:82
Thread creation descriptor passed to ove_thread_init() / ove_thread_create().
Definition thread.h:81
ove_thread_fn entry
Thread entry-point function. Must not be NULL.
Definition thread.h:83
const char * name
Human-readable thread name (may be truncated by backend).
Definition thread.h:82
ove_prio_t priority
Scheduling priority.
Definition thread.h:85

Declare and auto-initialise a static thread (heap mode).

Parameters
hnameVariable name for the resulting ove_thread_t handle.
stack_szThread stack size in bytes.
fnThread entry function.
ctxArgument passed to fn.
prioThread priority.
tnameHuman-readable thread name string.

◆ OVE_QUEUE_DEFINE_STATIC

#define OVE_QUEUE_DEFINE_STATIC (   name,
  item_sz,
  max 
)
Value:
static ove_queue_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_queue_create(&name, (item_sz), (max)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_queue * ove_queue_t
Opaque handle for a message queue object.
Definition queue.h:39
int ove_queue_create(ove_queue_t *q, size_t item_size, unsigned int max_items)
Allocate and initialise a queue from the heap.

Declare and auto-initialise a static message queue (heap mode).

Parameters
nameVariable name for the resulting ove_queue_t handle.
item_szSize of each queue item in bytes.
maxMaximum number of items in the queue.

◆ OVE_TIMER_DEFINE_STATIC

#define OVE_TIMER_DEFINE_STATIC (   name,
  cb,
  user_data,
  period_ms,
  one_shot 
)
Value:
static ove_timer_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_timer_create(&name, \
(cb), (user_data), (period_ms), (one_shot)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
int ove_timer_create(ove_timer_t *timer, ove_timer_fn callback, void *user_data, uint32_t period_ms, int one_shot)
Allocate and initialise a software timer from the heap.
struct ove_timer * ove_timer_t
Opaque handle for a software timer object.
Definition timer.h:37

Declare and auto-initialise a static timer (heap mode).

Parameters
nameVariable name for the resulting ove_timer_t handle.
cbTimer expiry callback.
user_dataOpaque pointer forwarded to cb.
period_msTimer period in milliseconds.
one_shotNon-zero for a one-shot timer, zero for periodic.

◆ OVE_EVENTGROUP_DEFINE_STATIC

#define OVE_EVENTGROUP_DEFINE_STATIC (   name)
Value:
static ove_eventgroup_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_eventgroup_create(&name); \
OVE_DEFINE_STATIC_CTOR_END_(name)
int ove_eventgroup_create(ove_eventgroup_t *eg)
Allocate and initialise a heap-backed event group.
struct ove_eventgroup * ove_eventgroup_t
Opaque handle for an event-group (bit-field) object.
Definition types.h:97

Declare and auto-initialise a static event group (heap mode).

Parameters
nameVariable name for the resulting ove_eventgroup_t handle.

◆ OVE_WORKQUEUE_DEFINE_STATIC

#define OVE_WORKQUEUE_DEFINE_STATIC (   name,
  stack_sz,
  wq_name,
  prio 
)
Value:
static ove_workqueue_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_workqueue_create(&name, \
(wq_name), (prio), (stack_sz)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_workqueue * ove_workqueue_t
Opaque handle for a work queue object.
Definition types.h:100
int ove_workqueue_create(ove_workqueue_t *wq, const char *name, ove_prio_t priority, size_t stack_size)
Allocate a heap-backed work queue.

Declare and auto-initialise a static work queue (heap mode).

Parameters
nameVariable name for the resulting ove_workqueue_t handle.
stack_szStack size in bytes for the work queue thread.
wq_nameHuman-readable work queue name string.
prioThread priority for the work queue thread.

◆ OVE_WORK_DEFINE_STATIC

#define OVE_WORK_DEFINE_STATIC (   name,
  handler 
)
Value:
static ove_work_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_work_init(&name, (handler)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_work * ove_work_t
Opaque handle for a deferred work item.
Definition types.h:103
int ove_work_init(ove_work_t *work, ove_work_fn handler)
Allocate and initialise a heap-backed work item.

Declare and auto-initialise a static work item (heap mode).

Parameters
nameVariable name for the resulting ove_work_t handle.
handlerWork handler function invoked when the item is executed.

◆ OVE_STREAM_DEFINE_STATIC

#define OVE_STREAM_DEFINE_STATIC (   name,
  buf_sz,
  trigger 
)
Value:
static ove_stream_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_stream_create(&name, \
(buf_sz), (trigger)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
int ove_stream_create(ove_stream_t *stream, size_t size, size_t trigger)
Allocate and initialise a heap-backed stream.
struct ove_stream * ove_stream_t
Opaque handle for a byte-stream (ring-buffer) object.
Definition types.h:106

Declare and auto-initialise a static stream buffer (heap mode).

Parameters
nameVariable name for the resulting ove_stream_t handle.
buf_szStream buffer capacity in bytes.
triggerMinimum bytes required before a blocked reader is unblocked.

◆ OVE_WATCHDOG_DEFINE_STATIC

#define OVE_WATCHDOG_DEFINE_STATIC (   name,
  timeout_ms 
)
Value:
static ove_watchdog_t name; \
OVE_DEFINE_STATIC_CTOR_BEGIN_(name) \
int _err = ove_watchdog_create(&name, (timeout_ms)); \
OVE_DEFINE_STATIC_CTOR_END_(name)
struct ove_watchdog * ove_watchdog_t
Opaque handle for a software watchdog object.
Definition types.h:109
int ove_watchdog_create(ove_watchdog_t *wdt, uint32_t timeout_ms)
Allocate and initialise a heap-backed watchdog timer.

Declare and auto-initialise a static watchdog timer (heap mode).

Parameters
nameVariable name for the resulting ove_watchdog_t handle.
timeout_msWatchdog timeout in milliseconds.