summaryrefslogtreecommitdiff
path: root/src/smi.h
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-09-22 17:05:21 -0300
committerPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-09-22 17:05:21 -0300
commit6b5c22d8680573c8a6b259d78ba3c8435514fde9 (patch)
treeaf0cfdbbff3e602143957c92e98a113a71de1415 /src/smi.h
parentcf7097c19b31671a53bc8161bd29b9f79f1d3d85 (diff)
Rework/simplify debug macros.
Instead of cut&paste of the name of the current function everywhere, just use cpp's __FUNCTION__ predefined macro. Create two macros to exit a function, named LEAVE() and RETURN(). Functions returning void should call LEAVE() and then explicitly return for now. "Logged" function calls are indented, so a review was done to ensure functions with a ENTER() also have the proper exit macro. The DEBUG macro was changed to have variadic arguments, and this way it is no longer required to prefix arguments with VERBLEV, but now it also is not possible to use another "verbosity value", but it wasn't used in any of the DEBUG macro calls.
Diffstat (limited to 'src/smi.h')
-rw-r--r--src/smi.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/smi.h b/src/smi.h
index 583a0c4..bcc0d2d 100644
--- a/src/smi.h
+++ b/src/smi.h
@@ -65,7 +65,7 @@ authorization from the XFree86 Project and Silicon Motion.
/******************************************************************************/
#ifndef SMI_DEBUG
-# define SMI_DEBUG 0
+#define SMI_DEBUG 0
#endif
#define SMI_USE_IMAGE_WRITES 0
@@ -276,20 +276,25 @@ typedef struct
/******************************************************************************/
#if SMI_DEBUG
-# define VERBLEV 1
-# define ENTER_PROC(PROCNAME) xf86ErrorFVerb(VERBLEV, "ENTER\t" PROCNAME \
- "(%d)\n", __LINE__); xf86Break1()
-# define DEBUG_PROC(PROCNAME) xf86ErrorFVerb(VERBLEV, "DEBUG\t" PROCNAME \
- "(%d)\n", __LINE__); xf86Break2()
-# define LEAVE_PROC(PROCNAME) xf86ErrorFVerb(VERBLEV, "LEAVE\t" PROCNAME \
- "(%d)\n", __LINE__); xf86Break1()
-# define DEBUG(arg) xf86ErrorFVerb arg
+extern int smi_indent;
+# define VERBLEV 1
+# define ENTER() xf86ErrorFVerb(VERBLEV, "%*c %s\n",\
+ smi_indent++, '>', __FUNCTION__)
+# define LEAVE() xf86ErrorFVerb(VERBLEV, "%*c %s\n",\
+ --smi_indent, '<', __FUNCTION__)
+# define RETURN(value) \
+ do { \
+ xf86ErrorFVerb(VERBLEV, "%*c %s\n", \
+ --smi_indent, '<', __FUNCTION__); \
+ return (value); \
+ } while (0)
+# define DEBUG(...) xf86ErrorFVerb(VERBLEV, __VA_ARGS__)
#else
-# define VERBLEV 4
-# define ENTER_PROC(PROCNAME)
-# define DEBUG_PROC(PROCNAME)
-# define LEAVE_PROC(PROCNAME)
-# define DEBUG(arg)
+# define VERBLEV 4
+# define ENTER() /**/
+# define LEAVE() /**/
+# define RETURN(value) return (value)
+# define DEBUG(...) /**/
#endif
/* Some Silicon Motion structs & registers */