| 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 | |
| 12 | /** |
| 13 | * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime |
| 14 | * @condition: the condition which should be false. |
| 15 | * |
| 16 | * If the condition is a constant and true, the compiler will generate a build |
| 17 | * error. If the condition is not constant, a BUG will be triggered at runtime |
| 18 | * if the condition is ever true. If the condition is constant and false, no |
| 19 | * code is emitted. |
| 20 | */ |
| 21 | #define BUILD_RUNTIME_BUG_ON(condition) \ |
| 22 | do { \ |
| 23 | if (__builtin_constant_p(condition)) \ |
| 24 | BUILD_BUG_ON(condition); \ |
| 25 | else \ |
| 26 | BUG_ON(condition); \ |
| 27 | } while (0) |
| 28 | |
| 29 | #endif |