0913e79b8058ccc9b3abaaa32a827954e11de370
1 #pragma once
3 #include "color.h"
4 #include "conv.h"
5 #include "testpat.h"
7 #define unlikely(x) __builtin_expect(!!(x), 0)
9 static void ASSERT_FAIL(const char *cond, const char *file,
10 unsigned int line, const char *func) __attribute__ ((__noreturn__));
12 static void ASSERT_FAIL(const char *cond, const char *file,
13 unsigned int line, const char *func)
14 {
15 fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", file, line, func, cond);
16 abort();
17 }
19 #define ASSERT(x) if (unlikely(!(x))) { ASSERT_FAIL( __STRING(x), __FILE__, __LINE__, __PRETTY_FUNCTION__); }
21 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))