From cc7547baa6725b6ada3cbf7ebaba0814dcb5f212 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 28 Nov 2011 07:42:11 -0500 Subject: [PATCH] --- yaml --- r: 281151 b: refs/heads/master c: a643061cb861ebb18e0292b7510dd9879b598ae0 h: refs/heads/master i: 281149: b82d2c32c95317103a7d6088a7bbea6f4e61dda6 281147: e8390117221200a1cfc24cc78b99c2eaf619525e 281143: fd2983a5c7809a038d54de2d804a41f773d4bee5 281135: 6d67f85f26a751aeca1d35fbf655545281d6c3bc 281119: 3513602502db81ec214654476b95bfe327574eb6 281087: b89bda3fdbb2f2a06cc8cf9598aab8a1d1415863 v: v3 --- [refs] | 2 +- trunk/drivers/staging/lttng/lib/bug.h | 29 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 trunk/drivers/staging/lttng/lib/bug.h diff --git a/[refs] b/[refs] index 33caeb2274db..bf0fecfd6721 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7430010ec58a189e2ef81d504417299779f47663 +refs/heads/master: a643061cb861ebb18e0292b7510dd9879b598ae0 diff --git a/trunk/drivers/staging/lttng/lib/bug.h b/trunk/drivers/staging/lttng/lib/bug.h new file mode 100644 index 000000000000..8243cc94a7b7 --- /dev/null +++ b/trunk/drivers/staging/lttng/lib/bug.h @@ -0,0 +1,29 @@ +#ifndef _LTTNG_BUG_H +#define _LTTNG_BUG_H + +/* + * lib/bug.h + * + * (C) Copyright 2010-2011 - Mathieu Desnoyers + * + * Dual LGPL v2.1/GPL v2 license. + */ + +/** + * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime + * @condition: the condition which should be false. + * + * If the condition is a constant and true, the compiler will generate a build + * error. If the condition is not constant, a BUG will be triggered at runtime + * if the condition is ever true. If the condition is constant and false, no + * code is emitted. + */ +#define BUILD_RUNTIME_BUG_ON(condition) \ + do { \ + if (__builtin_constant_p(condition)) \ + BUILD_BUG_ON(condition); \ + else \ + BUG_ON(condition); \ + } while (0) + +#endif