170,6 → 170,11 |
(typeof(ptr)) (__ptr + (off)); }) |
#endif |
|
/* Not-quite-unique ID. */ |
#ifndef __UNIQUE_ID |
# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) |
#endif |
|
#endif /* __KERNEL__ */ |
|
#endif /* __ASSEMBLY__ */ |
302,10 → 307,36 |
#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(), |