+ _Pragma("clang diagnostic ignored \"-Wcast-align\"") \
+ x; \
+ _Pragma("clang diagnostic pop")
+#endif
+
+#if defined(PRIVATE) || defined(KERNEL)
+/*
+ * Check if __probable and __improbable have already been defined elsewhere.
+ * These macros inform the compiler (and humans) about which branches are likely
+ * to be taken.
+ */
+#if !defined(__probable) && !defined(__improbable)
+#define __probable(x) __builtin_expect(!!(x), 1)
+#define __improbable(x) __builtin_expect(!!(x), 0)
+#endif /* !defined(__probable) && !defined(__improbable) */
+
+#if defined(__cplusplus)
+#define __container_of(ptr, type, field) __extension__({ \
+ const typeof(((type *)nullptr)->field) *__ptr = (ptr); \
+ (type *)((uintptr_t)__ptr - offsetof(type, field)); \
+ })
+#else
+#define __container_of(ptr, type, field) __extension__({ \
+ const typeof(((type *)NULL)->field) *__ptr = (ptr); \
+ (type *)((uintptr_t)__ptr - offsetof(type, field)); \
+ })
+#endif
+
+#endif /* KERNEL || PRIVATE */
+
+#define __compiler_barrier() __asm__ __volatile__("" ::: "memory")
+
+#if __has_attribute(enum_extensibility)
+#define __enum_open __attribute__((__enum_extensibility__(open)))
+#define __enum_closed __attribute__((__enum_extensibility__(closed)))
+#else
+#define __enum_open
+#define __enum_closed
+#endif // __has_attribute(enum_extensibility)
+
+#if __has_attribute(flag_enum)
+#define __enum_options __attribute__((__flag_enum__))
+#else
+#define __enum_options
+#endif
+
+/*
+ * Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS
+ *
+ * This provides more advanced type checking on compilers supporting
+ * the proper extensions, even in C.
+ */
+#if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \
+ __has_extension(cxx_strong_enums)
+#define __enum_decl(_name, _type, ...) \
+ typedef enum : _type __VA_ARGS__ __enum_open _name
+#define __enum_closed_decl(_name, _type, ...) \
+ typedef enum : _type __VA_ARGS__ __enum_closed _name
+#define __options_decl(_name, _type, ...) \
+ typedef enum : _type __VA_ARGS__ __enum_open __enum_options _name
+#define __options_closed_decl(_name, _type, ...) \
+ typedef enum : _type __VA_ARGS__ __enum_closed __enum_options _name
+#else
+#define __enum_decl(_name, _type, ...) \
+ typedef _type _name; enum __VA_ARGS__ __enum_open
+#define __enum_closed_decl(_name, _type, ...) \
+ typedef _type _name; enum __VA_ARGS__ __enum_closed
+#define __options_decl(_name, _type, ...) \
+ typedef _type _name; enum __VA_ARGS__ __enum_open __enum_options
+#define __options_closed_decl(_name, _type, ...) \
+ typedef _type _name; enum __VA_ARGS__ __enum_closed __enum_options