+
+/* Declaring inline functions within headers is error-prone due to differences
+ * across various versions of the C language and extensions. __header_inline
+ * can be used to declare inline functions within system headers. In cases
+ * where you want to force inlining instead of letting the compiler make
+ * the decision, you can use __header_always_inline.
+ *
+ * Be aware that using inline for functions which compilers may also provide
+ * builtins can behave differently under various compilers. If you intend to
+ * provide an inline version of such a function, you may want to use a macro
+ * instead.
+ *
+ * The check for !__GNUC__ || __clang__ is because gcc doesn't correctly
+ * support c99 inline in some cases:
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965
+ */
+
+#if defined(__cplusplus) || \
+ (__STDC_VERSION__ >= 199901L && \
+ !defined(__GNUC_GNU_INLINE__) && \
+ (!defined(__GNUC__) || defined(__clang__)))
+# define __header_inline inline
+#elif defined(__GNUC__) && defined(__GNUC_STDC_INLINE__)
+# define __header_inline extern __inline __attribute__((__gnu_inline__))
+#elif defined(__GNUC__)
+# define __header_inline extern __inline
+#else
+ /* If we land here, we've encountered an unsupported compiler,
+ * so hopefully it understands static __inline as a fallback.
+ */
+# define __header_inline static __inline
+#endif
+
+#ifdef __GNUC__
+# define __header_always_inline __header_inline __attribute__ ((__always_inline__))
+#else
+ /* Unfortunately, we're using a compiler that we don't know how to force to
+ * inline. Oh well.
+ */
+# define __header_always_inline __header_inline
+#endif
+
+/*
+ * Compiler-dependent macros that bracket portions of code where the
+ * "-Wunreachable-code" warning should be ignored. Please use sparingly.
+ */
+#if defined(__clang__)
+# define __unreachable_ok_push \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wunreachable-code\"")
+# define __unreachable_ok_pop \
+ _Pragma("clang diagnostic pop")
+#elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
+# define __unreachable_ok_push \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wunreachable-code\"")
+# define __unreachable_ok_pop \
+ _Pragma("GCC diagnostic pop")
+#else
+# define __unreachable_ok_push
+# define __unreachable_ok_pop