diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-24 13:08:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-24 13:08:39 -0400 |
commit | ed2d265d1266736bd294332d7f649003943ae36e (patch) | |
tree | 860e5b7bb72933e4a9abacdc2f2d75a0e6254e32 /include/linux | |
parent | f1d38e423a697b7aa06e12d3ca4753bcc1aa3531 (diff) | |
parent | 6c03438edeb5c359af35f060ea016ca65671c269 (diff) |
Merge tag 'bug-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux
Pull <linux/bug.h> cleanup from Paul Gortmaker:
"The changes shown here are to unify linux's BUG support under the one
<linux/bug.h> file. Due to historical reasons, we have some BUG code
in bug.h and some in kernel.h -- i.e. the support for BUILD_BUG in
linux/kernel.h predates the addition of linux/bug.h, but old code in
kernel.h wasn't moved to bug.h at that time. As a band-aid, kernel.h
was including <asm/bug.h> to pseudo link them.
This has caused confusion[1] and general yuck/WTF[2] reactions. Here
is an example that violates the principle of least surprise:
CC lib/string.o
lib/string.c: In function 'strlcat':
lib/string.c:225:2: error: implicit declaration of function 'BUILD_BUG_ON'
make[2]: *** [lib/string.o] Error 1
$
$ grep linux/bug.h lib/string.c
#include <linux/bug.h>
$
We've included <linux/bug.h> for the BUG infrastructure and yet we
still get a compile fail! [We've not kernel.h for BUILD_BUG_ON.] Ugh -
very confusing for someone who is new to kernel development.
With the above in mind, the goals of this changeset are:
1) find and fix any include/*.h files that were relying on the
implicit presence of BUG code.
2) find and fix any C files that were consuming kernel.h and hence
relying on implicitly getting some/all BUG code.
3) Move the BUG related code living in kernel.h to <linux/bug.h>
4) remove the asm/bug.h from kernel.h to finally break the chain.
During development, the order was more like 3-4, build-test, 1-2. But
to ensure that git history for bisect doesn't get needless build
failures introduced, the commits have been reorderd to fix the problem
areas in advance.
[1] https://lkml.org/lkml/2012/1/3/90
[2] https://lkml.org/lkml/2012/1/17/414"
Fix up conflicts (new radeon file, reiserfs header cleanups) as per Paul
and linux-next.
* tag 'bug-for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux:
kernel.h: doesn't explicitly use bug.h, so don't include it.
bug: consolidate BUILD_BUG_ON with other bug code
BUG: headers with BUG/BUG_ON etc. need linux/bug.h
bug.h: add include of it to various implicit C users
lib: fix implicit users of kernel.h for TAINT_WARN
spinlock: macroize assert_spin_locked to avoid bug.h dependency
x86: relocate get/set debugreg fcns to include/asm/debugreg.
Diffstat (limited to 'include/linux')
46 files changed, 109 insertions, 69 deletions
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h index f4ff882cb2da..42c471afc52a 100644 --- a/include/linux/atmdev.h +++ b/include/linux/atmdev.h | |||
@@ -217,6 +217,7 @@ struct atm_cirange { | |||
217 | #include <linux/wait.h> /* wait_queue_head_t */ | 217 | #include <linux/wait.h> /* wait_queue_head_t */ |
218 | #include <linux/time.h> /* struct timeval */ | 218 | #include <linux/time.h> /* struct timeval */ |
219 | #include <linux/net.h> | 219 | #include <linux/net.h> |
220 | #include <linux/bug.h> | ||
220 | #include <linux/skbuff.h> /* struct sk_buff */ | 221 | #include <linux/skbuff.h> /* struct sk_buff */ |
221 | #include <linux/uio.h> | 222 | #include <linux/uio.h> |
222 | #include <net/sock.h> | 223 | #include <net/sock.h> |
diff --git a/include/linux/bio.h b/include/linux/bio.h index de5422a57511..4d94eb8bcbcc 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/highmem.h> | 23 | #include <linux/highmem.h> |
24 | #include <linux/mempool.h> | 24 | #include <linux/mempool.h> |
25 | #include <linux/ioprio.h> | 25 | #include <linux/ioprio.h> |
26 | #include <linux/bug.h> | ||
26 | 27 | ||
27 | #ifdef CONFIG_BLOCK | 28 | #ifdef CONFIG_BLOCK |
28 | 29 | ||
diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h index ac4d9f8b52e9..3b5bafce4337 100644 --- a/include/linux/bit_spinlock.h +++ b/include/linux/bit_spinlock.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | #include <linux/preempt.h> | 5 | #include <linux/preempt.h> |
6 | #include <linux/atomic.h> | 6 | #include <linux/atomic.h> |
7 | #include <linux/bug.h> | ||
7 | 8 | ||
8 | /* | 9 | /* |
9 | * bit-based spin_lock() | 10 | * bit-based spin_lock() |
diff --git a/include/linux/bug.h b/include/linux/bug.h index d276b5510c83..72961c39576a 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h | |||
@@ -11,6 +11,67 @@ enum bug_trap_type { | |||
11 | 11 | ||
12 | struct pt_regs; | 12 | struct pt_regs; |
13 | 13 | ||
14 | #ifdef __CHECKER__ | ||
15 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) | ||
16 | #define BUILD_BUG_ON_ZERO(e) (0) | ||
17 | #define BUILD_BUG_ON_NULL(e) ((void*)0) | ||
18 | #define BUILD_BUG_ON(condition) | ||
19 | #define BUILD_BUG() (0) | ||
20 | #else /* __CHECKER__ */ | ||
21 | |||
22 | /* Force a compilation error if a constant expression is not a power of 2 */ | ||
23 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | ||
24 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) | ||
25 | |||
26 | /* Force a compilation error if condition is true, but also produce a | ||
27 | result (of value 0 and type size_t), so the expression can be used | ||
28 | e.g. in a structure initializer (or where-ever else comma expressions | ||
29 | aren't permitted). */ | ||
30 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | ||
31 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | ||
32 | |||
33 | /** | ||
34 | * BUILD_BUG_ON - break compile if a condition is true. | ||
35 | * @condition: the condition which the compiler should know is false. | ||
36 | * | ||
37 | * If you have some code which relies on certain constants being equal, or | ||
38 | * other compile-time-evaluated condition, you should use BUILD_BUG_ON to | ||
39 | * detect if someone changes it. | ||
40 | * | ||
41 | * The implementation uses gcc's reluctance to create a negative array, but | ||
42 | * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments | ||
43 | * to inline functions). So as a fallback we use the optimizer; if it can't | ||
44 | * prove the condition is false, it will cause a link error on the undefined | ||
45 | * "__build_bug_on_failed". This error message can be harder to track down | ||
46 | * though, hence the two different methods. | ||
47 | */ | ||
48 | #ifndef __OPTIMIZE__ | ||
49 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ||
50 | #else | ||
51 | extern int __build_bug_on_failed; | ||
52 | #define BUILD_BUG_ON(condition) \ | ||
53 | do { \ | ||
54 | ((void)sizeof(char[1 - 2*!!(condition)])); \ | ||
55 | if (condition) __build_bug_on_failed = 1; \ | ||
56 | } while(0) | ||
57 | #endif | ||
58 | |||
59 | /** | ||
60 | * BUILD_BUG - break compile if used. | ||
61 | * | ||
62 | * If you have some code that you expect the compiler to eliminate at | ||
63 | * build time, you should use BUILD_BUG to detect if it is | ||
64 | * unexpectedly used. | ||
65 | */ | ||
66 | #define BUILD_BUG() \ | ||
67 | do { \ | ||
68 | extern void __build_bug_failed(void) \ | ||
69 | __linktime_error("BUILD_BUG failed"); \ | ||
70 | __build_bug_failed(); \ | ||
71 | } while (0) | ||
72 | |||
73 | #endif /* __CHECKER__ */ | ||
74 | |||
14 | #ifdef CONFIG_GENERIC_BUG | 75 | #ifdef CONFIG_GENERIC_BUG |
15 | #include <asm-generic/bug.h> | 76 | #include <asm-generic/bug.h> |
16 | 77 | ||
diff --git a/include/linux/ceph/decode.h b/include/linux/ceph/decode.h index c5b6939fb32a..220ae21e819b 100644 --- a/include/linux/ceph/decode.h +++ b/include/linux/ceph/decode.h | |||
@@ -1,8 +1,9 @@ | |||
1 | #ifndef __CEPH_DECODE_H | 1 | #ifndef __CEPH_DECODE_H |
2 | #define __CEPH_DECODE_H | 2 | #define __CEPH_DECODE_H |
3 | 3 | ||
4 | #include <asm/unaligned.h> | 4 | #include <linux/bug.h> |
5 | #include <linux/time.h> | 5 | #include <linux/time.h> |
6 | #include <asm/unaligned.h> | ||
6 | 7 | ||
7 | #include "types.h" | 8 | #include "types.h" |
8 | 9 | ||
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 95bd8502e715..e8cf0ccd1a8d 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/backing-dev.h> | 7 | #include <linux/backing-dev.h> |
8 | #include <linux/completion.h> | 8 | #include <linux/completion.h> |
9 | #include <linux/exportfs.h> | 9 | #include <linux/exportfs.h> |
10 | #include <linux/bug.h> | ||
10 | #include <linux/fs.h> | 11 | #include <linux/fs.h> |
11 | #include <linux/mempool.h> | 12 | #include <linux/mempool.h> |
12 | #include <linux/pagemap.h> | 13 | #include <linux/pagemap.h> |
diff --git a/include/linux/ceph/mdsmap.h b/include/linux/ceph/mdsmap.h index 4c5cb0880bba..9935fac8c107 100644 --- a/include/linux/ceph/mdsmap.h +++ b/include/linux/ceph/mdsmap.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef _FS_CEPH_MDSMAP_H | 1 | #ifndef _FS_CEPH_MDSMAP_H |
2 | #define _FS_CEPH_MDSMAP_H | 2 | #define _FS_CEPH_MDSMAP_H |
3 | 3 | ||
4 | #include <linux/bug.h> | ||
4 | #include "types.h" | 5 | #include "types.h" |
5 | 6 | ||
6 | /* | 7 | /* |
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 4f7a63237471..7b9b75a529be 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/threads.h> | 10 | #include <linux/threads.h> |
11 | #include <linux/bitmap.h> | 11 | #include <linux/bitmap.h> |
12 | #include <linux/bug.h> | ||
12 | 13 | ||
13 | typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; | 14 | typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; |
14 | 15 | ||
diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 48ce5479386c..b92eadf92d72 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/atomic.h> | 20 | #include <linux/atomic.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
23 | #include <linux/bug.h> | ||
23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
24 | #include <linux/string.h> | 25 | #include <linux/string.h> |
25 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h index 5033fb88c107..94f20c1488a1 100644 --- a/include/linux/debug_locks.h +++ b/include/linux/debug_locks.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | #include <linux/atomic.h> | 5 | #include <linux/atomic.h> |
6 | #include <linux/bug.h> | ||
6 | #include <asm/system.h> | 7 | #include <asm/system.h> |
7 | 8 | ||
8 | struct task_struct; | 9 | struct task_struct; |
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 679b349d9b66..a5966f691ef8 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/device.h> | 24 | #include <linux/device.h> |
25 | #include <linux/uio.h> | 25 | #include <linux/uio.h> |
26 | #include <linux/bug.h> | ||
26 | #include <linux/scatterlist.h> | 27 | #include <linux/scatterlist.h> |
27 | #include <linux/bitmap.h> | 28 | #include <linux/bitmap.h> |
28 | #include <asm/page.h> | 29 | #include <asm/page.h> |
diff --git a/include/linux/elfcore.h b/include/linux/elfcore.h index 394a3e0e4a6b..0698c79fbcb2 100644 --- a/include/linux/elfcore.h +++ b/include/linux/elfcore.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/time.h> | 6 | #include <linux/time.h> |
7 | #ifdef __KERNEL__ | 7 | #ifdef __KERNEL__ |
8 | #include <linux/user.h> | 8 | #include <linux/user.h> |
9 | #include <linux/bug.h> | ||
9 | #endif | 10 | #endif |
10 | #include <linux/ptrace.h> | 11 | #include <linux/ptrace.h> |
11 | #include <linux/elf.h> | 12 | #include <linux/elf.h> |
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h index f957085d40ed..f5a84eef6ed2 100644 --- a/include/linux/ext3_fs.h +++ b/include/linux/ext3_fs.h | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
20 | #include <linux/magic.h> | 20 | #include <linux/magic.h> |
21 | #include <linux/bug.h> | ||
21 | 22 | ||
22 | /* | 23 | /* |
23 | * The second extended filesystem constants/structures | 24 | * The second extended filesystem constants/structures |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 9bbe1a9ac432..fa63f1b46103 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -389,6 +389,7 @@ struct inodes_stat_t { | |||
389 | #include <linux/prio_tree.h> | 389 | #include <linux/prio_tree.h> |
390 | #include <linux/init.h> | 390 | #include <linux/init.h> |
391 | #include <linux/pid.h> | 391 | #include <linux/pid.h> |
392 | #include <linux/bug.h> | ||
392 | #include <linux/mutex.h> | 393 | #include <linux/mutex.h> |
393 | #include <linux/capability.h> | 394 | #include <linux/capability.h> |
394 | #include <linux/semaphore.h> | 395 | #include <linux/semaphore.h> |
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 2a53f10712b3..a6dfe6944564 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/fsnotify_backend.h> | 14 | #include <linux/fsnotify_backend.h> |
15 | #include <linux/audit.h> | 15 | #include <linux/audit.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/bug.h> | ||
17 | 18 | ||
18 | /* | 19 | /* |
19 | * fsnotify_d_instantiate - instantiate a dentry for inode | 20 | * fsnotify_d_instantiate - instantiate a dentry for inode |
diff --git a/include/linux/gpio.h b/include/linux/gpio.h index 38ac48b7d3a8..ed5a46707ad0 100644 --- a/include/linux/gpio.h +++ b/include/linux/gpio.h | |||
@@ -34,6 +34,7 @@ struct gpio { | |||
34 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
35 | #include <linux/types.h> | 35 | #include <linux/types.h> |
36 | #include <linux/errno.h> | 36 | #include <linux/errno.h> |
37 | #include <linux/bug.h> | ||
37 | 38 | ||
38 | struct device; | 39 | struct device; |
39 | struct gpio_chip; | 40 | struct gpio_chip; |
diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 6549ed75e0a7..d3999b4e26cc 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
5 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
6 | #include <linux/bug.h> | ||
6 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
7 | #include <linux/uaccess.h> | 8 | #include <linux/uaccess.h> |
8 | #include <linux/hardirq.h> | 9 | #include <linux/hardirq.h> |
diff --git a/include/linux/i2o.h b/include/linux/i2o.h index a6deef4f4f67..d23c3c20b201 100644 --- a/include/linux/i2o.h +++ b/include/linux/i2o.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #define I2O_MAX_DRIVERS 8 | 24 | #define I2O_MAX_DRIVERS 8 |
25 | 25 | ||
26 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
27 | #include <linux/bug.h> | ||
27 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
28 | #include <linux/string.h> | 29 | #include <linux/string.h> |
29 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 33a6e1951d4d..a810987cb80e 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
18 | #include <linux/etherdevice.h> | 18 | #include <linux/etherdevice.h> |
19 | #include <linux/rtnetlink.h> | 19 | #include <linux/rtnetlink.h> |
20 | #include <linux/bug.h> | ||
20 | 21 | ||
21 | #define VLAN_HLEN 4 /* The additional bytes required by VLAN | 22 | #define VLAN_HLEN 4 /* The additional bytes required by VLAN |
22 | * (in addition to the Ethernet header) | 23 | * (in addition to the Ethernet header) |
diff --git a/include/linux/io-mapping.h b/include/linux/io-mapping.h index e44e84f0156c..657fab4efab3 100644 --- a/include/linux/io-mapping.h +++ b/include/linux/io-mapping.h | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/bug.h> | ||
23 | #include <asm/io.h> | 24 | #include <asm/io.h> |
24 | #include <asm/page.h> | 25 | #include <asm/page.h> |
25 | 26 | ||
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3e140add5360..5db52d0ff1d4 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/printk.h> | 20 | #include <linux/printk.h> |
21 | #include <linux/dynamic_debug.h> | 21 | #include <linux/dynamic_debug.h> |
22 | #include <asm/byteorder.h> | 22 | #include <asm/byteorder.h> |
23 | #include <asm/bug.h> | ||
24 | 23 | ||
25 | #define USHRT_MAX ((u16)(~0U)) | 24 | #define USHRT_MAX ((u16)(~0U)) |
26 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) | 25 | #define SHRT_MAX ((s16)(USHRT_MAX>>1)) |
@@ -677,67 +676,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
677 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | 676 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
678 | (type *)( (char *)__mptr - offsetof(type,member) );}) | 677 | (type *)( (char *)__mptr - offsetof(type,member) );}) |
679 | 678 | ||
680 | #ifdef __CHECKER__ | ||
681 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) | ||
682 | #define BUILD_BUG_ON_ZERO(e) (0) | ||
683 | #define BUILD_BUG_ON_NULL(e) ((void*)0) | ||
684 | #define BUILD_BUG_ON(condition) | ||
685 | #define BUILD_BUG() (0) | ||
686 | #else /* __CHECKER__ */ | ||
687 | |||
688 | /* Force a compilation error if a constant expression is not a power of 2 */ | ||
689 | #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ | ||
690 | BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) | ||
691 | |||
692 | /* Force a compilation error if condition is true, but also produce a | ||
693 | result (of value 0 and type size_t), so the expression can be used | ||
694 | e.g. in a structure initializer (or where-ever else comma expressions | ||
695 | aren't permitted). */ | ||
696 | #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) | ||
697 | #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) | ||
698 | |||
699 | /** | ||
700 | * BUILD_BUG_ON - break compile if a condition is true. | ||
701 | * @condition: the condition which the compiler should know is false. | ||
702 | * | ||
703 | * If you have some code which relies on certain constants being equal, or | ||
704 | * other compile-time-evaluated condition, you should use BUILD_BUG_ON to | ||
705 | * detect if someone changes it. | ||
706 | * | ||
707 | * The implementation uses gcc's reluctance to create a negative array, but | ||
708 | * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments | ||
709 | * to inline functions). So as a fallback we use the optimizer; if it can't | ||
710 | * prove the condition is false, it will cause a link error on the undefined | ||
711 | * "__build_bug_on_failed". This error message can be harder to track down | ||
712 | * though, hence the two different methods. | ||
713 | */ | ||
714 | #ifndef __OPTIMIZE__ | ||
715 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | ||
716 | #else | ||
717 | extern int __build_bug_on_failed; | ||
718 | #define BUILD_BUG_ON(condition) \ | ||
719 | do { \ | ||
720 | ((void)sizeof(char[1 - 2*!!(condition)])); \ | ||
721 | if (condition) __build_bug_on_failed = 1; \ | ||
722 | } while(0) | ||
723 | #endif | ||
724 | |||
725 | /** | ||
726 | * BUILD_BUG - break compile if used. | ||
727 | * | ||
728 | * If you have some code that you expect the compiler to eliminate at | ||
729 | * build time, you should use BUILD_BUG to detect if it is | ||
730 | * unexpectedly used. | ||
731 | */ | ||
732 | #define BUILD_BUG() \ | ||
733 | do { \ | ||
734 | extern void __build_bug_failed(void) \ | ||
735 | __linktime_error("BUILD_BUG failed"); \ | ||
736 | __build_bug_failed(); \ | ||
737 | } while (0) | ||
738 | |||
739 | #endif /* __CHECKER__ */ | ||
740 | |||
741 | /* Trap pasters of __FUNCTION__ at compile-time */ | 679 | /* Trap pasters of __FUNCTION__ at compile-time */ |
742 | #define __FUNCTION__ (__func__) | 680 | #define __FUNCTION__ (__func__) |
743 | 681 | ||
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index dce6e4dbeda7..b6e1f8c00577 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/list.h> | 33 | #include <linux/list.h> |
34 | #include <linux/notifier.h> | 34 | #include <linux/notifier.h> |
35 | #include <linux/smp.h> | 35 | #include <linux/smp.h> |
36 | #include <linux/bug.h> | ||
36 | #include <linux/percpu.h> | 37 | #include <linux/percpu.h> |
37 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
38 | #include <linux/rcupdate.h> | 39 | #include <linux/rcupdate.h> |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 900c76337e8f..ca1b153585d3 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/spinlock.h> | 13 | #include <linux/spinlock.h> |
14 | #include <linux/signal.h> | 14 | #include <linux/signal.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/bug.h> | ||
16 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
17 | #include <linux/mmu_notifier.h> | 18 | #include <linux/mmu_notifier.h> |
18 | #include <linux/preempt.h> | 19 | #include <linux/preempt.h> |
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 0b8e2a742600..910550f3b70e 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/mmzone.h> | 4 | #include <linux/mmzone.h> |
5 | #include <linux/spinlock.h> | 5 | #include <linux/spinlock.h> |
6 | #include <linux/notifier.h> | 6 | #include <linux/notifier.h> |
7 | #include <linux/bug.h> | ||
7 | 8 | ||
8 | struct page; | 9 | struct page; |
9 | struct zone; | 10 | struct zone; |
diff --git a/include/linux/mm.h b/include/linux/mm.h index a6fabdfd34c5..cf7982336103 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #ifdef __KERNEL__ | 6 | #ifdef __KERNEL__ |
7 | 7 | ||
8 | #include <linux/gfp.h> | 8 | #include <linux/gfp.h> |
9 | #include <linux/bug.h> | ||
9 | #include <linux/list.h> | 10 | #include <linux/list.h> |
10 | #include <linux/mmzone.h> | 11 | #include <linux/mmzone.h> |
11 | #include <linux/rbtree.h> | 12 | #include <linux/rbtree.h> |
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h index d5d2ec6494bb..37ef6b194089 100644 --- a/include/linux/mtd/cfi.h +++ b/include/linux/mtd/cfi.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/bug.h> | ||
25 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
26 | #include <linux/mtd/flashchip.h> | 27 | #include <linux/mtd/flashchip.h> |
27 | #include <linux/mtd/map.h> | 28 | #include <linux/mtd/map.h> |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8debe299676d..33b4f66374bd 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #ifdef __KERNEL__ | 33 | #ifdef __KERNEL__ |
34 | #include <linux/pm_qos.h> | 34 | #include <linux/pm_qos.h> |
35 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
36 | #include <linux/bug.h> | ||
36 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
37 | #include <linux/atomic.h> | 38 | #include <linux/atomic.h> |
38 | #include <asm/cache.h> | 39 | #include <asm/cache.h> |
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h index 7454ad7451b4..89bd4a4dcfb4 100644 --- a/include/linux/nilfs2_fs.h +++ b/include/linux/nilfs2_fs.h | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/types.h> | 41 | #include <linux/types.h> |
42 | #include <linux/ioctl.h> | 42 | #include <linux/ioctl.h> |
43 | #include <linux/magic.h> | 43 | #include <linux/magic.h> |
44 | #include <linux/bug.h> | ||
44 | 45 | ||
45 | 46 | ||
46 | #define NILFS_INODE_BMAP_SIZE 7 | 47 | #define NILFS_INODE_BMAP_SIZE 7 |
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 6b25758e028e..c88d2a9451af 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #define PAGE_FLAGS_H | 6 | #define PAGE_FLAGS_H |
7 | 7 | ||
8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
9 | #include <linux/bug.h> | ||
9 | #ifndef __GENERATING_BOUNDS_H | 10 | #ifndef __GENERATING_BOUNDS_H |
10 | #include <linux/mm_types.h> | 11 | #include <linux/mm_types.h> |
11 | #include <generated/bounds.h> | 12 | #include <generated/bounds.h> |
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index e7cf6669ac34..f5bd679be46b 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _LINUX_PID_NS_H | 2 | #define _LINUX_PID_NS_H |
3 | 3 | ||
4 | #include <linux/sched.h> | 4 | #include <linux/sched.h> |
5 | #include <linux/bug.h> | ||
5 | #include <linux/mm.h> | 6 | #include <linux/mm.h> |
6 | #include <linux/threads.h> | 7 | #include <linux/threads.h> |
7 | #include <linux/nsproxy.h> | 8 | #include <linux/nsproxy.h> |
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h index b7681102a4b9..11bad91c4433 100644 --- a/include/linux/posix_acl.h +++ b/include/linux/posix_acl.h | |||
@@ -8,6 +8,7 @@ | |||
8 | #ifndef __LINUX_POSIX_ACL_H | 8 | #ifndef __LINUX_POSIX_ACL_H |
9 | #define __LINUX_POSIX_ACL_H | 9 | #define __LINUX_POSIX_ACL_H |
10 | 10 | ||
11 | #include <linux/bug.h> | ||
11 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
12 | #include <linux/rcupdate.h> | 13 | #include <linux/rcupdate.h> |
13 | 14 | ||
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 407c678d2e30..5c719627c2aa 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
@@ -108,6 +108,7 @@ | |||
108 | #include <linux/compiler.h> /* For unlikely. */ | 108 | #include <linux/compiler.h> /* For unlikely. */ |
109 | #include <linux/sched.h> /* For struct task_struct. */ | 109 | #include <linux/sched.h> /* For struct task_struct. */ |
110 | #include <linux/err.h> /* for IS_ERR_VALUE */ | 110 | #include <linux/err.h> /* for IS_ERR_VALUE */ |
111 | #include <linux/bug.h> /* For BUG_ON. */ | ||
111 | 112 | ||
112 | 113 | ||
113 | extern long arch_ptrace(struct task_struct *child, long request, | 114 | extern long arch_ptrace(struct task_struct *child, long request, |
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index 07e360b1b282..e9a48234e693 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include <linux/preempt.h> | 23 | #include <linux/preempt.h> |
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <linux/bug.h> | ||
25 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
26 | #include <linux/rcupdate.h> | 27 | #include <linux/rcupdate.h> |
27 | 28 | ||
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 2c62594b67dd..20fb776a1d4a 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <linux/lockdep.h> | 42 | #include <linux/lockdep.h> |
43 | #include <linux/completion.h> | 43 | #include <linux/completion.h> |
44 | #include <linux/debugobjects.h> | 44 | #include <linux/debugobjects.h> |
45 | #include <linux/bug.h> | ||
45 | #include <linux/compiler.h> | 46 | #include <linux/compiler.h> |
46 | 47 | ||
47 | #ifdef CONFIG_RCU_TORTURE_TEST | 48 | #ifdef CONFIG_RCU_TORTURE_TEST |
diff --git a/include/linux/regset.h b/include/linux/regset.h index 686f37327a49..8e0c9febf495 100644 --- a/include/linux/regset.h +++ b/include/linux/regset.h | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/compiler.h> | 16 | #include <linux/compiler.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/bug.h> | ||
18 | #include <linux/uaccess.h> | 19 | #include <linux/uaccess.h> |
19 | struct task_struct; | 20 | struct task_struct; |
20 | struct user_regset; | 21 | struct user_regset; |
diff --git a/include/linux/relay.h b/include/linux/relay.h index a822fd71fd64..91cacc34c159 100644 --- a/include/linux/relay.h +++ b/include/linux/relay.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/timer.h> | 15 | #include <linux/timer.h> |
16 | #include <linux/wait.h> | 16 | #include <linux/wait.h> |
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/bug.h> | ||
18 | #include <linux/fs.h> | 19 | #include <linux/fs.h> |
19 | #include <linux/poll.h> | 20 | #include <linux/poll.h> |
20 | #include <linux/kref.h> | 21 | #include <linux/kref.h> |
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 9aaf5bfdad1a..ac9586dadfa5 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h | |||
@@ -1,10 +1,12 @@ | |||
1 | #ifndef _LINUX_SCATTERLIST_H | 1 | #ifndef _LINUX_SCATTERLIST_H |
2 | #define _LINUX_SCATTERLIST_H | 2 | #define _LINUX_SCATTERLIST_H |
3 | 3 | ||
4 | #include <linux/string.h> | ||
5 | #include <linux/bug.h> | ||
6 | #include <linux/mm.h> | ||
7 | |||
4 | #include <asm/types.h> | 8 | #include <asm/types.h> |
5 | #include <asm/scatterlist.h> | 9 | #include <asm/scatterlist.h> |
6 | #include <linux/mm.h> | ||
7 | #include <linux/string.h> | ||
8 | #include <asm/io.h> | 10 | #include <asm/io.h> |
9 | 11 | ||
10 | struct sg_table { | 12 | struct sg_table { |
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 54e5ae7f8adc..fc61854f6224 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/string.h> | 5 | #include <linux/string.h> |
6 | #include <linux/bug.h> | ||
6 | #include <linux/mutex.h> | 7 | #include <linux/mutex.h> |
7 | #include <linux/cpumask.h> | 8 | #include <linux/cpumask.h> |
8 | #include <linux/nodemask.h> | 9 | #include <linux/nodemask.h> |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a2b9953b582d..3fcb204a2612 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/kmemcheck.h> | 18 | #include <linux/kmemcheck.h> |
19 | #include <linux/compiler.h> | 19 | #include <linux/compiler.h> |
20 | #include <linux/time.h> | 20 | #include <linux/time.h> |
21 | #include <linux/bug.h> | ||
21 | #include <linux/cache.h> | 22 | #include <linux/cache.h> |
22 | 23 | ||
23 | #include <linux/atomic.h> | 24 | #include <linux/atomic.h> |
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index a32bcfdc7834..ca122b36aec1 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -8,6 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/gfp.h> | 10 | #include <linux/gfp.h> |
11 | #include <linux/bug.h> | ||
11 | #include <linux/workqueue.h> | 12 | #include <linux/workqueue.h> |
12 | #include <linux/kobject.h> | 13 | #include <linux/kobject.h> |
13 | 14 | ||
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 7df6c17b0281..363239087263 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
@@ -375,10 +375,7 @@ static inline int spin_can_lock(spinlock_t *lock) | |||
375 | return raw_spin_can_lock(&lock->rlock); | 375 | return raw_spin_can_lock(&lock->rlock); |
376 | } | 376 | } |
377 | 377 | ||
378 | static inline void assert_spin_locked(spinlock_t *lock) | 378 | #define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock) |
379 | { | ||
380 | assert_raw_spin_locked(&lock->rlock); | ||
381 | } | ||
382 | 379 | ||
383 | /* | 380 | /* |
384 | * Pull the atomic_t declaration: | 381 | * Pull the atomic_t declaration: |
diff --git a/include/linux/ssb/ssb_driver_gige.h b/include/linux/ssb/ssb_driver_gige.h index eba52a100533..6b05dcd927ff 100644 --- a/include/linux/ssb/ssb_driver_gige.h +++ b/include/linux/ssb/ssb_driver_gige.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define LINUX_SSB_DRIVER_GIGE_H_ | 2 | #define LINUX_SSB_DRIVER_GIGE_H_ |
3 | 3 | ||
4 | #include <linux/ssb/ssb.h> | 4 | #include <linux/ssb/ssb.h> |
5 | #include <linux/bug.h> | ||
5 | #include <linux/pci.h> | 6 | #include <linux/pci.h> |
6 | #include <linux/spinlock.h> | 7 | #include <linux/spinlock.h> |
7 | 8 | ||
diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 2189d3ffc85d..792d16d9cbc7 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _LINUX_SWAPOPS_H | 2 | #define _LINUX_SWAPOPS_H |
3 | 3 | ||
4 | #include <linux/radix-tree.h> | 4 | #include <linux/radix-tree.h> |
5 | #include <linux/bug.h> | ||
5 | 6 | ||
6 | /* | 7 | /* |
7 | * swapcache pages are stored in the swapper_space radix tree. We want to | 8 | * swapcache pages are stored in the swapper_space radix tree. We want to |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 8ec1153ff57b..3de3acb84a95 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -68,6 +68,7 @@ struct file_handle; | |||
68 | #include <linux/aio_abi.h> | 68 | #include <linux/aio_abi.h> |
69 | #include <linux/capability.h> | 69 | #include <linux/capability.h> |
70 | #include <linux/list.h> | 70 | #include <linux/list.h> |
71 | #include <linux/bug.h> | ||
71 | #include <linux/sem.h> | 72 | #include <linux/sem.h> |
72 | #include <asm/siginfo.h> | 73 | #include <asm/siginfo.h> |
73 | #include <asm/signal.h> | 74 | #include <asm/signal.h> |
diff --git a/include/linux/transport_class.h b/include/linux/transport_class.h index 9ae8da3e6407..11087cdd4ad3 100644 --- a/include/linux/transport_class.h +++ b/include/linux/transport_class.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #define _TRANSPORT_CLASS_H_ | 10 | #define _TRANSPORT_CLASS_H_ |
11 | 11 | ||
12 | #include <linux/device.h> | 12 | #include <linux/device.h> |
13 | #include <linux/bug.h> | ||
13 | #include <linux/attribute_container.h> | 14 | #include <linux/attribute_container.h> |
14 | 15 | ||
15 | struct transport_container; | 16 | struct transport_container; |
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 5206d6541da5..7323a3390206 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h | |||
@@ -53,6 +53,7 @@ | |||
53 | 53 | ||
54 | #ifdef __KERNEL__ | 54 | #ifdef __KERNEL__ |
55 | #include <linux/err.h> | 55 | #include <linux/err.h> |
56 | #include <linux/bug.h> | ||
56 | #include <linux/virtio.h> | 57 | #include <linux/virtio.h> |
57 | 58 | ||
58 | /** | 59 | /** |