blob: 68bb2b52159e98ae7c85b6c0d58d4b21d744e437 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#ifndef INCLUDED_UTILS_H
#define INCLUDED_UTILS_H
#include <stdlib.h>
#include <assert.h>
#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
|