18 #define __ASSERT_FILE__ "(filenames not available on timeless builds)"
19 #define __ASSERT_LINE__ 404
21 #define __ASSERT_FILE__ __FILE__
22 #define __ASSERT_LINE__ __LINE__
26 #define __build_time_assert(x) \
27 (__builtin_constant_p(x) ? ((x) ? 1 : dead_code_t(int)) : 0)
29 #define __build_time_assert(x) 0
34 const char *
const file,
const int line);
37 #define MOCK_ASSERT(result, expression) \
38 mock_assert((result), (expression), __ASSERT_FILE__, __ASSERT_LINE__)
40 #define MOCK_ASSERT(result, expression)
45 if (!__build_time_assert(x) && !(x)) { \
47 "ASSERTION ERROR: file '%s', line %d\n", \
48 __ASSERT_FILE__, __ASSERT_LINE__); \
49 MOCK_ASSERT(!!(x), #x); \
50 if (CONFIG(FATAL_ASSERTS)) \
54 #define ASSERT_MSG(x, msg) { \
55 if (!__build_time_assert(x) && !(x)) { \
57 "ASSERTION ERROR: file '%s', line %d\n", \
58 __ASSERT_FILE__, __ASSERT_LINE__); \
59 printk(BIOS_EMERG, "%s", msg); \
60 MOCK_ASSERT(!!(x), (msg)); \
61 if (CONFIG(FATAL_ASSERTS)) \
67 "ERROR: BUG ENCOUNTERED at file '%s', line %d\n", \
68 __ASSERT_FILE__, __ASSERT_LINE__); \
69 MOCK_ASSERT(0, "BUG ENCOUNTERED"); \
70 if (CONFIG(FATAL_ASSERTS)) \
74 #define assert(statement) ASSERT(statement)
89 #define dead_code() _dead_code_assertion_failed()
92 #define dead_code_t(type) ({ \
94 *(type *)(uintptr_t)0; \
98 #define pointer_to_uint32_safe(x) ({ \
99 if ((uintptr_t)(x) > 0xffffffffUL) \
100 die("Cast from pointer to uint32_t overflows"); \
101 (uint32_t)(uintptr_t)(x); \
104 #define pointer_to_uint32_safe(x) ({ \
105 (uint32_t)(uintptr_t)(x); \
void mock_assert(const int result, const char *const expression, const char *const file, const int line)
void _dead_code_assertion_failed(void)