+#define __token_glue(a,b,c) ___token_glue(a,b,c)
+#define ___token_glue(a,b,c) a ## b ## c
+#ifdef DEBUG_BUILD_CHECKS
+#define BUILD_ASSERT(x) extern int __token_glue(compile_time_assert_,__LINE__,__COUNTER__)[1-2*!(x)] __attribute__((unused))
+#else
+#define BUILD_ASSERT(x)
+#endif
+
+#ifndef BTRFS_DISABLE_BACKTRACE
+#define MAX_BACKTRACE 16
+static inline void print_trace(void)
+{
+ void *array[MAX_BACKTRACE];
+ int size;
+
+ size = backtrace(array, MAX_BACKTRACE);
+ backtrace_symbols_fd(array, size, 2);
+}
+#endif
+
+static inline void warning_trace(const char *assertion, const char *filename,
+ const char *func, unsigned line, long val)
+{
+ if (!val)
+ return;
+ fprintf(stderr,
+ "%s:%d: %s: Warning: assertion `%s` failed, value %ld\n",
+ filename, line, func, assertion, val);
+#ifndef BTRFS_DISABLE_BACKTRACE
+ print_trace();
+#endif
+}
+
+static inline void bugon_trace(const char *assertion, const char *filename,
+ const char *func, unsigned line, long val)
+{
+ if (!val)
+ return;
+ fprintf(stderr,
+ "%s:%d: %s: BUG_ON `%s` triggered, value %ld\n",
+ filename, line, func, assertion, val);
+#ifndef BTRFS_DISABLE_BACKTRACE
+ print_trace();
+#endif
+ abort();
+ exit(1);
+}
+