]>
Commit | Line | Data |
---|---|---|
2b22a99c SS |
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 <common.h> | |
db41d65a | 13 | #include <hang.h> |
2b22a99c SS |
14 | #if !defined(CONFIG_PANIC_HANG) |
15 | #include <command.h> | |
16 | #endif | |
17 | ||
18 | static void panic_finish(void) __attribute__ ((noreturn)); | |
19 | ||
20 | static void panic_finish(void) | |
21 | { | |
22 | putc('\n'); | |
23 | #if defined(CONFIG_PANIC_HANG) | |
24 | hang(); | |
25 | #else | |
26 | udelay(100000); /* allow messages to go out */ | |
27 | do_reset(NULL, 0, 0, NULL); | |
28 | #endif | |
29 | while (1) | |
30 | ; | |
31 | } | |
32 | ||
33 | void panic_str(const char *str) | |
34 | { | |
35 | puts(str); | |
36 | panic_finish(); | |
37 | } | |
38 | ||
39 | void panic(const char *fmt, ...) | |
40 | { | |
4f1eed75 | 41 | #if CONFIG_IS_ENABLED(PRINTF) |
2b22a99c SS |
42 | va_list args; |
43 | va_start(args, fmt); | |
44 | vprintf(fmt, args); | |
45 | va_end(args); | |
4f1eed75 | 46 | #endif |
2b22a99c SS |
47 | panic_finish(); |
48 | } | |
e21c03be AK |
49 | |
50 | void __assert_fail(const char *assertion, const char *file, unsigned int line, | |
51 | const char *function) | |
52 | { | |
53 | /* This will not return */ | |
54 | panic("%s:%u: %s: Assertion `%s' failed.", file, line, function, | |
55 | assertion); | |
56 | } |