|
@@ -26,21 +26,33 @@
|
|
|
#define _DMMLIB_TRACE_H_
|
|
|
#include <dmmlib/config.h>
|
|
|
|
|
|
+#ifdef PARSE_ENV
|
|
|
+#include "dmmlib/dmmlib.h" /* to check if systemallocator is initialized */
|
|
|
+#endif /* PARSE_ENV */
|
|
|
+
|
|
|
#ifdef WITH_MEM_TRACE
|
|
|
#include <stdio.h>
|
|
|
|
|
|
#ifndef PARSE_ENV
|
|
|
/** Memory trace file descriptor */
|
|
|
#define MEM_FD stderr
|
|
|
+
|
|
|
+/** Function for memory trace messages */
|
|
|
+#define MEM_TRACE(...) fprintf(MEM_FD, __VA_ARGS__)
|
|
|
+
|
|
|
#else /* PARSE_ENV */
|
|
|
/** Memory trace file descriptor macro */
|
|
|
#define MEM_FD mem_fd
|
|
|
/** Memory trace file descriptor */
|
|
|
FILE* mem_fd;
|
|
|
-#endif /* PARSE_ENV */
|
|
|
|
|
|
/** Function for memory trace messages */
|
|
|
-#define MEM_TRACE(...) fprintf(MEM_FD, __VA_ARGS__)
|
|
|
+#define MEM_TRACE(...) \
|
|
|
+ if(__builtin_expect (systemallocator.initialized, true)) { \
|
|
|
+ fprintf(MEM_FD, __VA_ARGS__); \
|
|
|
+ }
|
|
|
+
|
|
|
+#endif /* PARSE_ENV */
|
|
|
|
|
|
#else /* WITH_MEM_TRACE */
|
|
|
|
|
@@ -55,15 +67,23 @@ FILE* mem_fd;
|
|
|
#ifndef PARSE_ENV
|
|
|
/** Statistics file descriptor */
|
|
|
#define STATS_FD stderr
|
|
|
+
|
|
|
+/** Function for statistics trace messages */
|
|
|
+#define STATS_TRACE(...) fprintf(STATS_FD, __VA_ARGS__)
|
|
|
+
|
|
|
#else /* PARSE_ENV */
|
|
|
/** Statistics file descriptor macro */
|
|
|
#define STATS_FD stats_fd
|
|
|
/** Statistics file descriptor */
|
|
|
FILE* stats_fd;
|
|
|
-#endif /* PARSE_ENV */
|
|
|
|
|
|
/** Function for statistics trace messages */
|
|
|
-#define STATS_TRACE(...) fprintf(STATS_FD, __VA_ARGS__)
|
|
|
+#define STATS_TRACE(...) \
|
|
|
+ if(__builtin_expect (systemallocator.initialized, true)) { \
|
|
|
+ fprintf(STATS_FD, __VA_ARGS__); \
|
|
|
+ }
|
|
|
+
|
|
|
+#endif /* PARSE_ENV */
|
|
|
|
|
|
#else /* WITH_STATS_TRACE */
|
|
|
|
|
@@ -78,15 +98,23 @@ FILE* stats_fd;
|
|
|
#ifndef PARSE_ENV
|
|
|
/** Debug file descriptor */
|
|
|
#define DBG_FD stderr
|
|
|
+
|
|
|
+/** Function for debug trace messages */
|
|
|
+#define DBG_TRACE(...) fprintf(DBG_FD, __VA_ARGS__)
|
|
|
+
|
|
|
#else /* PARSE_ENV */
|
|
|
/** Debug file descriptor macro */
|
|
|
#define DBG_FD dbg_fd
|
|
|
/** Debug file descriptor */
|
|
|
FILE* dbg_fd;
|
|
|
-#endif /* PARSE_ENV */
|
|
|
|
|
|
/** Function for debug trace messages */
|
|
|
-#define DBG_TRACE(...) fprintf(DBG_FD, __VA_ARGS__)
|
|
|
+#define DBG_TRACE(...) \
|
|
|
+ if(__builtin_expect (systemallocator.initialized, true)) { \
|
|
|
+ fprintf(DBG_FD, __VA_ARGS__); \
|
|
|
+ }
|
|
|
+
|
|
|
+#endif /* PARSE_ENV */
|
|
|
|
|
|
#else /* WITH_DEBUG */
|
|
|
|