Skip to content
Snippets Groups Projects
Commit b9117423 authored by edgrif's avatar edgrif
Browse files

simplify file, function, line macro stuff + add some timer macros.

parent 25e4f99a
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,9 @@
* Description: Contains macros, functions etc. useful for testing/debugging.
*
* HISTORY:
* Last edited: Apr 8 17:05 2004 (edgrif)
* Last edited: Nov 7 16:47 2006 (edgrif)
* Created: Mon Mar 29 16:51:28 2004 (edgrif)
* CVS info: $Id: zmapUtilsDebug.h,v 1.1 2004-04-08 16:14:53 edgrif Exp $
* CVS info: $Id: zmapUtilsDebug.h,v 1.2 2006-11-07 17:00:32 edgrif Exp $
*-------------------------------------------------------------------
*/
#ifndef ZMAP_UTILS_DEBUG_H
......@@ -57,26 +57,53 @@ g_assert_not_reached()
extern gboolean zmap_debug_G ;
#ifdef HOME
/* Stupid home system needs updating.... */
#define zMapDebug(FORMAT, ...)
#else
/* Takes the standard printf like args: ZMAP_DEBUG("format string", lots, of, args) ; */
#define zMapDebug(FORMAT, ...) \
G_STMT_START{ \
if (zmap_debug_G) \
g_printerr(ZMAP_MSG_FORMAT_STRING FORMAT, \
__FILE__, \
ZMAP_MSG_FUNCTION_MACRO \
__LINE__, \
ZMAP_MSG_FUNCTION_MACRO, \
__VA_ARGS__) ; \
}G_STMT_END
#endif /*HOME*/
/* Timer functions, just simplifies printing etc a bit and provides a global timer if required.
* Just comment out #define ZMAP_DISABLE_TIMER to make it all work.
*/
/* #define ZMAP_DISABLE_TIMER */
#ifdef ZMAP_DISABLE_TIMER
#define zMapStartTimer(TIMER_PTR) (void)0
#define zMapPrintTimer(TIMER, TEXT) (void)0
#else
#define ZMAP_GLOBAL_TIMER zmap_global_timer_G
extern GTimer *ZMAP_GLOBAL_TIMER ;
/* A bit clumsy but couln't see a neat way to allow just putting NULL for the timer to get
* the global one.
* Do this for the global one: zMapStartTimer(ZMAP_GLOBAL_TIMER) ;
* and this for your one: zMapStartTimer(your_timer_ptr) ;
* */
#define zMapStartTimer(TIMER_PTR) \
(TIMER_PTR) = g_timer_new()
/* Takes an optional Gtimer* and an optional char* (you must supply the arg but it can NULL */
#define zMapPrintTimer(TIMER, TEXT) \
printf(ZMAP_MSG_FORMAT_STRING " %s - elapsed time: %g\n", \
ZMAP_MSG_FUNCTION_MACRO, \
(TEXT), \
g_timer_elapsed(((TIMER) ? (TIMER) : ZMAP_GLOBAL_TIMER), NULL)) ;
#endif /* ZMAP_DISABLE_TIMER */
#endif /* ZMAP_UTILS_DEBUG_H */
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment