becopyopt: Fix typos in comments.
[libfirm] / ir / common / debug.h
index b63a261..9c9388b 100644 (file)
@@ -1,30 +1,40 @@
+/*
+ * This file is part of libFirm.
+ * Copyright (C) 2012 University of Karlsruhe.
+ */
+
 /**
- * Debug facility.
- * @author Michael Beck, Sebastian Hack
- * @date 15.12.2004
+ * @file
+ * @brief   Debug facility.
+ * @author  Michael Beck, Sebastian Hack
+ * @date    15.12.2004
  */
+#ifndef FIRM_COMMON_DEBUG_H
+#define FIRM_COMMON_DEBUG_H
 
-#ifndef _FIRM_DEBUG_H
-#define _FIRM_DEBUG_H
+/* WITH DEBUG OUTPUT */
+#ifdef DEBUG_libfirm
 
 #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_0 = 0,   /**< use with firm_dbg_set_mask(). */
+       SET_LEVEL_1 = 1,
        SET_LEVEL_2 = 3,
        SET_LEVEL_3 = 7,
        SET_LEVEL_4 = 15,
-       SET_LEVEL_5 = 31
+       SET_LEVEL_5 = 31,
+       SET_LEVEL_ALL = SET_LEVEL_5
 };
 
-typedef struct _firm_dbg_module_t firm_dbg_module_t;
+typedef struct firm_dbg_module_t firm_dbg_module_t;
 
 /* Internal function to the debug module. */
 void *_firm_dbg_make_msg(const firm_dbg_module_t *mod, unsigned mask, const char *fmt, ...);
@@ -32,6 +42,9 @@ void *_firm_dbg_make_msg(const firm_dbg_module_t *mod, unsigned mask, const char
 /* Internal function to the debug module. */
 void _firm_dbg_print_msg(const char *filename, int line, const char *func, void *data);
 
+/* Internal function to the debug module. */
+void _firm_dbg_print(const firm_dbg_module_t *mod, unsigned mask, const char *fmt, ...);
+
 /**
  * Register a module to the firm debug facility.
  * If the module has already been registered, no new module is allocated
@@ -64,31 +77,18 @@ 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)
+  _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)     _DBG_MAIN(__func__, args)
-#else
-
-/* Else, check for gcc and use the proprietary __FUNCTION__ macro. */
-#ifdef __GNUC__
-#define _DBG(args)     _DBG_MAIN(__FUNCTION__, args)
-#else
-
-/* Else go without the name of the calling function. */
-#define _DBG(args)     _DBG_MAIN("", args)
-#endif
-#endif
+#define _DBG(args)  _DBG_MAIN(__func__, args)
+#define _DB(args) _firm_dbg_print args
 
 /**
  * Debug messages issued with this macro are always printed, even in
  * retail versions.
  * @see DBG()
  */
-#define DBG_RETAIL(args)               _DBG(args)
-
-#ifdef DEBUG_libfirm
+#define DBG_RETAIL(args)    _DBG(args)
+#define DB_RETAIL(args)     _DB(args)
 
 /**
  * Issue a debug message.
@@ -113,11 +113,30 @@ void firm_dbg_set_file(firm_dbg_module_t *module, FILE *file);
  * DBG((my_mod, LEVEL_DEFAULT, "entity %e has type %t", ent, type))
  * @endcode
  */
-#define DBG(args)                                      _DBG(args)
+#define DBG(args)           _DBG(args)
+#define DB(args)            _DB(args)
 
-#else
-#define DBG(args)
-#endif
+/** create a debug handle in debug mode */
+#define FIRM_DBG_REGISTER(handle, name) handle = firm_dbg_register(name)
+#define DEBUG_ONLY(code)   code
+#define RELEASE_ONLY(code)
+
+#else /* ndef DEBUG_libfirm */
+
+/* DEBUG OUTPUT IS COMPLETELY DISABLED */
+
+#define DBG(x)   (void)0
+#define DB(x)    (void)0
+
+/** create a debug handle in release mode */
+#define FIRM_DBG_REGISTER(handle, name)  (void)0
+#define DEBUG_ONLY(code)
+#define RELEASE_ONLY(code) code
+
+#define firm_dbg_set_mask(module, mask)  (void)0
+#define firm_dbg_get_mask(module)        (void)0
+#define firm_dbg_set_file(module, file)  (void)0
 
+#endif /* DEBUG_libfirm */
 
 #endif