diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-05-20 15:29:25 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-05-20 15:29:25 +0100 |
commit | eaa024d29620e08f75090ffc90343c09176c2b12 (patch) | |
tree | 22f3417bbbb3b469a6245782f9bd59497187756a /xen/include/xen/lib.h | |
parent | 9f6d07bac9f14aaa8bafe38b4a217e61a3a57842 (diff) | |
download | xen-eaa024d29620e08f75090ffc90343c09176c2b12.tar.gz xen-eaa024d29620e08f75090ffc90343c09176c2b12.tar.bz2 xen-eaa024d29620e08f75090ffc90343c09176c2b12.zip |
Introduce __must_be_array
Cloning the similar construct from Linux, allowing to detect improper
uses of ARRAY_SIZE() at build time.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen/include/xen/lib.h')
-rw-r--r-- | xen/include/xen/lib.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index f5c21f64f7..ab76120da6 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -18,6 +18,12 @@ void __warn(char *file, int line); /* Force a compilation error if condition is true */ #define BUILD_BUG_ON(condition) ((void)sizeof(struct { int:-!!(condition); })) +/* Force a compilation error if condition is true, but also produce a + result (of value 0 and type size_t), so the expression can be used + e.g. in a structure initializer (or where-ever else comma expressions + aren't permitted). */ +#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) + #ifndef assert_failed #define assert_failed(p) \ do { \ |