use tv_t.h instead of tv.h
[libfirm] / ir / common / debug.h
index 2f0c53a..a3e2a8f 100644 (file)
@@ -7,17 +7,35 @@
 #ifndef _FIRM_DEBUG_H
 #define _FIRM_DEBUG_H
 
+#include "firm_config.h"
+
+#ifdef WITH_LIBCORE
+
+#include <libcore/debug.h>
+
+/* use the newer debug implementation in libcore */
+typedef dbg_module_t firm_dbg_module_t;
+
+extern firm_dbg_module_t *firm_dbg_register(const char *name);
+
+#define firm_dbg_set_mask(module, mask) dbg_set_mask(module, mask)
+#define firm_dbg_get_mask(module)       dbg_get_mask(module)
+#define firm_dbg_set_file(module, file) dbg_set_file(module, file)
+
+#else
+/* use the builtin debug implementation */
+
 #include <stdio.h>
 
 enum firm_dbg_level_t {
-       LEVEL_DEFAULT = 0,              /**< Prints always. Use with DBG(). */
+       LEVEL_DEFAULT = 0, /**< Prints always. Use with DBG(). */
        LEVEL_1 = 1,
        LEVEL_2 = 2,
        LEVEL_3 = 4,
        LEVEL_4 = 8,
        LEVEL_5 = 16,
 
-       SET_LEVEL_1 = 1,                        /**< use with firm_dbg_set_mask(). */
+       SET_LEVEL_1 = 1,   /**< use with firm_dbg_set_mask(). */
        SET_LEVEL_2 = 3,
        SET_LEVEL_3 = 7,
        SET_LEVEL_4 = 15,
@@ -63,19 +81,21 @@ unsigned firm_dbg_get_mask(const firm_dbg_module_t *module);
  */
 void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file);
 
+#define _DBG_MAIN(func,args) \
+       _firm_dbg_print_msg(__FILE__, __LINE__, func, _firm_dbg_make_msg args)
 
 /* If we have C99 use the __func__ variable for calling functions name. */
 #if defined(__STD_VERSION__) && __STD_VERSION >= 199901L
-#define _DBG(args) _firm_dbg_print_msg(__FILE__, __LINE__, __func__, _firm_dbg_make_msg args)
+#define _DBG(args)     _DBG_MAIN(__func__, args)
 #else
 
 /* Else, check for gcc and use the proprietary __FUNCTION__ macro. */
 #ifdef __GNUC__
-#define _DBG(args) _firm_dbg_print_msg(__FILE__, __LINE__, __FUNCTION__, _firm_dbg_make_msg args)
+#define _DBG(args)     _DBG_MAIN(__FUNCTION__, args)
 #else
 
 /* Else go without the name of the calling function. */
-#define _DBG(args) _firm_dbg_print_msg(__FILE__, __LINE__, "", _firm_dbg_make_msg args)
+#define _DBG(args)     _DBG_MAIN("", args)
 #endif
 #endif
 
@@ -86,7 +106,7 @@ void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file);
  */
 #define DBG_RETAIL(args)               _DBG(args)
 
-#ifdef DEBUG
+#ifdef DEBUG_libfirm
 
 /**
  * Issue a debug message.
@@ -117,5 +137,6 @@ void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file);
 #define DBG(args)
 #endif
 
+#endif /* WITH_LIBCORE */
 
-#endif
+#endif /* _FIRM_DEBUG_H */