summaryrefslogtreecommitdiff
path: root/kerncompat.h
diff options
context:
space:
mode:
authorGustavo Zacarias <gustavo@zacarias.com.ar>2014-10-07 11:09:04 -0300
committerDavid Sterba <dsterba@suse.cz>2014-10-10 10:38:38 +0200
commit05499d865f061c258ef2a15b1ad5b650c991371a (patch)
tree0497561ebc867ee9d022b30a5748ddc72094a3e2 /kerncompat.h
parentcb37bf83cc583dfe1e22344049a649b363228509 (diff)
downloadbtrfs-progs-05499d865f061c258ef2a15b1ad5b650c991371a.tar.gz
btrfs-progs: add option to disable backtrace usage
This commit adds the support for a make variable named "DISABLE_BACKTRACE" which allows to disable the support for backtrace() usage on ASSERT(), BUG() and BUG_ON() calls. This is useful because some alternative C libraries like uClibc have optional support for backtrace() which is rarely built when debugging isn't taking place. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'kerncompat.h')
-rw-r--r--kerncompat.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/kerncompat.h b/kerncompat.h
index 19c7fa5..889d94c 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -29,7 +29,9 @@
#include <stddef.h>
#include <linux/types.h>
#include <stdint.h>
+#ifndef BTRFS_DISABLE_BACKTRACE
#include <execinfo.h>
+#endif
#define ptr_to_u64(x) ((u64)(uintptr_t)x)
#define u64_to_ptr(x) ((void *)(uintptr_t)x)
@@ -55,6 +57,7 @@
#define ULONG_MAX (~0UL)
#endif
+#ifndef BTRFS_DISABLE_BACKTRACE
#define MAX_BACKTRACE 16
static inline void print_trace(void)
{
@@ -81,6 +84,9 @@ static inline void assert_trace(const char *assertion, const char *filename,
}
#define BUG() assert_trace(NULL, __FILE__, __func__, __LINE__, 0)
+#else
+#define BUG() assert(0)
+#endif
#ifdef __CHECKER__
#define __force __attribute__((force))
@@ -264,10 +270,19 @@ static inline long IS_ERR(const void *ptr)
#define kstrdup(x, y) strdup(x)
#define kfree(x) free(x)
+#ifndef BTRFS_DISABLE_BACKTRACE
#define BUG_ON(c) assert_trace(#c, __FILE__, __func__, __LINE__, !(c))
+#else
+#define BUG_ON(c) assert(!(c))
+#endif
#define WARN_ON(c) BUG_ON(c)
+
+#ifndef BTRFS_DISABLE_BACKTRACE
#define ASSERT(c) assert_trace(#c, __FILE__, __func__, __LINE__, (c))
+#else
+#define ASSERT(c) assert(c)
+#endif
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \