From 8bbefe95d25fa2981add4df35bdd9903c91a8e62 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Sun, 8 Nov 2026 08:13:29 +0300 Subject: publish --- src/utils.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/utils.h (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..68bb2b5 --- /dev/null +++ b/src/utils.h @@ -0,0 +1,26 @@ +#ifndef INCLUDED_UTILS_H +#define INCLUDED_UTILS_H + +#include +#include + +#define UNUSED(X) ((void) (X)) +#define UNREACHABLE() ASSERT (!"reached the unreachable...") +// #define TODO(STR) fprintf (stderr, "%s:%d: warning: TODO "STR"\n", __FILE__, __LINE__) +#define TODO(...) + +#define ASSERT assert +#define REALLOC realloc +#define FREE free + +#define DIE(FMT, ...) \ + ({ \ + fprintf (stderr, FMT "\n" __VA_OPT__(,) __VA_ARGS__); \ + exit (EXIT_FAILURE); \ + }) + +#define ARRAY_LEN(array) (sizeof (array)/sizeof (*array)) +#define ARRAY_GET(array, index) \ + (ASSERT(index >= 0), ASSERT(index < ARRAY_LEN(array)), array[index]) + +#endif -- cgit v1.3.1