summaryrefslogtreecommitdiff
path: root/lib/tiny-printf.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-07-04 17:58:13 (GMT)
committerSimon Glass <sjg@chromium.org>2016-07-15 02:40:24 (GMT)
commite24091398d50961ece2fcb2924d7c37d329abc09 (patch)
tree21e3eee7ed96675e87c22bcfc93e0a686923def4 /lib/tiny-printf.c
parent162a7a421718a2d15716a78ffb7abb1d94f6b03a (diff)
downloadu-boot-e24091398d50961ece2fcb2924d7c37d329abc09.tar.xz
tiny-printf: Support assert()
At present assert() is not supported with tiny-printf, so when DEBUG is enabled a build error is generated for each assert(). Add an __assert_fail() function to correct this. It prints a message and then hangs. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/tiny-printf.c')
-rw-r--r--lib/tiny-printf.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index b334f05..1aa43ab 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -185,3 +185,12 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
return ret;
}
+
+void __assert_fail(const char *assertion, const char *file, unsigned line,
+ const char *function)
+{
+ /* This will not return */
+ printf("%s:%u: %s: Assertion `%s' failed.", file, line, function,
+ assertion);
+ hang();
+}