Rev 3747 | Rev 5056 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3747 | Rev 3763 | ||
---|---|---|---|
1 | #ifndef _ASM_GENERIC_BUG_H |
1 | #ifndef _ASM_GENERIC_BUG_H |
2 | #define _ASM_GENERIC_BUG_H |
2 | #define _ASM_GENERIC_BUG_H |
3 | 3 | ||
4 | //extern __printf(3, 4) |
4 | //extern __printf(3, 4) |
5 | //void warn_slowpath_fmt(const char *file, const int line, |
5 | //void warn_slowpath_fmt(const char *file, const int line, |
6 | // const char *fmt, ...); |
6 | // const char *fmt, ...); |
7 | //extern __printf(4, 5) |
7 | //extern __printf(4, 5) |
8 | //void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint, |
8 | //void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint, |
9 | // const char *fmt, ...); |
9 | // const char *fmt, ...); |
10 | 10 | ||
11 | //extern void warn_slowpath_null(const char *file, const int line); |
11 | //extern void warn_slowpath_null(const char *file, const int line); |
12 | 12 | ||
13 | #define __WARN() printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__) |
13 | #define __WARN() printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__) |
14 | //#define __WARN_printf(arg...) printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__) |
14 | //#define __WARN_printf(arg...) printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__) |
15 | #define __WARN_printf(arg...) do { printf(arg); __WARN(); } while (0) |
15 | #define __WARN_printf(arg...) do { printf(arg); __WARN(); } while (0) |
16 | 16 | ||
17 | #define WARN(condition, format...) ({ \ |
17 | #define WARN(condition, format...) ({ \ |
18 | int __ret_warn_on = !!(condition); \ |
18 | int __ret_warn_on = !!(condition); \ |
19 | if (unlikely(__ret_warn_on)) \ |
19 | if (unlikely(__ret_warn_on)) \ |
20 | __WARN_printf(format); \ |
20 | __WARN_printf(format); \ |
21 | unlikely(__ret_warn_on); \ |
21 | unlikely(__ret_warn_on); \ |
22 | }) |
22 | }) |
23 | 23 | ||
24 | 24 | ||
25 | #define WARN_ON(condition) ({ \ |
25 | #define WARN_ON(condition) ({ \ |
26 | int __ret_warn_on = !!(condition); \ |
26 | int __ret_warn_on = !!(condition); \ |
27 | if (unlikely(__ret_warn_on)) \ |
27 | if (unlikely(__ret_warn_on)) \ |
28 | __WARN(); \ |
28 | __WARN(); \ |
29 | unlikely(__ret_warn_on); \ |
29 | unlikely(__ret_warn_on); \ |
30 | }) |
30 | }) |
31 | 31 | ||
32 | 32 | ||
33 | #define WARN_ONCE(condition, format...) ({ \ |
33 | #define WARN_ONCE(condition, format...) ({ \ |
34 | static bool __warned; \ |
34 | static bool __warned; \ |
35 | int __ret_warn_once = !!(condition); \ |
35 | int __ret_warn_once = !!(condition); \ |
36 | \ |
36 | \ |
37 | if (unlikely(__ret_warn_once)) \ |
37 | if (unlikely(__ret_warn_once)) \ |
38 | if (WARN(!__warned, format)) \ |
38 | if (WARN(!__warned, format)) \ |
39 | __warned = true; \ |
39 | __warned = true; \ |
40 | unlikely(__ret_warn_once); \ |
40 | unlikely(__ret_warn_once); \ |
41 | }) |
41 | }) |
42 | 42 | ||
43 | 43 | ||
44 | #define WARN_ON_ONCE(condition) ({ \ |
44 | #define WARN_ON_ONCE(condition) ({ \ |
45 | static bool __warned; \ |
45 | static bool __warned; \ |
46 | int __ret_warn_once = !!(condition); \ |
46 | int __ret_warn_once = !!(condition); \ |
47 | \ |
47 | \ |
48 | if (unlikely(__ret_warn_once)) \ |
48 | if (unlikely(__ret_warn_once)) \ |
49 | if (WARN_ON(!__warned)) \ |
49 | if (WARN_ON(!__warned)) \ |
50 | __warned = true; \ |
50 | __warned = true; \ |
51 | unlikely(__ret_warn_once); \ |
51 | unlikely(__ret_warn_once); \ |
52 | }) |
52 | }) |
53 | 53 | ||
54 | #define BUG() do { \ |
54 | #define BUG() do { \ |
55 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
55 | printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \ |
56 | while(1){ delay(10); }; \ |
- | |
57 | } while (0) |
56 | } while (0) |
58 | 57 | ||
59 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
58 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) |
60 | 59 | ||
61 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ |
60 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ |
62 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) |
61 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) |
63 | 62 | ||
64 | 63 | ||
65 | #define printk_once(fmt, ...) \ |
64 | #define printk_once(fmt, ...) \ |
66 | ({ \ |
65 | ({ \ |
67 | static bool __print_once; \ |
66 | static bool __print_once; \ |
68 | \ |
67 | \ |
69 | if (!__print_once) { \ |
68 | if (!__print_once) { \ |
70 | __print_once = true; \ |
69 | __print_once = true; \ |
71 | printk(fmt, ##__VA_ARGS__); \ |
70 | printk(fmt, ##__VA_ARGS__); \ |
72 | } \ |
71 | } \ |
73 | }) |
72 | }) |
74 | 73 | ||
75 | 74 | ||
76 | #define pr_warn_once(fmt, ...) \ |
75 | #define pr_warn_once(fmt, ...) \ |
77 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
76 | printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
78 | 77 | ||
79 | #endif |
78 | #endif |