aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2019-01-18 13:30:29 +0100
committerSandrine Bailleux <sandrine.bailleux@arm.com>2019-01-18 14:32:47 +0100
commit971545c399ec0e79718132bcf7883111842b76e8 (patch)
tree17ac6b0b6ca0b221a0bedfbac8066c2a9570f6e6
parenta2d516fc5215973b4df38fe072fb68a8899e4ae4 (diff)
downloadtf-a-tests-971545c399ec0e79718132bcf7883111842b76e8.tar.gz
Use lock-less printf() in assert macro
This allows to use assertions in interrupt context (which we do in some places currently). Before this patch, a CPU could dead lock itself by: 1. acquiring the printf lock in the normal execution context; 2. taking an interrupt while still holding the lock; 3. inside the interrupt handler, executing an assertion check that fails and thus tries to print an error message on the UART. In a situation where several CPUs might be executing assert() at the same time, we will now get interleaved messages but that should be pretty rare. Change-Id: I6d1603300f6a3ea5756a46338cb950b7ca3e7956 Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
-rw-r--r--lib/stdlib/assert.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/stdlib/assert.c b/lib/stdlib/assert.c
index 39f30d12c..4b53d1e0e 100644
--- a/lib/stdlib/assert.c
+++ b/lib/stdlib/assert.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
+#include <stdio.h>
/*
* This is a basic implementation. This could be improved.
@@ -12,6 +12,8 @@
void __assert (const char *function, const char *file, unsigned int line,
const char *assertion)
{
- mp_printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
- while (1);
+ printf("ASSERT: %s <%d> : %s\n", function, line, assertion);
+
+ while (1)
+ ;
}