summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/til_tap.h77
1 files changed, 39 insertions, 38 deletions
diff --git a/src/til_tap.h b/src/til_tap.h
index a6384de..62e3c37 100644
--- a/src/til_tap.h
+++ b/src/til_tap.h
@@ -58,100 +58,101 @@ typedef struct v4f_t v4f_t;
typedef struct m4f_t m4f_t;
/* This is the bare tap initializer but use the type-checked wrappers below and add one if one's missing */
-static inline void til_tap_init(til_tap_t *tap, til_tap_type_t type, void *ptr, size_t n_elems, void *elems, const char *name)
+static inline til_tap_t til_tap_init(til_tap_type_t type, void *ptr, size_t n_elems, void *elems, const char *name)
{
- assert(tap);
assert(type < TIL_TAP_TYPE_MAX);
assert(ptr);
assert(n_elems);
assert(elems);
assert(name);
- tap->type = type;
- tap->ptr = ptr;
- tap->n_elems = n_elems;
- tap->elems = elems;
- tap->name = name;
+ *((void **)ptr) = elems;
- *((void **)tap->ptr) = elems;
+ return (til_tap_t){
+ .type = type,
+ .ptr = ptr,
+ .n_elems = n_elems,
+ .elems = elems,
+ .name = name,
+ };
}
/* typed wrappers, just supply n_elems=1 for individual variables - note n_elems is just a defensive
* programming sanity check to catch callers mismatching array sizes
*/
-static inline void til_tap_init_i8(til_tap_t *tap, int8_t **ptr, size_t n_elems, int8_t *elems, const char *name)
+static inline til_tap_t til_tap_init_i8(int8_t **ptr, size_t n_elems, int8_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_I8, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_I8, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_i16(til_tap_t *tap, int16_t **ptr, size_t n_elems, int16_t *elems, const char *name)
+static inline til_tap_t til_tap_init_i16(int16_t **ptr, size_t n_elems, int16_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_I16, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_I16, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_i32(til_tap_t *tap, int32_t **ptr, size_t n_elems, int32_t *elems, const char *name)
+static inline til_tap_t til_tap_init_i32(int32_t **ptr, size_t n_elems, int32_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_I32, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_I32, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_i64(til_tap_t *tap, int64_t **ptr, size_t n_elems, int64_t *elems, const char *name)
+static inline til_tap_t til_tap_init_i64(int64_t **ptr, size_t n_elems, int64_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_I64, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_I64, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_u8(til_tap_t *tap, uint8_t **ptr, size_t n_elems, uint8_t *elems, const char *name)
+static inline til_tap_t til_tap_init_u8(uint8_t **ptr, size_t n_elems, uint8_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_U8, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_U8, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_u16(til_tap_t *tap, uint16_t **ptr, size_t n_elems, uint16_t *elems, const char *name)
+static inline til_tap_t til_tap_init_u16(uint16_t **ptr, size_t n_elems, uint16_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_U16, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_U16, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_u32(til_tap_t *tap, uint32_t **ptr, size_t n_elems, uint32_t *elems, const char *name)
+static inline til_tap_t til_tap_init_u32(uint32_t **ptr, size_t n_elems, uint32_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_U32, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_U32, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_u64(til_tap_t *tap, uint64_t **ptr, size_t n_elems, uint64_t *elems, const char *name)
+static inline til_tap_t til_tap_init_u64(uint64_t **ptr, size_t n_elems, uint64_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_U64, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_U64, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_float(til_tap_t *tap, float **ptr, size_t n_elems, float *elems, const char *name)
+static inline til_tap_t til_tap_init_float(float **ptr, size_t n_elems, float *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_FLOAT, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_FLOAT, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_double(til_tap_t *tap, double **ptr, size_t n_elems, double *elems, const char *name)
+static inline til_tap_t til_tap_init_double(double **ptr, size_t n_elems, double *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_DOUBLE, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_DOUBLE, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_v2f(til_tap_t *tap, v2f_t **ptr, size_t n_elems, v2f_t *elems, const char *name)
+static inline til_tap_t til_tap_init_v2f(v2f_t **ptr, size_t n_elems, v2f_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_V2F, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_V2F, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_v3f(til_tap_t *tap, v3f_t **ptr, size_t n_elems, v3f_t *elems, const char *name)
+static inline til_tap_t til_tap_init_v3f(v3f_t **ptr, size_t n_elems, v3f_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_V3F, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_V3F, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_v4f(til_tap_t *tap, v4f_t **ptr, size_t n_elems, v4f_t *elems, const char *name)
+static inline til_tap_t til_tap_init_v4f(v4f_t **ptr, size_t n_elems, v4f_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_V4F, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_V4F, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_m4f(til_tap_t *tap, m4f_t **ptr, size_t n_elems, m4f_t *elems, const char *name)
+static inline til_tap_t til_tap_init_m4f(m4f_t **ptr, size_t n_elems, m4f_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_M4F, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_M4F, ptr, n_elems, elems, name);
}
-static inline void til_tap_init_voidp(til_tap_t *tap, void **ptr, size_t n_elems, void *elems, const char *name)
+static inline til_tap_t til_tap_init_til_tap_voidp(void **ptr, size_t n_elems, til_tap_t *elems, const char *name)
{
- return til_tap_init(tap, TIL_TAP_TYPE_VOIDP, ptr, n_elems, elems, name);
+ return til_tap_init(TIL_TAP_TYPE_VOIDP, ptr, n_elems, elems, name);
}
#endif
© All Rights Reserved