From fbce440bab0711ad8511d29e914d4e262c8c71da Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Wed, 30 Oct 2019 16:06:47 +0800 Subject: kill more --- ext4_common.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'ext4_common.h') diff --git a/ext4_common.h b/ext4_common.h index a3ac298..bf8476c 100644 --- a/ext4_common.h +++ b/ext4_common.h @@ -47,6 +47,41 @@ #define dbg_printf(s, ...) #endif +#ifdef UEXT4_DEBUG +#define _DEBUG 1 +#define debug dbg_printf +#else +#define _DEBUG 0 +#define debug(s, ...) +#endif + +/* + * An assertion is run-time check done in debug mode only. If DEBUG is not + * defined then it is skipped. If DEBUG is defined and the assertion fails, + * then it calls panic*( which may or may not reset/halt U-Boot (see + * CONFIG_PANIC_HANG), It is hoped that all failing assertions are found + * before release, and after release it is hoped that they don't matter. But + * in any case these failing assertions cannot be fixed with a reset (which + * may just do the same assertion again). + */ +void __assert_fail(const char *assertion, const char *file, unsigned int line, + const char *function); + +/** + * assert() - assert expression is true + * + * If the expression x evaluates to false and _DEBUG evaluates to true, a panic + * message is written and the system stalls. The value of _DEBUG is set to true + * if DEBUG is defined before including common.h. + * + * The expression x is always executed irrespective of the value of _DEBUG. + * + * @x: expression to test + */ +#define assert(x) \ + ({ if (!(x) && _DEBUG) \ + __assert_fail(#x, __FILE__, __LINE__, __func__); }) + static inline void *zalloc(size_t size) { void *p = memalign(ARCH_DMA_MINALIGN, size); -- cgit v1.2.3