diff options
author | Iru Cai <mytbk920423@gmail.com> | 2019-10-30 16:06:47 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2019-10-30 16:06:47 +0800 |
commit | fbce440bab0711ad8511d29e914d4e262c8c71da (patch) | |
tree | 07a863f4959d332db590e38804ef57164943464e /ext4_common.h | |
parent | 63cf543b3cc4d6e21d680bde234f697a5588c66e (diff) | |
download | uext4-fbce440bab0711ad8511d29e914d4e262c8c71da.tar.xz |
kill more
Diffstat (limited to 'ext4_common.h')
-rw-r--r-- | ext4_common.h | 35 |
1 files changed, 35 insertions, 0 deletions
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); |