(int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
} while (0)
+#define TBM_STDOUT_INFO(fmt, args...) \
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ tbm_log_print_stdout(TBM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt, \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
+
#define TBM_NEVER_GET_HERE() TBM_WRN("** NEVER GET HERE **")
#define TBM_DEPRECATED(str) \
do { \
/* check condition */
#define TBM_RETURN_IF_FAIL(cond) {\
if (!(cond)) {\
- TBM_ERR("'%s' failed.\n", #cond);\
+ TBM_ERR("'%s' failed.", #cond);\
return;\
} \
}
#define TBM_RETURN_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_ERR("'%s' failed.\n", #cond);\
+ TBM_ERR("'%s' failed.", #cond);\
return val;\
} \
}
#define TBM_GOTO_VAL_IF_FAIL(cond, val) {\
if (!(cond)) {\
- TBM_ERR("'%s' failed.\n", #cond);\
+ TBM_ERR("'%s' failed.", #cond);\
+ goto val;\
+ } \
+}
+
+#define TBM_RETURN_SET_ERR_IF_FAIL(cond, error, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.", #cond);\
+ error = error_type;\
+ return;\
+ } \
+}
+
+#define TBM_RETURN_VAL_SET_ERR_IF_FAIL(cond, val, error, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.", #cond);\
+ error = error_type;\
+ return val;\
+ } \
+}
+
+#define TBM_GOTO_VAL_SET_ERR_IF_FAIL(cond, val, error, error_type) {\
+ if (!(cond)) {\
+ TBM_ERR("'%s' failed.", #cond);\
+ error = error_type;\
goto val;\
} \
}