From: Simon Glass Date: Mon, 4 Jul 2016 17:58:13 +0000 (-0600) Subject: tiny-printf: Support assert() X-Git-Tag: v2016.09-rc1~82^2~29 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e24091398d50961ece2fcb2924d7c37d329abc09;p=oweals%2Fu-boot.git 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 --- diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index b334f053cc..1aa43aba44 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(); +}