WISP ERT (Client)  1.0.0
The WISP Extended Runtime (WISP side)
defs.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdbool.h>
4 #include <stddef.h>
5 #include <stdint.h>
6 
7 //=== WIO helper marcos ===
15 #define WIO_TRY(expr) { \
16  wio_status_t __status = expr; \
17  if (__status) \
18  return __status; \
19  }
20 #define WIO_CALLBACK(name) \
22  wio_status_t name(void* data, wio_status_t status, void* result)
23 #define WIO_INST_PTR(type) \
25  &((type){})
26 #define WIO_RETURN(ret_var, ret_val) { \
28  if (ret_var) \
29  *ret_var = ret_val; \
30  }
31 
32 //=== WIO math marcos ===
34 #define WIO_MIN(x, y) ((x<y)?x:y)
35 #define WIO_MIN3(x, y, z) WIO_MIN(WIO_MIN(x, y), z)
37 
38 //=== WIO type definitions ===
40 typedef uint8_t wio_status_t;
42 typedef wio_status_t (*wio_callback_t)(void*, wio_status_t, void*);
43 
45 typedef struct wio_closure {
47  void* data;
51 
52 //=== WIO error codes ===
54 static const wio_status_t WIO_OK = 0x00;
56 static const wio_status_t WIO_ERR_OUT_OF_RANGE = 0x01;
58 static const wio_status_t WIO_ERR_NO_MEMORY = 0x02;
60 static const wio_status_t WIO_ERR_ALREADY = 0x03;
62 static const wio_status_t WIO_ERR_INVALID = 0x04;
64 static const wio_status_t WIO_ERR_EMPTY = 0x05;
uint8_t wio_status_t
WIO status type.
Definition: defs.h:40
static const wio_status_t WIO_ERR_NO_MEMORY
No memory.
Definition: defs.h:58
static const wio_status_t WIO_ERR_OUT_OF_RANGE
Out of range.
Definition: defs.h:56
wio_status_t(* wio_callback_t)(void *, wio_status_t, void *)
WIO callback type.
Definition: defs.h:42
WIO closure type.
Definition: defs.h:45
static const wio_status_t WIO_OK
No error.
Definition: defs.h:54
wio_callback_t func
Function.
Definition: defs.h:49
static const wio_status_t WIO_ERR_EMPTY
Empty data structure.
Definition: defs.h:64
void * data
Closure data.
Definition: defs.h:47
static const wio_status_t WIO_ERR_ALREADY
Already in use.
Definition: defs.h:60
static const wio_status_t WIO_ERR_INVALID
Invalid parameter.
Definition: defs.h:62