2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 coresystems GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
20 #include <console/console.h>
22 /* TODO: Fix vendorcode headers to not define macros coreboot uses or to be more
28 /* GCC and CAR versions */
31 printk(BIOS_EMERG, "ASSERTION ERROR: file '%s'" \
32 ", line %d\n", __FILE__, __LINE__); \
33 if (CONFIG(FATAL_ASSERTS)) \
38 printk(BIOS_EMERG, "ERROR: BUG ENCOUNTERED at file '%s'"\
39 ", line %d\n", __FILE__, __LINE__); \
40 if (CONFIG(FATAL_ASSERTS)) \
44 #define assert(statement) ASSERT(statement)
47 * These macros can be used to assert that a certain branch of code is dead and
48 * will be compile-time eliminated. This differs from _Static_assert(), which
49 * will generate a compiler error even if the scope it was called from is dead
50 * code. This may be useful to double-check things like constants that are only
51 * valid if a certain Kconfig option is set.
53 * The error message when this hits will look like this:
55 * ramstage/lib/bootmode.o: In function `display_init_required':
56 * bootmode.c:42: undefined reference to `dead_code_assertion_failed_at_line_42'
58 #define __dead_code(line) do { \
59 extern void dead_code_assertion_failed_at_line_##line(void) \
60 __attribute__((noreturn)); \
61 dead_code_assertion_failed_at_line_##line(); \
63 #define _dead_code(line) __dead_code(line)
64 #define dead_code() _dead_code(__LINE__)
66 /* This can be used in the context of an expression of type 'type'. */
67 #define dead_code_t(type) ({ \
69 *(type *)(uintptr_t)0; \
72 #endif // __ASSERT_H__