mdbx: add mdbx_panic() to C API.

Change-Id: I009a7889311b57ae2210822a8087889f900919f8
This commit is contained in:
Leonid Yuriev 2020-09-10 15:37:59 +03:00
parent 58bcfb006e
commit cd4caeb03d
3 changed files with 7 additions and 11 deletions

3
mdbx.h
View File

@ -814,6 +814,9 @@ LIBMDBX_API int mdbx_env_set_assert(MDBX_env *env, MDBX_assert_func *func);
LIBMDBX_API const char *mdbx_dump_val(const MDBX_val *key, char *const buf,
const size_t bufsize);
/** \brief Panics with message and causes abnormal process termination. */
LIBMDBX_API void mdbx_panic(const char *fmt, ...) mdbx_printf_args(1, 2);
/** @} end of logging & debug */
/** \brief Environment flags

View File

@ -1064,13 +1064,6 @@ MDBX_INTERNAL_FUNC void mdbx_debug_log_va(int level, const char *function,
#endif /* MDBX_DEBUG */
#if defined(__ANDROID_API__)
#define mdbx_panic(fmt, ...) \
__android_log_assert("panic", "mdbx", fmt, __VA_ARGS__)
#else
void mdbx_panic(const char *fmt, ...) __printf_args(1, 2);
#endif
#if !MDBX_DEBUG && defined(__ANDROID_API__)
#define mdbx_assert_fail(env, msg, func, line) \
__android_log_assert(msg, "mdbx", "%s:%u", func, line)

View File

@ -238,8 +238,6 @@ void __cold mdbx_assert_fail(const MDBX_env *env, const char *msg,
#endif /* __ANDROID_API__ || MDBX_DEBUG */
#if !defined(__ANDROID_API__)
__cold void mdbx_panic(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
@ -257,14 +255,16 @@ __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
}
#endif /* ! __ANDROID_API__ */
/*----------------------------------------------------------------------------*/
#ifndef mdbx_vasprintf