+# define _format_attribute(type, format_str, format_start) \
+ __attribute__((format(type, format_str, format_start)))
+#endif
+
+/* Hint that the annotated function is intentionally not used. This might be
+ * the case if the function contains only static assertions. */
+#define _unused_attribute __attribute__((unused))
+
+/* Endianness definitions. Either CPU_IS_BIG_ENDIAN() or CPU_IS_LITTLE_ENDIAN()
+ * evaluates to 1. The other evaluates to 0. Note that newer gcc supports
+ * __BYTE_ORDER__ for easily determining the endianness; older gcc doesn't. In
+ * the latter case we fall back to a configure-time check. */
+#ifdef __BYTE_ORDER__
+# define CPU_IS_BIG_ENDIAN() (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#elif defined(HAVE_CONFIG_H)
+# include "config.h"
+# ifdef WORDS_BIGENDIAN
+# define CPU_IS_BIG_ENDIAN() 1
+# else
+# define CPU_IS_BIG_ENDIAN() 0
+# endif
+#endif
+#define CPU_IS_LITTLE_ENDIAN() (!CPU_IS_BIG_ENDIAN())
+
+/* UNALIGNED_ACCESS_IS_FAST should be defined to 1 if unaligned memory accesses
+ * can be performed efficiently on the target platform. */
+#if defined(__x86_64__) || defined(__i386__) || \
+ defined(__ARM_FEATURE_UNALIGNED) || defined(__powerpc64__)
+# define UNALIGNED_ACCESS_IS_FAST 1
+#else
+# define UNALIGNED_ACCESS_IS_FAST 0
+#endif
+
+/* Get the minimum of two variables, without multiple evaluation. */
+#undef min
+#define min(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \
+ (_a < _b) ? _a : _b; })
+#undef MIN
+#define MIN(a, b) min((a), (b))
+
+/* Get the maximum of two variables, without multiple evaluation. */
+#undef max
+#define max(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \
+ (_a > _b) ? _a : _b; })
+#undef MAX
+#define MAX(a, b) max((a), (b))
+
+/* Swap the values of two variables, without multiple evaluation. */
+#ifndef swap
+# define swap(a, b) ({ typeof(a) _a = (a); (a) = (b); (b) = _a; })
+#endif
+#define SWAP(a, b) swap((a), (b))
+
+/* Optional definitions for checking with 'sparse'. */
+#ifdef __CHECKER__
+# define _bitwise_attr __attribute__((bitwise))
+# define _force_attr __attribute__((force))
+#else
+# define _bitwise_attr
+# define _force_attr
+#endif
+
+/* STATIC_ASSERT() - verify the truth of an expression at compilation time. */
+#ifdef __CHECKER__
+# define STATIC_ASSERT(expr)
+#elif __STDC_VERSION__ >= 201112L
+# define STATIC_ASSERT(expr) _Static_assert((expr), "")
+#else
+# define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)]))
+#endif
+
+/* STATIC_ASSERT_ZERO() - verify the truth of an expression at compilation time
+ * and also produce a result of value '0' to be used in constant expressions */
+#define STATIC_ASSERT_ZERO(expr) ((int)sizeof(char[-!(expr)]))
+
+#define CONCAT_IMPL(s1, s2) s1##s2
+
+/* CONCAT() - concatenate two tokens at preprocessing time. */
+#define CONCAT(s1, s2) CONCAT_IMPL(s1, s2)