4 #define __must_check __attribute__((warn_unused_result))
6 #define __compiletime_warning(message) __attribute__((warning(message)))
7 #define __compiletime_error(message) __attribute__((error(message)))
10 * Mark unused variables passed to ops functions as unused, to silence gcc
12 #define fio_unused __attribute__((__unused__))
13 #define fio_init __attribute__((constructor))
14 #define fio_exit __attribute__((destructor))
16 #define fio_unlikely(x) __builtin_expect(!!(x), 0)
19 * Check at compile time that something is of a particular type.
20 * Always evaluates to 1 so you may use it easily in comparisons.
22 #define typecheck(type,x) \
24 __typeof__(x) __dummy2; \
25 (void)(&__dummy == &__dummy2); \
30 #if defined(CONFIG_STATIC_ASSERT)
31 #define compiletime_assert(condition, msg) _Static_assert(condition, msg)
33 #elif !defined(CONFIG_DISABLE_OPTIMIZATIONS)
35 #ifndef __compiletime_error
36 #define __compiletime_error(message)
39 #ifndef __compiletime_error_fallback
40 #define __compiletime_error_fallback(condition) do { } while (0)
43 #define __compiletime_assert(condition, msg, prefix, suffix) \
45 int __cond = !(condition); \
46 extern void prefix ## suffix(void) __compiletime_error(msg); \
49 __compiletime_error_fallback(__cond); \
52 #define _compiletime_assert(condition, msg, prefix, suffix) \
53 __compiletime_assert(condition, msg, prefix, suffix)
55 #define compiletime_assert(condition, msg) \
56 _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
60 #define compiletime_assert(condition, msg) do { } while (0)
65 #define FIO_ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
66 #define FIO_FIELD_SIZE(s, f) (sizeof(((__typeof__(s))0)->f))
69 #ifndef __has_attribute
70 #define __GCC4_has_attribute___fallthrough__ 0
73 #if __has_attribute(__fallthrough__)
74 #define fallthrough __attribute__((__fallthrough__))
76 #define fallthrough do {} while (0) /* fallthrough */