forked from hegdi/libldacdec
-
Notifications
You must be signed in to change notification settings - Fork 7
/
log.h
64 lines (48 loc) · 1.44 KB
/
log.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef __LOG_H_
#define __LOG_H_
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef DEBUG
#define LOG( format, ... ) \
{ \
printf( format, __VA_ARGS__ ); \
}
#define LOG_ARRAY( var, format ) \
{ \
__auto_type len = sizeof(var)/sizeof(var[0]); \
printf("%s[%ld] =\n", #var, len ); \
for( typeof(len) i=0; i<len; ++i ) \
{ \
printf( format, var[i] ); \
if( ((i+1)%16) == 0 ) \
printf("\n"); \
} \
printf("\n"); \
}
#define LOG_ARRAY_LEN( var, format, length )\
{ \
__auto_type len = length; \
printf("%s[%d] =\n", #var, len ); \
for( typeof(len) i=0; i<len; ++i ) \
{ \
printf( format, var[i] ); \
} \
printf("\n"); \
}
#define LOG_FUNCTION() { printf("%s\n", __FUNCTION__ ); }
#else
#define LOG( format, ... )
#define LOG_ARRAY( var, format )
#define LOG_ARRAY_LEN( var, format, len )
#define LOG_FUNCTION()
#endif
#ifdef DEBUG_ADAPTATION
#define LOG_ADAPT( format, ... ) \
{ \
printf( format, __VA_ARGS__ ); \
}
#else
#define LOG_ADAPT( format, ... )
#endif
#endif // __LOG_H_