dynapi: Deal with failure cases better, other fixes.

Fixes Bugzilla #4803.
This commit is contained in:
Ryan C. Gordon 2019-10-14 12:41:06 -04:00
parent fe20c35be8
commit ec04110d8e
3 changed files with 72 additions and 34 deletions

View file

@ -120,32 +120,14 @@ static void SDL_GenerateAssertionReport(void)
}
/* This is not declared in any header, although it is shared between some
parts of SDL, because we don't want anything calling it without an
extremely good reason. */
#if defined(__WATCOMC__)
static void SDL_ExitProcess (int);
void SDL_ExitProcess(const int exitcode);
#pragma aux SDL_ExitProcess aborts;
#endif
static SDL_NORETURN void SDL_ExitProcess(int exitcode)
{
#ifdef __WIN32__
/* "if you do not know the state of all threads in your process, it is
better to call TerminateProcess than ExitProcess"
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
TerminateProcess(GetCurrentProcess(), exitcode);
/* MingW doesn't have TerminateProcess marked as noreturn, so add an
ExitProcess here that will never be reached but make MingW happy. */
ExitProcess(exitcode);
#elif defined(__EMSCRIPTEN__)
emscripten_cancel_main_loop(); /* this should "kill" the app. */
emscripten_force_exit(exitcode); /* this should "kill" the app. */
exit(exitcode);
#elif defined(__HAIKU__) /* Haiku has _Exit, but it's not marked noreturn. */
_exit(exitcode);
#elif defined(HAVE__EXIT) /* Upper case _Exit() */
_Exit(exitcode);
#else
_exit(exitcode);
#endif
}
SDL_NORETURN void SDL_ExitProcess(const int exitcode);
#if defined(__WATCOMC__)