提交 2cbbc889 编写于 作者: S Shengliang Guan

enh: speed assert in release mode

上级 adbc11f8
......@@ -83,9 +83,14 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
#endif
;
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...);
#define ASSERTS(condition, ...) taosAssert(condition, __FILE__, __LINE__, __VA_ARGS__)
#define ASSERT(condition) ASSERTS(condition, "assert info not provided")
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...);
bool taosAssertRelease(bool condition);
#define ASSERTS(condition, ...) taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__)
#ifdef NDEBUG
#define ASSERT(condition) taosAssertRelease(condition)
#else
#define ASSERT(condition) taosAssertDebug(condition, __FILE__, __LINE__, "assert info not provided")
#endif
// clang-format off
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
......
......@@ -790,7 +790,7 @@ cmp_end:
return ret;
}
bool taosAssert(bool condition, const char *file, int32_t line, const char *format, ...) {
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) {
if (condition) return false;
const char *flags = "UTL FATAL ";
......@@ -822,4 +822,24 @@ bool taosAssert(bool condition, const char *file, int32_t line, const char *form
}
return true;
}
\ No newline at end of file
}
#ifdef NDEBUG
bool taosAssertRelease(bool condition) {
if (condition) return false;
const char *flags = "UTL FATAL ";
ELogLevel level = DEBUG_FATAL;
int32_t dflag = 255; // tsLogEmbedded ? 255 : uDebugFlag
taosPrintLog(flags, level, dflag, "tAssert called in release mode, exit:%d", tsAssert);
taosPrintTrace(flags, level, dflag);
if (tsAssert) {
taosMsleep(300);
abort();
}
return true;
}
#endif
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册