trace.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright Institute of Communication and Computer Systems (ICCS)
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. /**
  18. * @file trace.h
  19. * @author Ioannis Koutras (joko@microlab.ntua.gr)
  20. * @date September 2012
  21. * @brief Tracing functions
  22. */
  23. #ifndef _DMMLIB_TRACE_H_
  24. #define _DMMLIB_TRACE_H_
  25. #include <dmmlib/config.h>
  26. #ifdef WITH_MEM_TRACE
  27. #include <stdio.h>
  28. #ifndef PARSE_ENV
  29. /** Memory trace file descriptor */
  30. #define MEM_FD stderr
  31. #else /* PARSE_ENV */
  32. /** Memory trace file descriptor macro */
  33. #define MEM_FD mem_fd
  34. /** Memory trace file descriptor */
  35. FILE* mem_fd;
  36. #endif /* PARSE_ENV */
  37. /** Function for memory trace messages */
  38. #define MEM_TRACE(...) fprintf(MEM_FD, __VA_ARGS__)
  39. #else /* WITH_MEM_TRACE */
  40. /** Function for memory trace messages */
  41. #define MEM_TRACE(...) /* do nothing */
  42. #endif /* WITH_MEM_TRACE */
  43. #ifdef WITH_STATS_TRACE
  44. #include <stdio.h>
  45. #ifndef PARSE_ENV
  46. /** Statistics file descriptor */
  47. #define STATS_FD stderr
  48. #else /* PARSE_ENV */
  49. /** Statistics file descriptor macro */
  50. #define STATS_FD stats_fd
  51. /** Statistics file descriptor */
  52. FILE* stats_fd;
  53. #endif /* PARSE_ENV */
  54. /** Function for statistics trace messages */
  55. #define STATS_TRACE(...) fprintf(STATS_FD, __VA_ARGS__)
  56. #else /* WITH_STATS_TRACE */
  57. /** Function for statistics trace messages */
  58. #define STATS_TRACE(...) /* do nothing */
  59. #endif /* WITH_STATS_TRACE */
  60. #ifdef WITH_DEBUG
  61. #include <stdio.h>
  62. #ifndef PARSE_ENV
  63. /** Debug file descriptor */
  64. #define DBG_FD stderr
  65. #else /* PARSE_ENV */
  66. /** Debug file descriptor macro */
  67. #define DBG_FD dbg_fd
  68. /** Debug file descriptor */
  69. FILE* dbg_fd;
  70. #endif /* PARSE_ENV */
  71. /** Function for debug trace messages */
  72. #define DBG_TRACE(...) fprintf(DBG_FD, __VA_ARGS__)
  73. #else /* WITH_DEBUG */
  74. /** Function for debug trace messages */
  75. #define DBG_TRACE(...) /* do nothing */
  76. #endif /* WITH_DEBUG */
  77. #endif /* _DMMLIB_TRACE_H_ */