4 /* IWYU pragma: begin_exports */
6 #include "compiler-gcc4.h"
8 #include "compiler-gcc3.h"
10 #error Compiler too old, need gcc at least gcc 3.x
12 /* IWYU pragma: end_exports */
19 * Mark unused variables passed to ops functions as unused, to silence gcc
21 #define fio_unused __attribute__((__unused__))
22 #define fio_init __attribute__((constructor))
23 #define fio_exit __attribute__((destructor))
25 #define fio_unlikely(x) __builtin_expect(!!(x), 0)
28 * Check at compile time that something is of a particular type.
29 * Always evaluates to 1 so you may use it easily in comparisons.
31 #define typecheck(type,x) \
34 (void)(&__dummy == &__dummy2); \
39 #if defined(CONFIG_STATIC_ASSERT)
40 #define compiletime_assert(condition, msg) _Static_assert(condition, msg)
42 #elif !defined(CONFIG_DISABLE_OPTIMIZATIONS)
44 #ifndef __compiletime_error
45 #define __compiletime_error(message)
48 #ifndef __compiletime_error_fallback
49 #define __compiletime_error_fallback(condition) do { } while (0)
52 #define __compiletime_assert(condition, msg, prefix, suffix) \
54 int __cond = !(condition); \
55 extern void prefix ## suffix(void) __compiletime_error(msg); \
58 __compiletime_error_fallback(__cond); \
61 #define _compiletime_assert(condition, msg, prefix, suffix) \
62 __compiletime_assert(condition, msg, prefix, suffix)
64 #define compiletime_assert(condition, msg) \
65 _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
69 #define compiletime_assert(condition, msg) do { } while (0)
74 #define ARRAY_SIZE(x) (sizeof((x)) / (sizeof((x)[0])))
75 #define FIELD_SIZE(s, f) (sizeof(((typeof(s))0)->f))