oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
17#ifndef OVE_TYPES_H
18#define OVE_TYPES_H
19
20#include <stddef.h>
21#include <stdint.h>
22
23#if !defined(__GNUC__) && !defined(__clang__)
24#error "oveRTOS requires a GCC-compatible compiler (gcc or clang). Other toolchains (MSVC, etc.) are not supported: the substrate uses __attribute__ extensions, statement expressions, and other GCC-flavoured features throughout."
25#endif
26
27/*
28 * Public-API annotation macros.
29 *
30 * The skip-list (bindgen / Zig @cImport / Emscripten / clang-tidy lint)
31 * mirrors heap_assert.h: those tools either don't grok the attribute
32 * cleanly or never produce a binary the annotation could affect, so
33 * expand to nothing there. Mirroring the existing pattern keeps the
34 * tooling surface consistent.
35 */
36#if defined(__BINDGEN__) || defined(__ZIG_CIMPORT__) || defined(__EMSCRIPTEN__) || \
37 defined(__OVE_LINT__)
38#define OVE_NONNULL(...)
39#define OVE_NODISCARD
40#define OVE_RETURNS_NONNULL
41#define OVE_DEPRECATED(msg)
42#else
52#define OVE_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
53
61#define OVE_NODISCARD __attribute__((warn_unused_result))
62
64#define OVE_RETURNS_NONNULL __attribute__((returns_nonnull))
65
67#define OVE_DEPRECATED(msg) __attribute__((deprecated(msg)))
68#endif
69
154
162#define OVE_WAIT_FOREVER UINT64_MAX
163
164/*
165 * Compile-time C-ABI shape check. This file IS the C-ABI contract;
166 * the assertions below pin the numeric values that every binding
167 * (Rust `Error::from_code`, Zig `mapErrorCode`, C++ `static_assert`
168 * block in <ove/types.hpp>) reads back. If a future re-numbering
169 * drifts an `OVE_ERR_*` value, every TU that includes this header
170 * fails to compile with a clear message — the silent-drift surface is
171 * closed at the substrate layer the higher-level bindings sit on.
172 *
173 * `_Static_assert` is the C99/C11 keyword (also a GCC extension in
174 * C++); `static_assert` is the C++11 keyword. Pick whichever the
175 * including TU's language supports — TUs that include this header as
176 * C++ (the C++ binding's <ove/types.hpp> for instance) need the
177 * portable spelling.
178 */
179#if defined(__cplusplus)
180#define OVE_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
181#else
182#define OVE_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
183#endif
184OVE_STATIC_ASSERT(OVE_ERR_NOT_REGISTERED == -1, "OVE_ERR_NOT_REGISTERED drifted");
185OVE_STATIC_ASSERT(OVE_ERR_INVALID_PARAM == -2, "OVE_ERR_INVALID_PARAM drifted");
186OVE_STATIC_ASSERT(OVE_ERR_NO_MEMORY == -3, "OVE_ERR_NO_MEMORY drifted");
187OVE_STATIC_ASSERT(OVE_ERR_TIMEOUT == -4, "OVE_ERR_TIMEOUT drifted");
188OVE_STATIC_ASSERT(OVE_ERR_NOT_SUPPORTED == -5, "OVE_ERR_NOT_SUPPORTED drifted");
189OVE_STATIC_ASSERT(OVE_ERR_QUEUE_FULL == -6, "OVE_ERR_QUEUE_FULL drifted");
190OVE_STATIC_ASSERT(OVE_ERR_ML_FAILED == -7, "OVE_ERR_ML_FAILED drifted");
191OVE_STATIC_ASSERT(OVE_ERR_NET_REFUSED == -8, "OVE_ERR_NET_REFUSED drifted");
192OVE_STATIC_ASSERT(OVE_ERR_NET_UNREACHABLE == -9, "OVE_ERR_NET_UNREACHABLE drifted");
193OVE_STATIC_ASSERT(OVE_ERR_NET_ADDR_IN_USE == -10, "OVE_ERR_NET_ADDR_IN_USE drifted");
194OVE_STATIC_ASSERT(OVE_ERR_NET_RESET == -11, "OVE_ERR_NET_RESET drifted");
195OVE_STATIC_ASSERT(OVE_ERR_NET_DNS_FAIL == -12, "OVE_ERR_NET_DNS_FAIL drifted");
196OVE_STATIC_ASSERT(OVE_ERR_NET_CLOSED == -13, "OVE_ERR_NET_CLOSED drifted");
197OVE_STATIC_ASSERT(OVE_ERR_BUS_NACK == -14, "OVE_ERR_BUS_NACK drifted");
198OVE_STATIC_ASSERT(OVE_ERR_BUS_BUSY == -15, "OVE_ERR_BUS_BUSY drifted");
199OVE_STATIC_ASSERT(OVE_ERR_BUS_ERROR == -16, "OVE_ERR_BUS_ERROR drifted");
200OVE_STATIC_ASSERT(OVE_ERR_QUEUE_EMPTY == -17, "OVE_ERR_QUEUE_EMPTY drifted");
201OVE_STATIC_ASSERT(OVE_ERR_WOULD_BLOCK == -18, "OVE_ERR_WOULD_BLOCK drifted");
202OVE_STATIC_ASSERT(OVE_ERR_EOF == -19, "OVE_ERR_EOF drifted");
203OVE_STATIC_ASSERT(OVE_ERR_INVAL == -20, "OVE_ERR_INVAL drifted");
204OVE_STATIC_ASSERT(OVE_ERR_NOT_FOUND == -21, "OVE_ERR_NOT_FOUND drifted");
205OVE_STATIC_ASSERT(OVE_WAIT_FOREVER == UINT64_MAX, "OVE_WAIT_FOREVER drifted");
206
208typedef struct ove_thread *ove_thread_t;
209
211typedef struct ove_mutex *ove_mutex_t;
212
214typedef struct ove_sem *ove_sem_t;
215
217typedef struct ove_event *ove_event_t;
218
220typedef struct ove_condvar *ove_condvar_t;
221
223typedef struct ove_eventgroup *ove_eventgroup_t;
224
226typedef struct ove_workqueue *ove_workqueue_t;
227
229typedef struct ove_work *ove_work_t;
230
232typedef struct ove_stream *ove_stream_t;
233
235typedef struct ove_watchdog *ove_watchdog_t;
236
238typedef struct ove_file *ove_file_t;
239
241typedef struct ove_dir *ove_dir_t;
242
244typedef struct ove_model *ove_model_t;
245
247typedef struct ove_socket *ove_socket_t;
248
250typedef struct ove_netif *ove_netif_t;
251
253typedef struct ove_tls *ove_tls_t;
254
256typedef struct ove_http_client *ove_http_client_t;
257
259typedef struct ove_mqtt_client *ove_mqtt_client_t;
260
262typedef struct ove_uart *ove_uart_t;
263
265typedef struct ove_spi *ove_spi_t;
266
268typedef struct ove_i2c *ove_i2c_t;
269
271typedef struct ove_i2s *ove_i2s_t;
272
279typedef uint32_t ove_eventbits_t;
280
298typedef void (*ove_notify_cb)(void *user_data);
299
312typedef void (*ove_dma_complete_cb)(int result, void *user_data);
313
314/* RTOS name string (compile-time) */
315#include "ove_config.h"
316
324#if defined(CONFIG_OVE_RTOS_FREERTOS)
325#define OVE_RTOS_NAME "FreeRTOS"
326#elif defined(CONFIG_OVE_RTOS_ZEPHYR)
327#define OVE_RTOS_NAME "Zephyr"
328#elif defined(CONFIG_OVE_RTOS_NUTTX)
329#define OVE_RTOS_NAME "NuttX"
330#elif defined(CONFIG_OVE_RTOS_POSIX)
331#define OVE_RTOS_NAME "POSIX"
332#else
333#define OVE_RTOS_NAME "Unknown"
334#endif
335
336#endif /* OVE_TYPES_H */
337
struct ove_mqtt_client * ove_mqtt_client_t
Opaque handle for an MQTT client.
Definition types.h:259
struct ove_spi * ove_spi_t
Opaque handle for an SPI bus controller.
Definition types.h:265
void(* ove_dma_complete_cb)(int result, void *user_data)
DMA / async transfer completion callback signature.
Definition types.h:312
struct ove_netif * ove_netif_t
Opaque handle for a network interface.
Definition types.h:250
struct ove_eventgroup * ove_eventgroup_t
Opaque handle for an event-group (bit-field) object.
Definition types.h:223
struct ove_thread * ove_thread_t
Opaque handle for a thread object.
Definition types.h:208
struct ove_i2s * ove_i2s_t
Opaque handle for an I2S / SAI bus controller.
Definition types.h:271
struct ove_tls * ove_tls_t
Opaque handle for a TLS session.
Definition types.h:253
struct ove_uart * ove_uart_t
Opaque handle for a UART peripheral.
Definition types.h:262
uint32_t ove_eventbits_t
Bit-mask type used by the event-group API.
Definition types.h:279
struct ove_stream * ove_stream_t
Opaque handle for a byte-stream (ring-buffer) object.
Definition types.h:232
struct ove_event * ove_event_t
Opaque handle for a binary event (signal/wait) object.
Definition types.h:217
struct ove_dir * ove_dir_t
Opaque handle for an open directory.
Definition types.h:241
struct ove_sem * ove_sem_t
Opaque handle for a counting semaphore object.
Definition types.h:214
ove_err_t
oveRTOS error codes.
Definition types.h:81
struct ove_condvar * ove_condvar_t
Opaque handle for a condition variable object.
Definition types.h:220
struct ove_mutex * ove_mutex_t
Opaque handle for a mutex object.
Definition types.h:211
struct ove_workqueue * ove_workqueue_t
Opaque handle for a work queue object.
Definition types.h:226
struct ove_watchdog * ove_watchdog_t
Opaque handle for a software watchdog object.
Definition types.h:235
struct ove_i2c * ove_i2c_t
Opaque handle for an I2C bus controller.
Definition types.h:268
struct ove_socket * ove_socket_t
Opaque handle for a network socket.
Definition types.h:247
struct ove_file * ove_file_t
Opaque handle for an open file.
Definition types.h:238
struct ove_model * ove_model_t
Opaque handle for an ML inference model session.
Definition types.h:244
struct ove_http_client * ove_http_client_t
Opaque handle for an HTTP client.
Definition types.h:256
void(* ove_notify_cb)(void *user_data)
Notify-callback signature used by the _set_notify variants of the comm primitives (stream / queue / e...
Definition types.h:298
struct ove_work * ove_work_t
Opaque handle for a deferred work item.
Definition types.h:229
#define OVE_WAIT_FOREVER
Timeout value that means "block indefinitely".
Definition types.h:162
@ OVE_ERR_INVAL
Definition types.h:149
@ OVE_ERR_QUEUE_FULL
Definition types.h:101
@ OVE_ERR_NET_REFUSED
Definition types.h:107
@ OVE_ERR_BUS_BUSY
Definition types.h:128
@ OVE_ERR_NET_DNS_FAIL
Definition types.h:119
@ OVE_ERR_QUEUE_EMPTY
Definition types.h:134
@ OVE_ERR_BUS_NACK
Definition types.h:125
@ OVE_ERR_BUS_ERROR
Definition types.h:131
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
@ OVE_ERR_NO_MEMORY
Definition types.h:92
@ OVE_ERR_NET_ADDR_IN_USE
Definition types.h:113
@ OVE_ERR_NET_CLOSED
Definition types.h:122
@ OVE_ERR_INVALID_PARAM
Definition types.h:89
@ OVE_ERR_NOT_REGISTERED
Definition types.h:86
@ OVE_ERR_NET_RESET
Definition types.h:116
@ OVE_ERR_NET_UNREACHABLE
Definition types.h:110
@ OVE_ERR_NOT_FOUND
Definition types.h:152
@ OVE_OK
Definition types.h:83
@ OVE_ERR_WOULD_BLOCK
Definition types.h:143
@ OVE_ERR_ML_FAILED
Definition types.h:104
@ OVE_ERR_EOF
Definition types.h:146
@ OVE_ERR_TIMEOUT
Definition types.h:95