Commit | Line | Data |
---|---|---|
44d13f19 MD |
1 | #ifndef _LTTNG_BUG_H |
2 | #define _LTTNG_BUG_H | |
3 | ||
4 | /* | |
5 | * lib/bug.h | |
6 | * | |
7 | * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
8 | * | |
9 | * Dual LGPL v2.1/GPL v2 license. | |
10 | */ | |
11 | ||
a6352fd4 MD |
12 | #define BUILD_BUG_ON(condition) \ |
13 | ((void) sizeof(char[-!!(condition)])) | |
14 | ||
44d13f19 MD |
15 | /** |
16 | * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime | |
17 | * @condition: the condition which should be false. | |
18 | * | |
19 | * If the condition is a constant and true, the compiler will generate a build | |
20 | * error. If the condition is not constant, a BUG will be triggered at runtime | |
21 | * if the condition is ever true. If the condition is constant and false, no | |
22 | * code is emitted. | |
23 | */ | |
24 | #define BUILD_RUNTIME_BUG_ON(condition) \ | |
25 | do { \ | |
26 | if (__builtin_constant_p(condition)) \ | |
27 | BUILD_BUG_ON(condition); \ | |
28 | else \ | |
29 | BUG_ON(condition); \ | |
30 | } while (0) | |
31 | ||
32 | #endif |