diff options
| author | 2026-11-08 08:19:44 +0000 | |
|---|---|---|
| committer | 2026-11-08 08:23:19 +0000 | |
| commit | 5be0e39d0ce97849d7722bd1ac98563c7014faf3 (patch) | |
| tree | 9dba821664337a6662a6da88dfe86291d269c36b /src/utils.h | |
| download | lab-05-master.tar.gz | |
Diffstat (limited to 'src/utils.h')
| -rw-r--r-- | src/utils.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..fa8b3ee --- /dev/null +++ b/src/utils.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #ifndef INCLUDED_UTILS_H | ||
| 2 | #define INCLUDED_UTILS_H | ||
| 3 | |||
| 4 | #include <assert.h> | ||
| 5 | #include <stdlib.h> | ||
| 6 | #include <stdio.h> | ||
| 7 | |||
| 8 | #define UNUSED(X) ((void) (X)) | ||
| 9 | #define UNREACHABLE() ASSERT (!"reached the unreachable...") | ||
| 10 | #define TODO(STR) fprintf (stderr, "%s:%d: warning: TODO "STR"\n", __FILE__, __LINE__) | ||
| 11 | // #define TODO(...) | ||
| 12 | #define REACHED(FMT, ...) fprintf (stderr, "%s:%d: info: %s: reached: "FMT"\n", __FILE__, __LINE__, __func__ __VA_OPT__(,) __VA_ARGS__) | ||
| 13 | |||
| 14 | #define MALLOC malloc | ||
| 15 | #define REALLOC realloc | ||
| 16 | #define FREE free | ||
| 17 | #define ASSERT assert | ||
| 18 | |||
| 19 | #define PRINT_EXP(EXP, FMT) printf (#EXP" = "FMT"\n", EXP) | ||
| 20 | |||
| 21 | #define DIE(FMT, ...) \ | ||
| 22 | ({ \ | ||
| 23 | fprintf (stderr, FMT "\n" __VA_OPT__(,) __VA_ARGS__); \ | ||
| 24 | exit (EXIT_FAILURE); \ | ||
| 25 | }) | ||
| 26 | |||
| 27 | #endif | ||
