4 /* IWYU pragma: begin_exports */
5 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __clang_major__ >= 6
7 #error Compiler too old, need at least gcc 4.9
9 /* IWYU pragma: end_exports */
11 #define __must_check __attribute__((warn_unused_result))
13 #define __compiletime_warning(message) __attribute__((warning(message)))
14 #define __compiletime_error(message) __attribute__((error(message)))
17 * Mark unused variables passed to ops functions as unused, to silence gcc
19 #define fio_unused __attribute__((__unused__))
20 #define fio_init __attribute__((constructor))
21 #define fio_exit __attribute__((destructor))
23 #define fio_unlikely(x) __builtin_expect(!!(x), 0)
26 * Check at compile time that something is of a particular type.
27 * Always evaluates to 1 so you may use it easily in comparisons.
29 #define typecheck(type,x) \
31 __typeof__(x) __dummy2; \
32 (void)(&__dummy == &__dummy2); \
37 #if defined(CONFIG_STATIC_ASSERT)
38 #define compiletime_assert(condition, msg) _Static_assert(condition, msg)
40 #elif !defined(CONFIG_DISABLE_OPTIMIZATIONS)
42 #ifndef __compiletime_error
43 #define __compiletime_error(message)
46 #ifndef __compiletime_error_fallback
47 #define __compiletime_error_fallback(condition) do { } while (0)
50 #define __compiletime_assert(condition, msg, prefix, suffix) \
52 int __cond = !(condition); \
53 extern void prefix ## suffix(void) __compiletime_error(msg); \
56 __compiletime_error_fallback(__cond); \
59 #define _compiletime_assert(condition, msg, prefix, suffix) \
60 __compiletime_assert(condition, msg, prefix, suffix)
62 #define compiletime_assert(condition, msg) \
63 _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
67 #define compiletime_assert(condition, msg) do { } while (0)
72 #define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
73 #define FIELD_SIZE(s, f) (sizeof(((__typeof__(s))0)->f))