summaryrefslogtreecommitdiffstats
path: root/src/include/debug.h
blob: bb5d33f3c34db357afb2a501bef9ba7e500d957f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef DEBUG_H
#define DEBUG_H

//#include <lib.h>
extern int last_putchar;

/* Defining DEBUG_THIS before including this file enables debug() macro
 * for the file. DEBUG_ALL is for global control. */

#if DEBUG_THIS || DEBUG_ALL
#define DEBUG 1
#else
#undef DEBUG
#endif

#if DEBUG
# define debug(...) \
    ((last_putchar=='\n' ? printf("%s: ", __FUNCTION__) : 0), \
    printf(__VA_ARGS__))
# define debug_hexdump hexdump
#else
# define debug(...) /* nothing */
# define debug_hexdump(...) /* nothing */
#endif

#define debugx debug

#endif /* DEBUG_H */