Felix Held has submitted this change. ( https://review.coreboot.org/c/coreboot/+/39620 )
Change subject: assert.h: add assertions with descriptive failures ......................................................................
assert.h: add assertions with descriptive failures
BUG=None TEST=tested in following patches on Trembyle board
Change-Id: Ib30ccd41759e5a2a61d3182cc08ed5eb762eca98 Signed-off-by: Eric Peers epeers@google.com Reviewed-on: https://chromium-review.googlesource.com/1971443 Tested-by: Martin Roth martinroth@chromium.org Reviewed-by: Martin Roth martinroth@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/39620 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Martin Roth martinroth@google.com Reviewed-by: Angel Pons th3fanbus@gmail.com Reviewed-by: Raul Rangel rrangel@chromium.org Reviewed-by: Paul Menzel paulepanter@users.sourceforge.net --- M src/include/assert.h 1 file changed, 11 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Martin Roth: Looks good to me, approved Paul Menzel: Looks good to me, but someone else must approve Raul Rangel: Looks good to me, approved Angel Pons: Looks good to me, approved
diff --git a/src/include/assert.h b/src/include/assert.h index 8f5af1f..990cee1 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -33,6 +33,17 @@ hlt(); \ } \ } + +#define ASSERT_MSG(x, msg) { \ + if (!(x)) { \ + printk(BIOS_EMERG, "ASSERTION ERROR: file '%s'" \ + ", line %d\n", __FILE__, __LINE__); \ + printk(BIOS_EMERG, "%s", msg); \ + if (CONFIG(FATAL_ASSERTS)) \ + hlt(); \ + } \ +} + #define BUG() { \ printk(BIOS_EMERG, "ERROR: BUG ENCOUNTERED at file '%s'"\ ", line %d\n", __FILE__, __LINE__); \