Cleanup: move to kernel style SPDX license identifiers
[lttng-modules.git] / lib / bug.h
CommitLineData
9f36eaed
MJ
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
58c78202
MD
3 * lib/bug.h
4 *
886d51a3 5 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
58c78202
MD
6 */
7
9f36eaed
MJ
8#ifndef _LTTNG_BUG_H
9#define _LTTNG_BUG_H
10
20cac830
MJ
11#include <linux/version.h>
12
13#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
14#define LTTNG_BUILD_BUG_ON(cond) BUILD_BUG_ON(cond)
15#else
16#define LTTNG_BUILD_BUG_ON(cond) MAYBE_BUILD_BUG_ON(cond)
17#endif
18
58c78202
MD
19/**
20 * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
21 * @condition: the condition which should be false.
22 *
23 * If the condition is a constant and true, the compiler will generate a build
24 * error. If the condition is not constant, a BUG will be triggered at runtime
25 * if the condition is ever true. If the condition is constant and false, no
26 * code is emitted.
27 */
28#define BUILD_RUNTIME_BUG_ON(condition) \
29 do { \
30 if (__builtin_constant_p(condition)) \
20cac830 31 LTTNG_BUILD_BUG_ON(condition); \
58c78202
MD
32 else \
33 BUG_ON(condition); \
34 } while (0)
35
36#endif
This page took 0.032147 seconds and 4 git commands to generate.