mdbx: add mdbx_assert_fail() to public API.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-06-01 18:55:18 +03:00
parent 501691a3c0
commit 106f39327e
3 changed files with 5 additions and 19 deletions

4
mdbx.h
View File

@ -1004,6 +1004,10 @@ LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf,
/** \brief Panics with message and causes abnormal process termination. */
LIBMDBX_API void mdbx_panic(const char *fmt, ...) MDBX_PRINTF_ARGS(1, 2);
/** \brief Panics with asserton failed message and causes abnormal process
* termination. */
LIBMDBX_API void mdbx_assert_fail(const MDBX_env *env, const char *msg,
const char *func, unsigned line);
/** end of c_debug @} */
/** \brief Environment flags

View File

@ -1239,14 +1239,6 @@ MDBX_INTERNAL_FUNC void mdbx_debug_log_va(int level, const char *function,
#define mdbx_assert_enabled() (0)
#endif /* assertions */
#if !MDBX_DEBUG && defined(__ANDROID_API__)
#define mdbx_assert_fail(env, msg, func, line) \
__android_log_assert(msg, "mdbx", "%s:%u", func, line)
#else
void mdbx_assert_fail(const MDBX_env *env, const char *msg, const char *func,
int line);
#endif
#define mdbx_debug_extra(fmt, ...) \
do { \
if (mdbx_log_enabled(MDBX_LOG_EXTRA)) \

View File

@ -221,10 +221,8 @@ __extern_C void __assert(const char *function, const char *file, int line,
#endif /* __assert_fail */
#if !defined(__ANDROID_API__) || MDBX_DEBUG
__cold void mdbx_assert_fail(const MDBX_env *env, const char *msg,
const char *func, int line) {
const char *func, unsigned line) {
#if MDBX_DEBUG
if (env && env->me_assert_func) {
env->me_assert_func(env, msg, func, line);
@ -246,8 +244,6 @@ __cold void mdbx_assert_fail(const MDBX_env *env, const char *msg,
OutputDebugStringA(message);
if (IsDebuggerPresent())
DebugBreak();
#elif defined(__ANDROID_API__)
__android_log_assert(msg, "mdbx", "%s:%u", func, line);
#else
__assert_fail(msg, "mdbx", line, func);
#endif
@ -260,8 +256,6 @@ __cold void mdbx_assert_fail(const MDBX_env *env, const char *msg,
#endif
}
#endif /* __ANDROID_API__ || MDBX_DEBUG */
__cold void mdbx_panic(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
@ -279,12 +273,8 @@ __cold void mdbx_panic(const char *fmt, ...) {
if (IsDebuggerPresent())
DebugBreak();
FatalExit(ERROR_UNHANDLED_ERROR);
#else
#if defined(__ANDROID_API__)
__android_log_assert("panic", "mdbx", "%s", const_message);
#else
__assert_fail(const_message, "mdbx", 0, "panic");
#endif /* __ANDROID_API__ */
abort();
#endif
}