Add private qAbort helper function
Used from qt_message_fatal(), but is useful in other situations too. Change-Id: I3c0e438536d40271061c76d954c7878abfe37b8e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
0da123d67b
commit
8f13af5d7b
@ -3359,6 +3359,35 @@ time_t qMkTime(struct tm *when)
|
|||||||
return mktime(when);
|
return mktime(when);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qAbort()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// std::abort() in the MSVC runtime will call _exit(3) if the abort
|
||||||
|
// behavior is _WRITE_ABORT_MSG - see also _set_abort_behavior(). This is
|
||||||
|
// the default for a debug-mode build of the runtime. Worse, MinGW's
|
||||||
|
// std::abort() implementation (in msvcrt.dll) is basically a call to
|
||||||
|
// _exit(3) too. Unfortunately, _exit() and _Exit() *do* run the static
|
||||||
|
// destructors of objects in DLLs, a violation of the C++ standard (see
|
||||||
|
// [support.start.term]). So we bypass std::abort() and directly
|
||||||
|
// terminate the application.
|
||||||
|
|
||||||
|
# if defined(Q_CC_MSVC) && !defined(Q_CC_INTEL)
|
||||||
|
if (IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE))
|
||||||
|
__fastfail(FAST_FAIL_FATAL_APP_EXIT);
|
||||||
|
# else
|
||||||
|
RaiseFailFastException(nullptr, nullptr, 0);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
// Fallback
|
||||||
|
TerminateProcess(GetCurrentProcess(), STATUS_FATAL_APP_EXIT);
|
||||||
|
|
||||||
|
// Tell the compiler the application has stopped.
|
||||||
|
Q_UNREACHABLE_IMPL();
|
||||||
|
#else // !Q_OS_WIN
|
||||||
|
std::abort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Also specified to behave as if they call tzset():
|
// Also specified to behave as if they call tzset():
|
||||||
// localtime() -- but not localtime_r(), which we use when threaded
|
// localtime() -- but not localtime_r(), which we use when threaded
|
||||||
// strftime() -- not used (except in tests)
|
// strftime() -- not used (except in tests)
|
||||||
|
@ -72,6 +72,11 @@ QT_BEGIN_NAMESPACE
|
|||||||
Q_CORE_EXPORT void qTzSet();
|
Q_CORE_EXPORT void qTzSet();
|
||||||
Q_CORE_EXPORT time_t qMkTime(struct tm *when);
|
Q_CORE_EXPORT time_t qMkTime(struct tm *when);
|
||||||
|
|
||||||
|
#if !defined(Q_CC_MSVC)
|
||||||
|
Q_NORETURN
|
||||||
|
#endif
|
||||||
|
Q_CORE_EXPORT void qAbort();
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#if !__has_builtin(__builtin_available)
|
#if !__has_builtin(__builtin_available)
|
||||||
|
@ -1872,31 +1872,7 @@ static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const
|
|||||||
Q_UNUSED(message);
|
Q_UNUSED(message);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
qAbort();
|
||||||
// std::abort() in the MSVC runtime will call _exit(3) if the abort
|
|
||||||
// behavior is _WRITE_ABORT_MSG - see also _set_abort_behavior(). This is
|
|
||||||
// the default for a debug-mode build of the runtime. Worse, MinGW's
|
|
||||||
// std::abort() implementation (in msvcrt.dll) is basically a call to
|
|
||||||
// _exit(3) too. Unfortunately, _exit() and _Exit() *do* run the static
|
|
||||||
// destructors of objects in DLLs, a violation of the C++ standard (see
|
|
||||||
// [support.start.term]). So we bypass std::abort() and directly
|
|
||||||
// terminate the application.
|
|
||||||
|
|
||||||
# if defined(Q_CC_MSVC) && !defined(Q_CC_INTEL)
|
|
||||||
if (IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE))
|
|
||||||
__fastfail(FAST_FAIL_FATAL_APP_EXIT);
|
|
||||||
# else
|
|
||||||
RaiseFailFastException(nullptr, nullptr, 0);
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// Fallback
|
|
||||||
TerminateProcess(GetCurrentProcess(), STATUS_FATAL_APP_EXIT);
|
|
||||||
|
|
||||||
// Tell the compiler the application has stopped.
|
|
||||||
Q_UNREACHABLE_IMPL();
|
|
||||||
#else // !Q_OS_WIN
|
|
||||||
std::abort();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user