diff options
| author | H. Peter Anvin <hpa@linux.intel.com> | 2013-04-20 09:16:44 -0700 |
|---|---|---|
| committer | H. Peter Anvin <hpa@linux.intel.com> | 2013-04-20 09:16:44 -0700 |
| commit | f53f292eeaa234615c31a1306babe703fc4263f2 (patch) | |
| tree | 707b0933a20f7dc05495e974243a23b5c9f8c918 /include/linux/compiler.h | |
| parent | 15b9c359f288b09003cb70f7ed204affc0c6614d (diff) | |
| parent | a9499fa7cd3fd4824a7202d00c766b269fa3bda6 (diff) | |
Merge remote-tracking branch 'efi/chainsaw' into x86/efi
Resolved Conflicts:
drivers/firmware/efivars.c
fs/efivarsfs/file.c
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'include/linux/compiler.h')
| -rw-r--r-- | include/linux/compiler.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index dd852b73b286..10b8f23fab0f 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -307,10 +307,36 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect); #endif #ifndef __compiletime_error # define __compiletime_error(message) +# define __compiletime_error_fallback(condition) \ + do { ((void)sizeof(char[1 - 2 * condition])); } while (0) +#else +# define __compiletime_error_fallback(condition) do { } while (0) #endif -#ifndef __linktime_error -# define __linktime_error(message) -#endif + +#define __compiletime_assert(condition, msg, prefix, suffix) \ + do { \ + bool __cond = !(condition); \ + extern void prefix ## suffix(void) __compiletime_error(msg); \ + if (__cond) \ + prefix ## suffix(); \ + __compiletime_error_fallback(__cond); \ + } while (0) + +#define _compiletime_assert(condition, msg, prefix, suffix) \ + __compiletime_assert(condition, msg, prefix, suffix) + +/** + * compiletime_assert - break build and emit msg if condition is false + * @condition: a compile-time constant condition to check + * @msg: a message to emit if condition is false + * + * In tradition of POSIX assert, this macro will break the build if the + * supplied condition is *false*, emitting the supplied error message if the + * compiler has support to do so. + */ +#define compiletime_assert(condition, msg) \ + _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) + /* * Prevent the compiler from merging or refetching accesses. The compiler * is also forbidden from reordering successive instances of ACCESS_ONCE(), |
