123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #ifndef _DMMLIB_TRACE_H_
- #define _DMMLIB_TRACE_H_
- #include "dmmlib/config.h"
- #include "tls_allocator.h"
- #ifdef PARSE_ENV
- #include "dmmlib/dmmlib.h" /* to check if systemallocator is initialized */
- #endif
- #ifdef WITH_MEM_TRACE
- #include <stdio.h>
- #ifndef PARSE_ENV
- #define MEM_FD stderr
- #define MEM_TRACE(...) fprintf(MEM_FD, __VA_ARGS__)
- #else
- #define MEM_FD mem_fd
- FILE* mem_fd;
- #define MEM_TRACE(...) \
- get_tls_allocator(); \
- if(__builtin_expect (tls_allocator->initialized, true)) { \
- fprintf(MEM_FD, __VA_ARGS__); \
- }
- #endif
- #else
- #define MEM_TRACE(...)
- #endif
- #ifdef WITH_STATS_TRACE
- #include <stdio.h>
- #ifndef PARSE_ENV
- #define STATS_FD stderr
- #define STATS_TRACE(...) fprintf(STATS_FD, __VA_ARGS__)
- #else
- #define STATS_FD stats_fd
- FILE* stats_fd;
- #define STATS_TRACE(...) \
- get_tls_allocator(); \
- if(__builtin_expect (tls_allocator->initialized, true)) { \
- fprintf(STATS_FD, __VA_ARGS__); \
- }
- #endif
- #else
- #define STATS_TRACE(...)
- #endif
- #ifdef WITH_DEBUG
- #include <stdio.h>
- #ifndef PARSE_ENV
- #define DBG_FD stderr
- #define DBG_TRACE(...) fprintf(DBG_FD, __VA_ARGS__)
- #else
- #define DBG_FD dbg_fd
- FILE* dbg_fd;
- #define DBG_TRACE(...) \
- get_tls_allocator(); \
- if(__builtin_expect (tls_allocator->initialized, true)) { \
- fprintf(DBG_FD, __VA_ARGS__); \
- }
- #endif
- #else
- #define DBG_TRACE(...)
- #endif
- #endif
|