"Das U-Boot" Source Tree
1/*
2 * linux/lib/vsprintf.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
8/*
9 * Wirzenius wrote this portably, Torvalds fucked it up :-)
10 */
11
12#include <hang.h>
13#if !defined(CONFIG_PANIC_HANG)
14#include <command.h>
15#endif
16#include <linux/delay.h>
17#include <stdio.h>
18
19static void panic_finish(void) __attribute__ ((noreturn));
20
21static void panic_finish(void)
22{
23 putc('\n');
24#if defined(CONFIG_PANIC_HANG)
25 hang();
26#else
27 flush(); /* flush the panic message before reset */
28
29 do_reset(NULL, 0, 0, NULL);
30#endif
31 while (1)
32 ;
33}
34
35void panic_str(const char *str)
36{
37 puts(str);
38 panic_finish();
39}
40
41void panic(const char *fmt, ...)
42{
43#if CONFIG_IS_ENABLED(PRINTF)
44 va_list args;
45 va_start(args, fmt);
46 vprintf(fmt, args);
47 va_end(args);
48#endif
49 panic_finish();
50}
51
52void __assert_fail(const char *assertion, const char *file, unsigned int line,
53 const char *function)
54{
55 /* This will not return */
56 panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
57 assertion);
58}