From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Sun, 12 Jun 2016 23:33:14 -0600 Subject: [U-Boot] [PATCH v2 33/55] tiny-printf: Support assert() In-Reply-To: <1465796016-18375-1-git-send-email-sjg@chromium.org> References: <1465796016-18375-1-git-send-email-sjg@chromium.org> Message-ID: <1465796016-18375-34-git-send-email-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- Changes in v2: None lib/tiny-printf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index 3c65fc9..2aeee2a 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -175,3 +175,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(); +} -- 2.8.0.rc3.226.g39d4020