Coverage Report

Created: 2025-06-15 00:57

/src/cmp_tool/lib/common/cmp_debug.h
Line
Count
Source
1
/**
2
 * @file   cmp_debug.h
3
 * @author Dominik Loidolt (dominik.loidolt@univie.ac.at)
4
 * @date   2020
5
 *
6
 * @copyright GPLv2
7
 * This program is free software; you can redistribute it and/or modify it
8
 * under the terms and conditions of the GNU General Public License,
9
 * version 2, as published by the Free Software Foundation.
10
 *
11
 * This program is distributed in the hope it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14
 * more details.
15
 *
16
 * @brief compression/decompression debugging printing functions
17
 */
18
19
#ifndef CMP_DEBUG_H
20
#define CMP_DEBUG_H
21
22
23
/* DEBUGLEVEL should be externally defined, usually via the compiler command
24
 * line.  Its value must be a numeric value. */
25
#ifndef DEBUGLEVEL
26
#  ifdef DEBUG
27
#    define DEBUGLEVEL 1
28
#  else
29
#    define DEBUGLEVEL 0
30
#  endif
31
#endif
32
33
34
#define PRINT_BUFFER_SIZE 256
35
36
#if (DEBUGLEVEL > 0)
37
__extension__
38
#  define debug_print(...) cmp_debug_print_impl(__VA_ARGS__)
39
void cmp_debug_print_impl(const char *fmt, ...);
40
#else
41
__extension__
42
1.69k
#  define debug_print(...) do {} while (0)
43
#endif
44
45
__extension__
46
#define debug_print_level(level, ...)     \
47
  do {            \
48
    if ((level) <= DEBUGLEVEL)    \
49
      debug_print(__VA_ARGS__); \
50
  } while (0)
51
52
53
#endif /* CMP_DEBUG_H */