You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.4 KiB
C
81 lines
2.4 KiB
C
#ifndef __DEBUG_H__
|
|
#define __DEBUG_H__
|
|
|
|
#define CHECK(cond,ret) \
|
|
do{\
|
|
if((cond)){\
|
|
return((ret));\
|
|
}\
|
|
}while(0)
|
|
|
|
#define CHK_RETURN(cond,msg,ret) \
|
|
do{\
|
|
if((cond)){\
|
|
if((msg))ERR((msg));\
|
|
return((ret));\
|
|
}\
|
|
}while(0)
|
|
|
|
|
|
void printArray(const char * func, int line, unsigned char arr[], int l);
|
|
|
|
#define _MSG_ARRAY(array, len) do { \
|
|
if (1) \
|
|
{ \
|
|
printArray(__func__, __LINE__, array, len);\
|
|
} \
|
|
} while(0)
|
|
|
|
#define print_raw_data(data, len) _MSG_ARRAY(data, len)
|
|
|
|
#define DEBUG 1
|
|
#ifdef DEBUG
|
|
|
|
#define LOG(format,...) printf("[%s:%d] "format"\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
|
|
|
#define ERROR(format,...) \
|
|
do{ \
|
|
fprintf(stderr, "[ERROR at:]%s func: %s line: %d\nerror:"format"\n", \
|
|
__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
|
|
}while(0)
|
|
|
|
#define PrintArray1D(arr, m) \
|
|
do \
|
|
{ \
|
|
if (m > 0) { \
|
|
int i = 0; \
|
|
printf("arr:"); \
|
|
for (i = 0; i < m; i++) { \
|
|
if(arr[i] == '\0') \
|
|
printf(" "); \
|
|
else \
|
|
printf("%c ", arr[i]); \
|
|
} \
|
|
printf("\n"); \
|
|
} \
|
|
}while(0)
|
|
|
|
#define PrintArray2D(arr, m, n) \
|
|
do \
|
|
{ \
|
|
int i = 0; \
|
|
int j = 0; \
|
|
for(i=0;i<m;i++) \
|
|
{ \
|
|
for(j=0;j<n;j++) \
|
|
{ \
|
|
printf("%f ",arr[i][j]); \
|
|
} \
|
|
printf("\n"); \
|
|
} \
|
|
}while(0)
|
|
|
|
#else
|
|
#define LOG(format,...) NULL
|
|
#define ERROR(format,...) NULL
|
|
#define PrintArray1D(arr,m) NULL
|
|
#define PrintArray2D(arr,m,n) NULL
|
|
#endif
|
|
#endif
|
|
|