1 #pragma once
3 #define unlikely(x) __builtin_expect(!!(x), 0)
5 static void ASSERT_FAIL(const char *cond, const char *file,
6 unsigned int line, const char *func) __attribute__ ((__noreturn__));
8 static void ASSERT_FAIL(const char *cond, const char *file,
9 unsigned int line, const char *func)
10 {
11 fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", file, line, func, cond);
12 abort();
13 }
15 #define ASSERT(x) if (unlikely(!(x))) { ASSERT_FAIL( __STRING(x), __FILE__, __LINE__, __PRETTY_FUNCTION__); }