summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAntonio Nino Diaz <antonio.ninodiaz@arm.com>2017-04-18 15:16:05 +0100
committerAntonio Nino Diaz <antonio.ninodiaz@arm.com>2017-04-19 16:00:53 +0100
commitcc8b56322bb04569a5adf944774b16862782c95b (patch)
tree51949e487c935520370c0be0376614fd6bc6e70b /lib
parent239b085caab4cfd38708d5d1a7de8eb14bb952c7 (diff)
Add `ENABLE_ASSERTIONS` build option
Add the new build option `ENABLE_ASSERTIONS` that controls whether or not assert functions are compiled out. It defaults to 1 for debug builds and to 0 for release builds. Additionally, a following patch will be done to allow this build option to hide auxiliary code used for the checks done in an `assert()`. This code is is currently under the DEBUG build flag. Assert messages are now only printed if LOG_LEVEL >= LOG_LEVEL_INFO, which is the default for debug builds. This patch also updates the User Guide. Change-Id: I1401530b56bab25561bb0f274529f1d12c5263bc Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/assert.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/stdlib/assert.c b/lib/stdlib/assert.c
index 3486e50b..3c0bd166 100644
--- a/lib/stdlib/assert.c
+++ b/lib/stdlib/assert.c
@@ -32,15 +32,18 @@
#include <debug.h>
#include <platform.h>
-/*
- * This is a basic implementation. This could be improved.
- */
-void __assert (const char *function, const char *file, unsigned int line,
+void __assert(const char *function, const char *file, unsigned int line,
const char *assertion)
{
+#if LOG_LEVEL >= LOG_LEVEL_INFO
+ /*
+ * Only print the output if LOG_LEVEL is higher or equal to
+ * LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
+ */
tf_printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
console_flush();
+#endif
plat_panic_handler();
}