4 * Copyright (c) 2017 Google, Inc
5 * Written by Simon Glass <sjg@chromium.org>
7 * SPDX-License-Identifier: GPL-2.0+
19 #ifdef CONFIG_SPL_BUILD
26 * Output a debug text when condition "cond" is met. The "cond" should be
27 * computed by a preprocessor in the best case, allowing for the best
30 #define debug_cond(cond, fmt, args...) \
33 printf(pr_fmt(fmt), ##args); \
36 /* Show a message if DEBUG is defined in a file */
37 #define debug(fmt, args...) \
38 debug_cond(_DEBUG, fmt, ##args)
40 /* Show a message if not in SPL */
41 #define warn_non_spl(fmt, args...) \
42 debug_cond(!_SPL_BUILD, fmt, ##args)
45 * An assertion is run-time check done in debug mode only. If DEBUG is not
46 * defined then it is skipped. If DEBUG is defined and the assertion fails,
47 * then it calls panic*( which may or may not reset/halt U-Boot (see
48 * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found
49 * before release, and after release it is hoped that they don't matter. But
50 * in any case these failing assertions cannot be fixed with a reset (which
51 * may just do the same assertion again).
53 void __assert_fail(const char *assertion, const char *file, unsigned int line,
54 const char *function);
56 ({ if (!(x) && _DEBUG) \
57 __assert_fail(#x, __FILE__, __LINE__, __func__); })