Create Project for repo.or.cz
[vp.git] / src / utils / debug.h
blobf74627c249550d5448b45d73224dc2a26364bed9
1 /*******************************************************************************
2 * File : debug.h
3 *
4 * Author : Henry He
5 * Created : Thu 22 Oct 2009 03:29:31 PM CST
6 * Description :
7 ******************************************************************************/
9 #ifndef __DEBUG_INC_20091022_152931_HENRY__
10 #define __DEBUG_INC_20091022_152931_HENRY__
13 /*******************************************************************************
14 * Desc : Includes Files
15 ******************************************************************************/
16 #include <assert.h>
18 #include "utils/typedef.h"
19 #include "utils/config.h"
20 #include "utils/HLH_Mutex.h"
23 /*******************************************************************************
24 * Desc : Macro Definations
25 ******************************************************************************/
28 //=========================== Assertion ======================================
30 #if (__USE_ASSERT__ != 0)
31 # define ASSERT(cond) \
32 do { \
33 if ( !(cond) ) { \
34 HLH_DEBUG (HLH_DEBUG_MAIN, ("assert [ %s ] failed", #cond)); \
35 while (1); \
36 } \
37 } while (0)
38 #else
39 # define ASSERT(cond)
40 #endif
43 //=========================== Debug ==========================================
46 // 'info' must be surrounded by '()'
48 #if (__USE_HLH_DEBUG__ != 0)
50 # define HLH_DEBUG(flags, info) \
51 do { \
52 if ( (flags) & HLH_DEBUG_FLAGS ) { \
53 Printf ("%s: %s: %d: ", __FILE__, __FUNCTION__, __LINE__); \
54 Printf info; \
55 Printf ("\n"); \
56 } \
57 } while (0)
59 #else
60 # define HLH_DEBUG(flags, info)
61 #endif
63 #if (__TRACE_CALL__ != 0)
65 # define HLH_ENTER_FUNC(flags) \
66 do { \
67 HLH_DEBUG ( flags, ("Enter-----------------------------") ); \
68 } while (0)
70 # define HLH_EXIT_FUNC(flags) \
71 do { \
72 HLH_DEBUG ( flags, ("Exit -----------------------------") ); \
73 } while (0)
75 #else
77 # define HLH_ENTER_FUNC(flags)
78 # define HLH_EXIT_FUNC(flags)
80 #endif
83 /*******************************************************************************
84 * Desc : Type Definations
85 ******************************************************************************/
88 /*******************************************************************************
89 * Desc : Classes
90 ******************************************************************************/
93 /*******************************************************************************
94 * Desc : Extern Variables
95 ******************************************************************************/
96 extern HLH_AutoMutex g_zhmPrintMutex;
99 /*******************************************************************************
100 * Desc : Functions
101 ******************************************************************************/
102 extern int Printf (const char * pcFormat, ...);
106 #endif /* __DEBUG_INC_20091022_152931_HENRY__ */