.. | .. |
---|
10 | 10 | # define __compiletime_error(message) |
---|
11 | 11 | #endif |
---|
12 | 12 | |
---|
| 13 | +#ifdef __OPTIMIZE__ |
---|
| 14 | +# define __compiletime_assert(condition, msg, prefix, suffix) \ |
---|
| 15 | + do { \ |
---|
| 16 | + extern void prefix ## suffix(void) __compiletime_error(msg); \ |
---|
| 17 | + if (!(condition)) \ |
---|
| 18 | + prefix ## suffix(); \ |
---|
| 19 | + } while (0) |
---|
| 20 | +#else |
---|
| 21 | +# define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0) |
---|
| 22 | +#endif |
---|
| 23 | + |
---|
| 24 | +#define _compiletime_assert(condition, msg, prefix, suffix) \ |
---|
| 25 | + __compiletime_assert(condition, msg, prefix, suffix) |
---|
| 26 | + |
---|
| 27 | +/** |
---|
| 28 | + * compiletime_assert - break build and emit msg if condition is false |
---|
| 29 | + * @condition: a compile-time constant condition to check |
---|
| 30 | + * @msg: a message to emit if condition is false |
---|
| 31 | + * |
---|
| 32 | + * In tradition of POSIX assert, this macro will break the build if the |
---|
| 33 | + * supplied condition is *false*, emitting the supplied error message if the |
---|
| 34 | + * compiler has support to do so. |
---|
| 35 | + */ |
---|
| 36 | +#define compiletime_assert(condition, msg) \ |
---|
| 37 | + _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) |
---|
| 38 | + |
---|
13 | 39 | /* Optimization barrier */ |
---|
14 | 40 | /* The "volatile" is due to gcc bugs */ |
---|
15 | 41 | #define barrier() __asm__ __volatile__("": : :"memory") |
---|
.. | .. |
---|
81 | 107 | #ifndef noinline |
---|
82 | 108 | # define noinline |
---|
83 | 109 | #endif |
---|
84 | | - |
---|
85 | | -#define uninitialized_var(x) x = *(&(x)) |
---|
86 | 110 | |
---|
87 | 111 | #include <linux/types.h> |
---|
88 | 112 | |
---|
.. | .. |
---|
172 | 196 | # define __fallthrough |
---|
173 | 197 | #endif |
---|
174 | 198 | |
---|
| 199 | +/* Indirect macros required for expanded argument pasting, eg. __LINE__. */ |
---|
| 200 | +#define ___PASTE(a, b) a##b |
---|
| 201 | +#define __PASTE(a, b) ___PASTE(a, b) |
---|
| 202 | + |
---|
175 | 203 | #endif /* _TOOLS_LINUX_COMPILER_H */ |
---|