From f5d445afa10ed7ba03b0ea9a5274f11904220700 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 20 Aug 2026 18:51:01 +0000 Subject: Move aplwc-repl into its own directory, and likewise for the aplwc library FossilOrigin-Name: 7e6b710fae494fadfe06bed16ae10bdda0f377067cb9411ed2b8bfc682d2fcbc --- src/lib/aplwc_internal.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/lib/aplwc_internal.h (limited to 'src/lib/aplwc_internal.h') diff --git a/src/lib/aplwc_internal.h b/src/lib/aplwc_internal.h new file mode 100644 index 0000000..97a89ba --- /dev/null +++ b/src/lib/aplwc_internal.h @@ -0,0 +1,50 @@ +#ifndef APLWC_INTERNAL_H +#define APLWC_INTERNAL_H + +#include + +#define UNUSED_PARAMETER(arg) ((void)arg) + +#define RETURN_ERROR(aplwcp, rc, msg) do{ \ + return ((aplwc)->last_error = (rc)); \ + }while(0) + +#define NELEM(x) (sizeof(x)/sizeof(x[0])) + +#if APLWC_BUILD_TYPE_DEBUG + #define ALWAYS(x) ((x) ? 1 : (assert(0), 0)) + #define NEVER(x) ((x) ? (assert(0), 1) : 0) +#elif APLWC_BUILD_TYPE_RELEASE + #define ALWAYS(x) (X) + #define NEVER(X) (X) +#elif APLWC_BUILD_TYPE_COVERAGE + #define ALWAYS(x) (1) + #define NEVER(x) (0) +#endif + +#include +#include +#include +#include + +struct memory { + uint8_t *data; + size_t size; + size_t offset; +}; + +struct aplwc { + enum aplwc_rc last_error; + char last_error_msg[64]; + struct memory memory; +}; + +/* errors.c */ +const char *rc_to_string(enum aplwc_rc); + +/* memory.c */ +struct memory memory_init(uint8_t *, size_t); +struct aplwc *memory_alloc_aplwc(struct memory *); +void memory_free_aplwc(struct memory *, struct aplwc *); + +#endif /* APLWC_INTERNAL_H */ -- cgit v1.2.3