]>
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 | ||
db41d65a | 12 | #include <hang.h> |
2b22a99c SS |
13 | #if !defined(CONFIG_PANIC_HANG) |
14 | #include <command.h> | |
15 | #endif | |
c05ed00a | 16 | #include <linux/delay.h> |
c5f4cdb8 | 17 | #include <stdio.h> |
2b22a99c SS |
18 | |
19 | static void panic_finish(void) __attribute__ ((noreturn)); | |
20 | ||
21 | static void panic_finish(void) | |
22 | { | |
23 | putc('\n'); | |
24 | #if defined(CONFIG_PANIC_HANG) | |
25 | hang(); | |
26 | #else | |
c5f4cdb8 TD |
27 | flush(); /* flush the panic message before reset */ |
28 | ||
2b22a99c SS |
29 | do_reset(NULL, 0, 0, NULL); |
30 | #endif | |
31 | while (1) | |
32 | ; | |
33 | } | |
34 | ||
35 | void panic_str(const char *str) | |
36 | { | |
37 | puts(str); | |
38 | panic_finish(); | |
39 | } | |
40 | ||
41 | void panic(const char *fmt, ...) | |
42 | { | |
4f1eed75 | 43 | #if CONFIG_IS_ENABLED(PRINTF) |
2b22a99c SS |
44 | va_list args; |
45 | va_start(args, fmt); | |
46 | vprintf(fmt, args); | |
47 | va_end(args); | |
4f1eed75 | 48 | #endif |
2b22a99c SS |
49 | panic_finish(); |
50 | } | |
e21c03be AK |
51 | |
52 | void __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 | } |