Add ph_blk_offset during every blockdev bread/bwrite
[lwext4.git] / lwext4 / ext4_debug.h
index f37f6d14b3dcaa789c3c35e4f610a69f692e4b41..4c69a4e3e83c15270ed63489c2f47e2a4916909f 100644 (file)
 #ifndef EXT4_DEBUG_H_
 #define EXT4_DEBUG_H_
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "ext4_config.h"
 #include "ext4_errno.h"
 
 
 #include <stdint.h>
 #include <stdio.h>
+#include <inttypes.h>
+
+#ifndef PRIu64
+#define PRIu64 "llu"
+#endif
+
+#ifndef PRId64
+#define PRId64 "lld"
+#endif
+
 
-#define DEBUG_BALLOC (1 << 0)
-#define DEBUG_BCACHE (1 << 1)
-#define DEBUG_BITMAP (1 << 2)
-#define DEBUG_BLOCK_GROUP (1 << 3)
-#define DEBUG_BLOCKDEV (1 << 4)
-#define DEBUG_DIR_IDX (1 << 5)
-#define DEBUG_DIR (1 << 6)
-#define DEBUG_EXTENT (1 << 7)
-#define DEBUG_FS (1 << 8)
-#define DEBUG_HASH (1 << 9)
-#define DEBUG_IALLOC (1 << 10)
-#define DEBUG_INODE (1 << 11)
-#define DEBUG_SUPER (1 << 12)
-#define DEBUG_XATTR (1 << 13)
-#define DEBUG_MKFS (1 << 14)
-#define DEBUG_EXT4 (1 << 15)
+#define DEBUG_BALLOC (1ul << 0)
+#define DEBUG_BCACHE (1ul << 1)
+#define DEBUG_BITMAP (1ul << 2)
+#define DEBUG_BLOCK_GROUP (1ul << 3)
+#define DEBUG_BLOCKDEV (1ul << 4)
+#define DEBUG_DIR_IDX (1ul << 5)
+#define DEBUG_DIR (1ul << 6)
+#define DEBUG_EXTENT (1ul << 7)
+#define DEBUG_FS (1ul << 8)
+#define DEBUG_HASH (1ul << 9)
+#define DEBUG_IALLOC (1ul << 10)
+#define DEBUG_INODE (1ul << 11)
+#define DEBUG_SUPER (1ul << 12)
+#define DEBUG_XATTR (1ul << 13)
+#define DEBUG_MKFS (1ul << 14)
+#define DEBUG_EXT4 (1ul << 15)
+#define DEBUG_JBD (1ul << 16)
 
 #define DEBUG_ALL (0xFFFFFFFF)
 
@@ -99,6 +114,8 @@ static inline const char *ext4_dmask_id2str(uint32_t m)
                return "ext4_xattr: ";
        case DEBUG_MKFS:
                return "ext4_mkfs: ";
+       case DEBUG_JBD:
+               return "ext4_jbd: ";
        case DEBUG_EXT4:
                return "ext4: ";
        }
@@ -126,10 +143,13 @@ uint32_t ext4_dmask_get(void);
 #define ext4_dbg(m, ...)                                                       \
        do {                                                                   \
                if (m & ext4_dmask_get()) {                                    \
-                       printf(ext4_dmask_id2str(m));                          \
-                       printf(__VA_ARGS__);                                   \
+                       if (CONFIG_DEBUG_PREFIX) {                             \
+                               printf("%s", ext4_dmask_id2str(m));            \
+                               printf("l: %d   ", __LINE__);                  \
+                       }                                                      \
+                       printf(__VA_ARGS__);                                   \
                        fflush(stdout);                                        \
-               }                                                              \
+               }                                                              \
        } while (0)
 #else
 #define ext4_dbg(m, ...) do { } while (0)
@@ -137,23 +157,27 @@ uint32_t ext4_dmask_get(void);
 
 #if CONFIG_DEBUG_ASSERT
 /**@brief   Debug assertion.*/
- #if CONFIG_HAVE_OWN_ASSERT
- #define ext4_assert(_v)                                                       \
-       do {                                                                   \
-               if (!(_v)) {                                                   \
-                       printf("assertion failed:\nfile: %s\nline: %d\n",      \
-                              __FILE__, __LINE__);                            \
-                              while (1)                                       \
-                                      ;                                       \
-               }                                                              \
-       } while (0)
- #else
- #define ext4_assert(_v) assert(_v)
- #endif
+#if CONFIG_HAVE_OWN_ASSERT
+#define ext4_assert(_v)                                                        \
+       do {                                                                   \
+               if (!(_v)) {                                                   \
+                       printf("assertion failed:\nfile: %s\nline: %d\n",      \
+                              __FILE__, __LINE__);                            \
+                              while (1)                                       \
+                                      ;                                       \
+               }                                                              \
+       } while (0)
+#else
+#define ext4_assert(_v) assert(_v)
+#endif
 #else
 #define ext4_assert(_v)
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* EXT4_DEBUG_H_ */
 
 /**