diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-09 13:20:48 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-10 05:49:43 +0000 |
commit | b1a173ea45a94368325440dd014417554c88918a (patch) | |
tree | 5222a0459bbc24856b77135ec911042ecddf621d /builtin | |
parent | 039c889e1435da921d2e18dc63ab96e4cf437a07 (diff) | |
download | chrome-ec-b1a173ea45a94368325440dd014417554c88918a.tar.gz |
panic: Tidy up the #ifdefs
Move the common code into a separate function. Add comments to the
nesting. Use IS_ENABLED() where possible and drop the outer #ifdef
around the C code, since the linker will throw it away automatically
if it is not called.
BUG=b:177604307
BRANCH=none
TEST=verified no code-size change on volteer
Change-Id: I61065d37fb6267097a2078493a4edfcdeea23819
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2686248
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/assert.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/builtin/assert.h b/builtin/assert.h index e58a450fa8..f51ea7b57a 100644 --- a/builtin/assert.h +++ b/builtin/assert.h @@ -27,7 +27,9 @@ extern noreturn void panic_assert_fail(const char *fname, int linenum); if (!(cond)) \ panic_assert_fail(__FILE__, __LINE__); \ } while (0) -#else + +#else /* !CONFIG_DEBUG_ASSERT_BRIEF */ + extern noreturn void panic_assert_fail(const char *msg, const char *func, const char *fname, int linenum); #define ASSERT(cond) \ @@ -36,18 +38,21 @@ extern noreturn void panic_assert_fail(const char *msg, const char *func, panic_assert_fail(#cond, __func__, __FILE__, \ __LINE__); \ } while (0) -#endif -#else +#endif /* CONFIG_DEBUG_ASSERT_BRIEF */ + +#else /* !CONFIG_DEBUG_ASSERT_REBOOTS */ + #define ASSERT(cond) \ do { \ if (!(cond)) \ __asm("bkpt"); \ __builtin_unreachable(); \ } while (0) -#endif -#else +#endif /* CONFIG_DEBUG_ASSERT_REBOOTS */ + +#else /* !CONFIG_DEBUG_ASSERT */ #define ASSERT(cond) -#endif +#endif /* CONFIG_DEBUG_ASSERT */ /* This collides with cstdlib, so exclude it where cstdlib is supported. */ #ifndef assert |