Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#ifndef _ASM_GENERIC_BUG_H
2#define _ASM_GENERIC_BUG_H
3
4#include <linux/compiler.h>
5
6#ifdef CONFIG_BUG
7#ifndef HAVE_ARCH_BUG
8#define BUG() do { \
9 printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
10 panic("BUG!"); \
11} while (0)
12#endif
13
14#ifndef HAVE_ARCH_BUG_ON
15#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
16#endif
17
18#ifndef HAVE_ARCH_WARN_ON
19#define WARN_ON(condition) ({ \
20 typeof(condition) __ret_warn_on = (condition); \
21 if (unlikely(__ret_warn_on)) { \
22 printk("BUG: warning at %s:%d/%s()\n", __FILE__, \
23 __LINE__, __FUNCTION__); \
24 dump_stack(); \
25 } \
26 unlikely(__ret_warn_on); \
27})
28#endif
29
30#else /* !CONFIG_BUG */
31#ifndef HAVE_ARCH_BUG
32#define BUG()
33#endif
34
35#ifndef HAVE_ARCH_BUG_ON
36#define BUG_ON(condition) do { if (condition) ; } while(0)
37#endif
38
39#ifndef HAVE_ARCH_WARN_ON
40#define WARN_ON(condition) ({ \
41 typeof(condition) __ret_warn_on = (condition); \
42 unlikely(__ret_warn_on); \
43})
44#endif
45#endif
46
47#define WARN_ON_ONCE(condition) ({ \
48 static int __warned; \
49 typeof(condition) __ret_warn_once = (condition); \
50 \
51 if (unlikely(__ret_warn_once)) \
52 if (WARN_ON(!__warned)) \
53 __warned = 1; \
54 unlikely(__ret_warn_once); \
55})
56
57#ifdef CONFIG_SMP
58# define WARN_ON_SMP(x) WARN_ON(x)
59#else
60# define WARN_ON_SMP(x) do { } while (0)
61#endif
62
63#endif