00001
00007 #ifndef _TXC_DEBUG_H
00008 #define _TXC_DEBUG_H
00009
00010 #include <stdio.h>
00011 #include <assert.h>
00012
00013
00014 #define TXC_DEBUG_POOL txc_runtime_settings.debug_pool
00015 #define TXC_DEBUG_KOA txc_runtime_settings.debug_koa
00016 #define TXC_DEBUG_SENTINEL txc_runtime_settings.debug_sentinel
00017 #define TXC_DEBUG_TX txc_runtime_settings.debug_tx
00018 #define TXC_DEBUG_XCALL txc_runtime_settings.debug_xcall
00019
00020 #define TXC_DEBUG_OUT stderr
00021
00022
00023
00024 #define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
00025 #define timevaladd(vvp, uvp) \
00026 do { \
00027 (vvp)->tv_sec += (uvp)->tv_sec; \
00028 (vvp)->tv_usec += (uvp)->tv_usec; \
00029 if ((vvp)->tv_usec >= 1000000) { \
00030 (vvp)->tv_sec++; \
00031 (vvp)->tv_usec -= 1000000; \
00032 } \
00033 } while (0)
00034
00035 #define timevalsub(vvp, uvp) \
00036 do { \
00037 (vvp)->tv_sec -= (uvp)->tv_sec; \
00038 (vvp)->tv_usec -= (uvp)->tv_usec; \
00039 if ((vvp)->tv_usec < 0) { \
00040 (vvp)->tv_sec--; \
00041 (vvp)->tv_usec += 1000000; \
00042 } \
00043 } while (0)
00044
00045
00046 #define TXC_INTERNALERROR(msg, ...) \
00047 txc_debug_printmsg(__FILE__, __LINE__, 1, "Internal Error: ", \
00048 msg, ##__VA_ARGS__ )
00049
00050 #define TXC_ERROR(msg, ...) \
00051 txc_debug_printmsg(NULL, 0, 1, "Error", msg, ##__VA_ARGS__ )
00052
00053
00054 #ifdef _TXC_DEBUG_BUILD
00055
00056 # define TXC_WARNING(msg, ...) \
00057 txc_debug_printmsg(NULL, 0, 0, "Warning", msg, ##__VA_ARGS__ )
00058
00059
00060 # define TXC_DEBUG_PRINT(debug_level, msg, ...) \
00061 txc_debug_printmsg_L(debug_level, msg, ##__VA_ARGS__ )
00062
00063 # define TXC_ASSERT(condition) assert(condition)
00064
00065 #else
00066
00067 # define TXC_WARNING(msg, ...) ((void) 0)
00068 # define TXC_DEBUG_PRINT(debug_level, msg, ...) ((void) 0)
00069 # define TXC_ASSERT(condition) ((void) 0)
00070
00071 #endif
00072
00073
00074
00075
00076 void txc_debug_printmsg(char *file, int line, int fatal, const char *prefix, const char *strformat, ...);
00077 void txc_debug_printmsg_L(int debug_level, const char *strformat, ...);
00078
00079 #endif